From 32b8cec5361174c92c45a4975d4e02f1fb448aa2 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 17 Nov 2017 13:14:02 +0100 Subject: [REF] web,*: ActionManager/ViewManager refactoring This rev. is the first part (out of 3) of the refactoring of the ActionManager and ViewManager layer of the webclient. The main changes are: - there is no ViewManager anymore, its work is now handled by the ActionManager itself, but isolated in a specific file ; this eases a lot of things, as the breadcrumbs handling for example. - the ActionManager code is converted to the new coding principles and guidelines ; mainly, children widgets communicate with it by triggering events up, and not by function calls anymore. - the ActionManager layer is now testable, and a lot of tests have already been written. - the code in other addons has been adapted consequently. What's coming next: - introduce the 'AbstractAction' Widget, and make client actions and view controllers inherit from it ; this widget will implement a common API that could be used uniformly by the ActionManager (e.g. restore(), canBeLeft(), renderButtons(), getTitle()...). - move the ControlPanel handling from the ActionManager to the AbstractAction. --- addons/google_spreadsheet/static/src/js/search.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'addons/google_spreadsheet/static/src') diff --git a/addons/google_spreadsheet/static/src/js/search.js b/addons/google_spreadsheet/static/src/js/search.js index a9f8e392d0a..20b7c804f33 100644 --- a/addons/google_spreadsheet/static/src/js/search.js +++ b/addons/google_spreadsheet/static/src/js/search.js @@ -7,27 +7,28 @@ var data = require('web.data'); var Domain = require('web.Domain'); var FavoriteMenu = require('web.FavoriteMenu'); var pyeval = require('web.pyeval'); -var ViewManager = require('web.ViewManager'); var QWeb = core.qweb; FavoriteMenu.include({ start: function () { this._super(); - var am = this.findAncestor(function (a) { - return a instanceof ActionManager; - }); - if (am && am.get_inner_widget() instanceof ViewManager) { - this.view_manager = am.get_inner_widget(); + if (this.action.type === 'ir.actions.act_window') { this.$('.o_favorites_menu').append(QWeb.render('SearchView.addtogooglespreadsheet')); this.$('.add-to-spreadsheet').click(this.add_to_spreadsheet.bind(this)); } }, add_to_spreadsheet: function () { + // AAB: trigger_up an event that will be intercepted by the controller, + // as soon as the controller is the parent of the control panel + var am = this.findAncestor(function (a) { + return a instanceof ActionManager; + }); + var controller = am.getCurrentController(); var sv_data = this.searchview.build_search_data(), model = this.searchview.dataset.model, - list_view = this.view_manager.views.list, - list_view_id = list_view ? list_view.view_id : false, + list_view = _.findWhere(controller.widget.actionViews, {type: 'list'}), + list_view_id = list_view ? list_view.viewID : false, domain = [], groupbys = pyeval.eval('groupbys', sv_data.groupbys).join(" "), ds = new data.DataSet(this, 'google.drive.config'); -- cgit v1.2.3