diff options
| author | Christophe Simonis <chs@odoo.com> | 2014-09-05 15:28:22 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2014-09-05 15:28:22 +0200 |
| commit | 31bf30d2d0eb78baaa36360b99fe58bf7cd4c9e7 (patch) | |
| tree | d7be61ecd6bb4c8b5552e39b03e2a64eebbbf323 /addons/web_graph/static/src/js/graph_widget.js | |
| parent | afba9e8817c458640ae446ac7aaaab79be4fe1e9 (diff) | |
| parent | ed1c173971968eaa96693cb4e1547efa6e6c34e0 (diff) | |
[MERGE] forward port of branch 8.0 up to ed1c173
Diffstat (limited to 'addons/web_graph/static/src/js/graph_widget.js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph_widget.js | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index db33e567b42..f0e07e06e6a 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -153,41 +153,49 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // ---------------------------------------------------------------------- // Configuration methods // ---------------------------------------------------------------------- - set: function (domain, row_groupby, col_groupby) { + set: function (domain, row_groupby, col_groupby, measures_groupby) { if (!this.pivot) { this.pivot_options.domain = domain; this.pivot_options.row_groupby = row_groupby; this.pivot_options.col_groupby = col_groupby; + this.pivot_options.measures_groupby = measures_groupby; return; } var row_gbs = this.create_field_values(row_groupby), col_gbs = this.create_field_values(col_groupby), + measures_gbs = this.create_field_values(measures_groupby), dom_changed = !_.isEqual(this.pivot.domain, domain), row_gb_changed = !_.isEqual(row_gbs, this.pivot.rows.groupby), col_gb_changed = !_.isEqual(col_gbs, this.pivot.cols.groupby), + measures_gb_changed = !_.isEqual(measures_gbs, this.pivot.measures), row_reduced = is_strict_beginning_of(row_gbs, this.pivot.rows.groupby), - col_reduced = is_strict_beginning_of(col_gbs, this.pivot.cols.groupby); + col_reduced = is_strict_beginning_of(col_gbs, this.pivot.cols.groupby), + measures_reduced = is_strict_beginning_of(measures_gbs, this.pivot.measures); - if (!dom_changed && row_reduced && !col_gb_changed) { + if (!dom_changed && row_reduced && !col_gb_changed && !measures_gb_changed) { this.pivot.fold_with_depth(this.pivot.rows, row_gbs.length); this.display_data(); return; } - if (!dom_changed && col_reduced && !row_gb_changed) { + if (!dom_changed && col_reduced && !row_gb_changed && !measures_gb_changed) { this.pivot.fold_with_depth(this.pivot.cols, col_gbs.length); this.display_data(); return; } - if (!dom_changed && col_reduced && row_reduced) { + if (!dom_changed && col_reduced && row_reduced && !measures_gb_changed) { this.pivot.fold_with_depth(this.pivot.rows, row_gbs.length); this.pivot.fold_with_depth(this.pivot.cols, col_gbs.length); this.display_data(); return; } - if (dom_changed || row_gb_changed || col_gb_changed) { - this.pivot.set(domain, row_gbs, col_gbs).then(this.proxy('display_data')); + if (dom_changed || row_gb_changed || col_gb_changed || measures_gb_changed) { + this.pivot.set(domain, row_gbs, col_gbs, measures_gbs).then(this.proxy('display_data')); + } + + if (measures_gb_changed) { + this.put_measure_checkmarks(); } }, @@ -235,6 +243,10 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return _.pluck(this.pivot.cols.groupby, 'field'); }, + get_current_measures: function () { + return _.pluck(this.pivot.measures, 'field'); + }, + // ---------------------------------------------------------------------- // UI code // ---------------------------------------------------------------------- @@ -340,12 +352,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ } this.dropdown = $(QWeb.render('field_selection', {fields:fields, header_id:id})); $(event.target).after(this.dropdown); - this.dropdown.css({position:'absolute', - left:event.originalEvent.layerX, - top:event.originalEvent.layerY}); - this.$('.field-selection').next('.dropdown-menu').first().toggle(); - - + this.dropdown.css({ + position:'absolute', + left:event.originalEvent.layerX, + }); + this.$('.field-selection').next('.dropdown-menu').first().toggle(); }, field_selection: function (event) { @@ -627,7 +638,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ }, draw_measure_row: function (measure_row) { - if (this.pivot.measures.length === 1) { return; } var $row = $('<tr>').append('<th>'); _.each(measure_row, function (cell) { var $cell = $('<th>').addClass('measure_row').text(cell.text); |
