From 0562940f2c0cfb5483ba1043fffc86988d97445a Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 29 Oct 2019 08:37:01 +0000 Subject: [FIX] mail: dicuss can save favorite filters In discuss, make a search with some stuff, and try to save that filter as favorite Before this commit, there was a crash, because the Discuss action did not implement what the controllers do to save favorites. After this commit, it is possible to save a filter as favorite OPW 2087258 closes odoo/odoo#39519 X-original-commit: 5514a414324675bf5c2cc0360e429a7d2548b16f Signed-off-by: Lucas Perais (lpe) --- addons/web/static/src/js/chrome/action_mixin.js | 24 ++++++++++++++++++++++ .../web/static/src/js/views/abstract_controller.js | 20 ++---------------- 2 files changed, 26 insertions(+), 18 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome/action_mixin.js b/addons/web/static/src/js/chrome/action_mixin.js index fa13e64e63e..b4a02879154 100644 --- a/addons/web/static/src/js/chrome/action_mixin.js +++ b/addons/web/static/src/js/chrome/action_mixin.js @@ -34,6 +34,15 @@ var ActionMixin = { */ contentTemplate: null, + /** + * Events built by and managed by Odoo Framework + * + * It is expected that any Widget Class implementing this mixin + * will also implement the ParentedMixin which actually manages those + */ + custom_events: { + get_controller_query_params: '_onGetControllerQueryParams', + }, /** * If an action wants to use a control panel, it will be created and * registered in this _controlPanel key (the widget). The way this control @@ -178,6 +187,21 @@ var ActionMixin = { this._title = title; this.updateControlPanel({title: this._title}, {clear: false}); }, + /** + * FIXME: this logic should be rethought + * + * Handles a context request: provides to the caller the state of the + * current controller. + * + * @private + * @param {OdooEvent} ev + * @param {function} ev.data.callback used to send the requested state + */ + _onGetControllerQueryParams: function (ev) { + ev.stopPropagation(); + var state = this.getOwnedQueryParams(); + ev.data.callback(state || {}); + }, }; return ActionMixin; diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index 43a485fb009..780b0bcf1b6 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -24,14 +24,13 @@ var session = require('web.session'); var QWeb = core.qweb; var AbstractController = mvc.Controller.extend(ActionMixin, { - custom_events: { - get_controller_query_params: '_onGetControllerQueryParams', + custom_events: _.extend({}, ActionMixin.custom_events, { navigation_move: '_onNavigationMove', open_record: '_onOpenRecord', search: '_onSearch', switch_view: '_onSwitchView', search_panel_domain_updated: '_onSearchPanelDomainUpdated', - }, + }), events: { 'click a[type="action"]': '_onActionClicked', }, @@ -546,21 +545,6 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { }); } }, - /** - * FIXME: this logic should be rethought - * - * Handles a context request: provides to the caller the state of the - * current controller. - * - * @private - * @param {OdooEvent} ev - * @param {function} ev.data.callback used to send the requested state - */ - _onGetControllerQueryParams: function (ev) { - ev.stopPropagation(); - var state = this.getOwnedQueryParams(); - ev.data.callback(state || {}); - }, /** * Called either from the control panel to focus the controller * or from the view to focus the search bar -- cgit v1.2.3