summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js/pivot_table.js
diff options
context:
space:
mode:
authorGery Debongnie <ged@openerp.com>2014-01-17 11:23:39 +0100
committerGery Debongnie <ged@openerp.com>2014-01-17 11:23:39 +0100
commit6839fcaddd60d82c66626acfeaa7467232f67471 (patch)
treeefc74dd0c625c4a1de37fdd9cc9a40f631845e70 /addons/web_graph/static/src/js/pivot_table.js
parentc374766f9d31d27a6832a0240ba3a9bcb18e7da8 (diff)
[IMP] makes sure that the graph view does not reload data if the user removes a measure. Also, display the 'no data' screen if there are no current measure in graph view (addon web_graph)
bzr revid: ged@openerp.com-20140117102339-99kka9v6wfsgesdn
Diffstat (limited to 'addons/web_graph/static/src/js/pivot_table.js')
-rw-r--r--addons/web_graph/static/src/js/pivot_table.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js
index d7a836d98b8..61a6587e0a2 100644
--- a/addons/web_graph/static/src/js/pivot_table.js
+++ b/addons/web_graph/static/src/js/pivot_table.js
@@ -61,16 +61,25 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherM
toggle_measure: function (field_id) {
var current_measure = _.findWhere(this.measures, {field:field_id});
- if (current_measure) {
+ if (current_measure) { // remove current_measure
+ var index = this.measures.indexOf(current_measure);
this.measures = _.without(this.measures, current_measure);
- } else {
+ if (this.measures.length === 0) {
+ this.nodata = true;
+ } else {
+ _.each(this.cells, function (cell) {
+ cell.values.splice(index, 1);
+ });
+ }
+ if (this.active) { this.trigger('redraw_required'); }
+ } else { // add a new measure
this.measures.push({
field: field_id,
type: this.fields[field_id].type,
string: this.fields[field_id].string
});
+ if (this.active) { this.update_data(); }
}
- if (this.active) { this.update_data(); }
},
set: function (domain, row_groupby, col_groupby) {
@@ -401,6 +410,12 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherM
rows = this.rows.groupby,
visible_fields = rows.concat(cols, self.measures);
+ if (this.measures.length === 0) {
+ var result = $.Deferred();
+ result.resolve()
+ return result;
+ }
+
var groupbys = _.map(_.range(cols.length + 1), function (i) {
return cols.slice(0, i).concat(rows);
});