From db24973abeccb64a9c40239da952ca0fd6e147e2 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 7 Mar 2012 13:49:08 +0100 Subject: [PATCH] [FIX] Dashboard does not handle two actions with the same action id. Dashboard should be refactored in trunk in order to be nivified and use a DashBoardAction class bzr revid: fme@openerp.com-20120307124908-q48a2d8epae73wwx --- addons/web_dashboard/static/src/js/dashboard.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/addons/web_dashboard/static/src/js/dashboard.js b/addons/web_dashboard/static/src/js/dashboard.js index 1ebc987c9f6..698d0b7da08 100644 --- a/addons/web_dashboard/static/src/js/dashboard.js +++ b/addons/web_dashboard/static/src/js/dashboard.js @@ -11,7 +11,6 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({ init: function(view, node) { this._super(view, node); this.template = 'DashBoard'; - this.actions_attrs = {}; this.action_managers = []; }, start: function() { @@ -31,18 +30,16 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({ this.$element.delegate('.oe-dashboard-column .oe-dashboard-fold', 'click', this.on_fold_action); this.$element.delegate('.oe-dashboard-column .ui-icon-closethick', 'click', this.on_close_action); - this.actions_attrs = {}; // Init actions _.each(this.node.children, function(column, column_index) { _.each(column.children, function(action, action_index) { delete(action.attrs.width); delete(action.attrs.height); delete(action.attrs.colspan); - self.actions_attrs[action.attrs.name] = action.attrs; self.rpc('/web/action/load', { action_id: parseInt(action.attrs.name, 10) }, function(result) { - self.on_load_action(result, column_index + '_' + action_index); + self.on_load_action(result, column_index + '_' + action_index, action.attrs); }); }); }); @@ -97,9 +94,9 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({ $action = $e.parents('.oe-dashboard-action:first'), id = parseInt($action.attr('data-id'), 10); if ($e.is('.ui-icon-minusthick')) { - this.actions_attrs[id].fold = '1'; + $action.data('action_attrs').fold = '1'; } else { - delete(this.actions_attrs[id].fold); + delete($action.data('action_attrs').fold); } $e.toggleClass('ui-icon-minusthick ui-icon-plusthick'); $action.find('.oe-dashboard-action-content').toggle(); @@ -122,7 +119,7 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({ var actions = []; $(this).find('.oe-dashboard-action').each(function() { var action_id = $(this).attr('data-id'), - new_attrs = _.clone(self.actions_attrs[action_id]); + new_attrs = _.clone($(this).data('action_attrs')); if (new_attrs.domain) { new_attrs.domain = new_attrs.domain_string; delete(new_attrs.domain_string); @@ -143,10 +140,9 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({ self.$element.find('.oe-dashboard-link-reset').show(); }); }, - on_load_action: function(result, index) { + on_load_action: function(result, index, action_attrs) { var self = this, action = result.result, - action_attrs = this.actions_attrs[action.id], view_mode = action_attrs.view_mode; if (action_attrs.context) { @@ -187,6 +183,7 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({ var am = new openerp.web.ActionManager(this), // FIXME: ideally the dashboard view shall be refactored like kanban. $action = $('#' + this.view.element_id + '_action_' + index); + $action.parent().data('action_attrs', action_attrs); this.action_managers.push(am); am.appendTo($action); am.do_action(action);