From 40dd121938552d3f88289d2e5fcd1d57a0dd01bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 6 Dec 2018 12:39:06 +0000 Subject: [REF] web: move ControlPanel inside controllers/actions This branch introduces a large-scale reorganization of the component tree generated by the web client. The short version is that now, the control panel is a child of the view controller and no longer a sibling. Graphically (and simplified), we go from this: webClient / | \ ... ... actionManager / \ controlPanel viewController / \ to this: webClient / | \ ... ... actionManager | viewController / | \ ControlPanelController / \ CPRenderer CPModel The motivation is that this work moves the code where it should be. Before this commit, it was kind of weird to have code in the controllers to render buttons outside of their root node (in renderButtons). Also, the action manager had to take care of coordinating search view states between view transitions. So, this work simplifies the code. It also makes it easier to extend. We see day after day that Odoo needs to take care of more complex UI needs, and in many cases, these needs were quite difficult to implement (we prefer spaghettis in our plates, not in our code). The changes in this branch should open the way to implement these features. For example, - it will now be easy to add the possibility of views (for example, the search view or a new ControlPanel view) to add custom buttons (of type action or object) in the control panel. - Another need will be to serialize/ restore the state of the search view across action boundaries (needed by the dashboard). - Another example is the possibility for views to customize easily the presence/absence of sub menus (filters/groupbys/favorites/ time range/...) - Another need is an easier way for views/client action to customize their control panel. This commit also contains a large rewrite of the search view (so it is more inline with our architecture and easier to maintain). Part of task 1893568 Co-authored-by: Aaron Bohy Co-authored-by: Mathieu Duckerts-Antoine Co-authored-by: Martin Geubelle --- addons/web/static/src/js/fields/relational_fields.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 60b0275c8c8..6d53d283f8a 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -16,7 +16,7 @@ odoo.define('web.relational_fields', function (require) { var AbstractField = require('web.AbstractField'); var basicFields = require('web.basic_fields'); var concurrency = require('web.concurrency'); -var ControlPanel = require('web.ControlPanel'); +var ControlPanelView = require('web.ControlPanelView'); var dialogs = require('web.view_dialogs'); var core = require('web.core'); var data = require('web.data'); @@ -1030,7 +1030,14 @@ var FieldX2Many = AbstractField.extend({ } var self = this; var defs = []; - this.control_panel = new ControlPanel(this, "X2ManyControlPanel"); + var controlPanelView = new ControlPanelView({ + template: 'X2ManyControlPanel', + withSearchBar: false, + }); + var cpDef = controlPanelView.getController(this).then(function (controlPanel) { + self._controlPanel = controlPanel; + return self._controlPanel.prependTo(self.$el); + }); this.pager = new Pager(this, this.value.count, this.value.offset + 1, this.value.limit, { single_page_hidden: true, withAccessKey: false, @@ -1053,9 +1060,9 @@ var FieldX2Many = AbstractField.extend({ }); this._renderButtons(); defs.push(this.pager.appendTo($('
'))); // start the pager - defs.push(this.control_panel.prependTo(this.$el)); + defs.push(cpDef); return $.when.apply($, defs).then(function () { - self.control_panel.update({ + self._controlPanel.updateContents({ cp_content: { $buttons: self.$buttons, $pager: self.pager.$el, -- cgit v1.2.3