diff options
Diffstat (limited to 'addons/web/static/src/js/chrome/abstract_web_client.js')
| -rw-r--r-- | addons/web/static/src/js/chrome/abstract_web_client.js | 55 |
1 files changed, 39 insertions, 16 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 45a2b0b1e8c..c491297abfc 100644 --- a/addons/web/static/src/js/chrome/abstract_web_client.js +++ b/addons/web/static/src/js/chrome/abstract_web_client.js @@ -36,8 +36,8 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { toggle_fullscreen: function (event) { this.toggle_fullscreen(event.data.fullscreen); }, - current_action_updated: function (e) { - this.current_action_updated(e.data.action); + current_action_updated: function (ev) { + this.current_action_updated(ev.data.action, ev.data.controller); }, // GENERIC SERVICES // the next events are dedicated to generic services required by @@ -51,6 +51,7 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { } }, warning: '_onDisplayWarning', + load_action: '_onLoadAction', load_views: function (event) { var params = { model: event.data.modelName, @@ -66,6 +67,7 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { .load_filters(event.data.dataset, event.data.action_id) .then(event.data.on_success); }, + push_state: '_onPushState', show_effect: '_onShowEffect', // session get_session: function (event) { @@ -199,7 +201,7 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { }; }, set_action_manager: function () { - this.action_manager = new ActionManager(this, {webclient: this}); + this.action_manager = new ActionManager(this, session.user_context); return this.action_manager.appendTo(this.$('.o_main_content')); }, set_notification_manager: function () { @@ -213,11 +215,7 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { show_application: function () { }, clear_uncommitted_changes: function () { - var def = $.Deferred().resolve(); - core.bus.trigger('clear_uncommitted_changes', function chain_callbacks(callback) { - def = def.then(callback); - }); - return def; + return this.action_manager.clearUncommittedChanges(); }, destroy_content: function () { _.each(_.clone(this.getChildren()), function (el) { @@ -264,7 +262,7 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { * This allows to widgets that are not inside the ActionManager to perform do_action */ do_action: function () { - return this.action_manager.do_action.apply(this, arguments); + return this.action_manager.doAction.apply(this.action_manager, arguments); }, do_reload: function () { var self = this; @@ -274,6 +272,9 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { }); }, do_push_state: function (state) { + if (!state.menu_id && this.menu) { // this.menu doesn't exist in the POS + state.menu_id = this.menu.getCurrentPrimaryMenu(); + } if ('title' in state) { this.set_title(state.title); delete state.title; @@ -304,13 +305,14 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { this.connection_notification = false; } }, - // Handler to be overwritten - current_action_updated: function () { - }, - // -------------------------------------------------------------- - // Scrolltop handling - // -------------------------------------------------------------- - getScrollTop: function () { + /** + * Handler to be overridden, called each time the UI is updated by the + * ActionManager. + * + * @param {Object} action the action of the currently displayed controller + * @param {Object} controller the currently displayed controller + */ + current_action_updated: function (action, controller) { }, //-------------------------------------------------------------- // Misc. @@ -347,6 +349,27 @@ var AbstractWebClient = Widget.extend(mixins.ServiceProvider, { } }, /** + * Loads an action from the database given its ID. + * + * @private + * @param {OdooEvent} event + * @param {integer} event.data.actionID + * @param {Object} event.data.context + * @param {function} event.data.on_success + */ + _onLoadAction: function (event) { + data_manager + .load_action(event.data.actionID, event.data.context) + .then(event.data.on_success); + }, + /** + * @private + * @param {OdooEvent} e + */ + _onPushState: function (e) { + this.do_push_state(e.data.state); + }, + /** * Displays a visual effect (for example, a rainbowman0 * * @private |
