From 47762dfca2c49a8da9f9fd1b57f966a27d96f602 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Fri, 3 Jan 2014 15:44:18 +0100 Subject: [PATCH] [IMP] allows the selection of multiple measures in graph view (addon web_graph) bzr revid: ged@openerp.com-20140103144418-7mstnfwah6v6jkkx --- addons/web_graph/static/src/js/graph.js | 8 ++++++-- addons/web_graph/static/src/js/pivot.js | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 93cac5146ec..e8e4e561ef4 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -344,7 +344,7 @@ instance.web_graph.Graph = instance.web.Widget.extend({ measure_selection: function (event) { event.preventDefault(); var measure = event.target.attributes['data-choice'].nodeValue; - this.pivot.config({measures:[measure]}); + this.pivot.config({toggle_measure:measure}); }, option_selection: function (event) { @@ -421,7 +421,11 @@ instance.web_graph.Graph = instance.web.Widget.extend({ ******************************************************************************/ draw_table: function () { this.pivot.rows.main.title = 'Total'; - this.pivot.cols.main.title = this.title; + if (this.pivot.measures.length == 1) { + this.pivot.cols.main.title = this.measure_label(this.pivot.measures[0]); + } else { + this.pivot.cols.main.title = this.title; + } this.draw_top_headers(); _.each(this.pivot.rows.headers, this.proxy('draw_row')); }, diff --git a/addons/web_graph/static/src/js/pivot.js b/addons/web_graph/static/src/js/pivot.js index 4e1359339dd..e112082e018 100644 --- a/addons/web_graph/static/src/js/pivot.js +++ b/addons/web_graph/static/src/js/pivot.js @@ -51,6 +51,14 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherM this.measures = options.measures; changed = true; } + if (options.toggle_measure) { + if (_.contains(this.measures, options.toggle_measure)) { + this.measures = _.without(this.measures, options.toggle_measure); + } else { + this.measures.push(options.toggle_measure); + } + changed = true; + } if (!_.isEqual(options.col_groupby, this.cols.groupby)) { this.cols.groupby = options.col_groupby; changed = true;