summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/root_widget.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2018-08-08 18:54:43 +0200
committerChristophe Matthieu <chm@odoo.com>2018-08-09 02:31:59 +0200
commit6448420c5dd160470e465dee7729d19d8d5e7bab (patch)
treec2696ff4e1f7abd90af8570804bc86a524790860 /addons/web_editor/static/src/js/root_widget.js
parent791c70b329bf513a4c9359d38603b10dc6066829 (diff)
[IMP] bus: re-factoring of bus.bus (Longpolling and CrossTab)
The purpose of this change is to make the code clearer and testable. In this change, the 'tab_manager' static object was merged with the bus cross tab. Cleaning was done to clearly define private and public functions as well as handlers. The methods are documented and the constants are now defined on the class. The bus use the service behavior with 'trigger_up'. 'bus.CrossTab' who extend 'bus.Longpolling' are instantiated by the bus service. The class is always instantiated with a parent, or root in the case of the website (im_livechat), to use the ajax and localstorage services. So the behavior, perhaps logger or redefined by the parents.
Diffstat (limited to 'addons/web_editor/static/src/js/root_widget.js')
-rw-r--r--addons/web_editor/static/src/js/root_widget.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/addons/web_editor/static/src/js/root_widget.js b/addons/web_editor/static/src/js/root_widget.js
index 98a14908f10..462dcd9bae9 100644
--- a/addons/web_editor/static/src/js/root_widget.js
+++ b/addons/web_editor/static/src/js/root_widget.js
@@ -4,6 +4,7 @@ odoo.define('web_editor.root_widget', function (require) {
var Class = require('web.Class');
var dom = require('web.dom');
var mixins = require('web.mixins');
+var session = require('web.session');
var Widget = require('web.Widget');
/**
@@ -15,13 +16,13 @@ var Widget = require('web.Widget');
var RootWidget = Widget.extend({
custom_events: _.extend({}, Widget.prototype.custom_events || {}, {
registry_update: '_onRegistryUpdate',
+ get_session: '_onGetSession',
}),
/**
* @constructor
*/
init: function () {
this._super.apply(this, arguments);
-
this._widgets = [];
this._listenToUpdates = false;
this._getRegistry().setParent(this);
@@ -98,6 +99,17 @@ var RootWidget = Widget.extend({
//--------------------------------------------------------------------------
/**
+ * Get the curuent session module.
+ *
+ * @private
+ * @param {OdooEvent} ev
+ */
+ _onGetSession: function (event) {
+ if (event.data.callback) {
+ event.data.callback(session);
+ }
+ },
+ /**
* Called when the linked registry is updated after this `RootWidget`
*
* @private