From 9ba78dfcce85a9b115b338d6b3193bb34be43d35 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 21 Mar 2017 08:52:35 +0100 Subject: [PATCH] [FIX] web: reload view with correct params When reloading a view by clicking on its icon in the view switcher, some params of the view (e.g. limit) were reset to their original value. So if the user previously updated that param (e.g. by editing the pager), these changes were lost. This rev. ensures that those original params are only given to the view at its initialization, but not on reload. --- .../web/static/src/js/chrome/view_manager.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js index d2700854fe3..af1d037bc2f 100644 --- a/addons/web/static/src/js/chrome/view_manager.js +++ b/addons/web/static/src/js/chrome/view_manager.js @@ -84,9 +84,9 @@ var ViewManager = Widget.extend(ControlPanelMixin, { this.title = this.action.name; var actionGroupBy = self.action.context.group_by; if (!actionGroupBy) { - actionGroupBy = [] + actionGroupBy = []; } else if (typeof actionGroupBy === 'string') { - actionGroupBy = [actionGroupBy] + actionGroupBy = [actionGroupBy]; } _.each(views, function (view) { var view_type = view[1] || view.view_type; @@ -236,18 +236,6 @@ var ViewManager = Widget.extend(ControlPanelMixin, { } var old_view = this.active_view; - view_options = _.extend({}, view.options, view_options, this.env); - - if (view_options.groupBy && !view_options.groupBy.length) { - var actionContext = view_options ? view_options.action.context : {}; - var actionGroupBy = actionContext.group_by; - if (!actionGroupBy) { - actionGroupBy = [] - } else if (typeof actionGroupBy === 'string') { - actionGroupBy = [actionGroupBy] - } - view_options.groupBy = actionGroupBy; - } // Ensure that the fields_view has been loaded var views_def; @@ -267,6 +255,17 @@ var ViewManager = Widget.extend(ControlPanelMixin, { self.active_view = view; if (!view.loaded) { + view_options = _.extend({}, view.options, view_options, self.env); + if (view_options.groupBy && !view_options.groupBy.length) { + var actionContext = view_options ? view_options.action.context : {}; + var actionGroupBy = actionContext.group_by; + if (!actionGroupBy) { + actionGroupBy = []; + } else if (typeof actionGroupBy === 'string') { + actionGroupBy = [actionGroupBy]; + } + view_options.groupBy = actionGroupBy; + } view.loaded = $.Deferred(); self.create_view(view, view_options).then(function(controller) { view.controller = controller; @@ -279,6 +278,7 @@ var ViewManager = Widget.extend(ControlPanelMixin, { }); } else { view.loaded = view.loaded.then(function() { + view_options = _.extend({}, view_options, self.env); return view.controller.reload(view_options); }); }