From 01e3a5996f9fab841be270b84f0877d0b8b9fc37 Mon Sep 17 00:00:00 2001 From: mcm-odoo Date: Wed, 15 Jan 2020 13:03:29 +0000 Subject: [REF] web: pivot: use owl_compatibility tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit changes ControllerAdapter to a mixin that inherits WidgetAdapterMixin and RendererWrapper now extends ComponentWrapper. This commit also changes PivotController base class/mixin and uses the Odoo legacy custom_events because of the adapter. closes odoo/odoo#43256 Related: odoo/enterprise#7744 Signed-off-by: Géry Debongnie (ged) --- .../web/static/src/js/views/abstract_controller.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src/js/views/abstract_controller.js') diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index 152d8c08071..a0152e5ccc4 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -18,12 +18,13 @@ var concurrency = require('web.concurrency'); var config = require('web.config'); var core = require('web.core'); var mvc = require('web.mvc'); +var { WidgetAdapterMixin } = require('web.OwlCompatibility'); var session = require('web.session'); var QWeb = core.qweb; -var AbstractController = mvc.Controller.extend(ActionMixin, { +var AbstractController = mvc.Controller.extend(ActionMixin, WidgetAdapterMixin, { custom_events: _.extend({}, ActionMixin.custom_events, { navigation_move: '_onNavigationMove', open_record: '_onOpenRecord', @@ -106,6 +107,7 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { this.controlPanelElements.$switch_buttons.off(); } this._super.apply(this, arguments); + WidgetAdapterMixin.destroy.call(this, ...arguments); }, /** * Called each time the controller is attached into the DOM. @@ -118,6 +120,7 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { this._searchPanel.on_attach_callback(); } this.renderer.on_attach_callback(); + WidgetAdapterMixin.on_attach_callback.call(this, ...arguments); }, /** * Called each time the controller is detached from the DOM. @@ -127,6 +130,7 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { this._controlPanel.on_detach_callback(); } this.renderer.on_detach_callback(); + WidgetAdapterMixin.on_detach_callback.call(this, ...arguments); }, //-------------------------------------------------------------------------- @@ -296,16 +300,17 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { }); }); }, - /** - * Update the state of the renderer. - * This method is required to be overridden in OWL components through the controller - * adapter + * Update the state of the renderer (handle both Widget and Component + * renderers). * * @param {Object} state the model state * @param {Object} params will be given to the model and to the renderer */ - updateRendererState: function(state, params) { + updateRendererState: function (state, params) { + if (this.renderer instanceof owl.Component) { + return this.renderer.update(state); + } return this.renderer.updateState(state, params); }, @@ -462,6 +467,9 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { * @private */ _startRenderer: function () { + if (this.renderer instanceof owl.Component) { + return this.renderer.mount(this.$('.o_content')[0]); + } return this.renderer.appendTo(this.$('.o_content')); }, /** -- cgit v1.2.3