summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/chrome
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2020-05-28 09:55:44 +0000
committerAaron Bohy <aab@odoo.com>2020-06-12 08:04:14 +0000
commit26fe23201bb495176d14c15c8866e8fc72ca044c (patch)
treed464bed68b4a9e5494869db375c0aea103d69350 /addons/web/static/src/js/chrome
parentc4786fccfd23360a02e442c48ae2fb9f1e70aa4c (diff)
[IMP] web,*: properly define env in the frontend
*bus,mail This commit extracts the common basis of the env to use both in the frontend and the backend. The public env now contains most of the features that were previously (only) in the webclient env. Moreover, the PublicRoot no longer uses the ServiceProviderMixin, such that services are only deployed once, in the (public) env. Owl components can now be defined in the website, and rely on a properly built env. Legacy widgets still works as they access services through the PublicRoot (via trigger_up) which redirects those requests to the env.
Diffstat (limited to 'addons/web/static/src/js/chrome')
-rw-r--r--addons/web/static/src/js/chrome/abstract_web_client.js34
1 files changed, 12 insertions, 22 deletions
diff --git a/addons/web/static/src/js/chrome/abstract_web_client.js b/addons/web/static/src/js/chrome/abstract_web_client.js
index 0cabba1d23d..95d9868b89a 100644
--- a/addons/web/static/src/js/chrome/abstract_web_client.js
+++ b/addons/web/static/src/js/chrome/abstract_web_client.js
@@ -20,7 +20,6 @@ var data_manager = require('web.data_manager');
var dom = require('web.dom');
var KeyboardNavigationMixin = require('web.KeyboardNavigationMixin');
var Loading = require('web.Loading');
-var local_storage = require('web.local_storage');
var RainbowMan = require('web.RainbowMan');
var session = require('web.session');
var utils = require('web.utils');
@@ -103,7 +102,7 @@ var AbstractWebClient = Widget.extend(KeyboardNavigationMixin, {
this.action_mutex = new concurrency.Mutex();
this.set('title_part', {"zopenerp": "Odoo"});
this.env = env;
- core.bus.on('legacy_webclient_request', this, this._onLegacyWebclientRequest);
+ this.env.bus.on('set_title_part', this, this._onSetTitlePart);
},
/**
* @override
@@ -206,6 +205,11 @@ var AbstractWebClient = Widget.extend(KeyboardNavigationMixin, {
set_action_manager: function () {
var self = this;
this.action_manager = new ActionManager(this, session.user_context);
+ this.env.bus.on('do-action', this, payload => {
+ this.action_manager.doAction(payload.action, payload.options)
+ .then(payload.on_success || (() => {}))
+ .guardedCatch(payload.on_fail || (() => {}));
+ });
var fragment = document.createDocumentFragment();
return this.action_manager.appendTo(fragment).then(function () {
dom.append(self.$el, fragment, {
@@ -440,20 +444,6 @@ var AbstractWebClient = Widget.extend(KeyboardNavigationMixin, {
ev.data.callback(this.getScrollPosition());
},
/**
- * Services used to trigger_up some events (e.g. do_action, get_session,
- * set_title_part) when the webclient was still instantiating them. Now that
- * services have been moved to the env, the webclient is no longer their
- * parent and they can thus no longer communicate with the webclient by
- * trigger_up. Instead, they trigger those events on the bus, and we end up
- * in this handler. Eventually, services should stop triggering events up.
- *
- * @private
- * @param {CustomEvent} ev
- */
- _onLegacyWebclientRequest: function (ev) {
- this._trigger_up(ev);
- },
- /**
* Loads an action from the database given its ID.
*
* @private
@@ -502,13 +492,13 @@ var AbstractWebClient = Widget.extend(KeyboardNavigationMixin, {
},
/**
* @private
- * @param {OdooEvent} ev
- * @param {string} ev.data.part
- * @param {string} [ev.data.title]
+ * @param {Object} payload
+ * @param {string} payload.part
+ * @param {string} [payload.title]
*/
- _onSetTitlePart: function (ev) {
- var part = ev.data.part;
- var title = ev.data.title;
+ _onSetTitlePart: function (payload) {
+ var part = payload.part;
+ var title = payload.title;
this.set_title_part(part, title);
},
/**