diff options
| author | Randhir Mayatra rma-openerp <rma@tinyerp.com> | 2014-04-07 15:32:40 +0530 |
|---|---|---|
| committer | Randhir Mayatra rma-openerp <rma@tinyerp.com> | 2014-04-07 15:32:40 +0530 |
| commit | c037ebb362cf196edabc07a7e40c85a15a51eb27 (patch) | |
| tree | 8cbd28cdc85d9c3a3fb6d172297d3376d375f0a1 /addons/web_graph/static/src/js | |
| parent | 8c666af35c9c7b79373b999d1df2d4ba350e8f5d (diff) | |
| parent | 7c79674a3ec2ce1e58e8edca889d2175813a4793 (diff) | |
[MERGE] merge with latest trunk
bzr revid: rma@tinyerp.com-20140407100240-vk43kganr5g0gz5i
Diffstat (limited to 'addons/web_graph/static/src/js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph_view.js | 52 | ||||
| -rw-r--r-- | addons/web_graph/static/src/js/graph_widget.js | 23 |
2 files changed, 46 insertions, 29 deletions
diff --git a/addons/web_graph/static/src/js/graph_view.js b/addons/web_graph/static/src/js/graph_view.js index fa39fc581db..25a1f932cc4 100644 --- a/addons/web_graph/static/src/js/graph_view.js +++ b/addons/web_graph/static/src/js/graph_view.js @@ -140,11 +140,20 @@ instance.web_graph.GraphView = instance.web.View.extend({ // add groupby to the search view register_groupby: function(row_groupby, col_groupby) { - var query = this.search_view.query; + var query = this.search_view.query, + groupbys = this.get_groupbys_from_searchview(), + search_row_groupby = groupbys.group_by, + search_col_groupby = groupbys.col_group_by, + row_gb_changed = !_.isEqual(_.pluck(row_groupby, 'field'), search_row_groupby), + col_gb_changed = !_.isEqual(_.pluck(col_groupby, 'field'), search_col_groupby); if (!_.has(this.search_view, '_s_groupby')) { return; } - if (row_groupby.length && col_groupby.length) { + if (!row_gb_changed && !col_gb_changed) { + return; + } + + if (row_gb_changed && col_gb_changed) { // when two changes to the search view will be done, the method do_search // will be called twice, once with the correct groupby and incorrect col_groupby, // and once with correct informations. This flag is necessary to prevent the @@ -152,26 +161,31 @@ instance.web_graph.GraphView = instance.web.View.extend({ this.ignore_do_search = true; } - // add row groupbys - var row_facet = this.make_row_groupby_facets(row_groupby), - row_search_facet = query.findWhere({category:'GroupBy'}); + if (row_gb_changed) { + // add row groupbys + var row_facet = this.make_row_groupby_facets(row_groupby), + row_search_facet = query.findWhere({category:'GroupBy'}); - if (row_search_facet) { - row_search_facet.values.reset(row_facet.values); - } else { - if (row_groupby.length) { - query.add(row_facet); + if (row_search_facet) { + row_search_facet.values.reset(row_facet.values); + } else { + if (row_groupby.length) { + query.add(row_facet); + } } } - // add col groupbys - var col_facet = this.make_col_groupby_facets(col_groupby), - col_search_facet = query.findWhere({category:'ColGroupBy'}); - - if (col_search_facet) { - col_search_facet.values.reset(col_facet.values); - } else { - if (col_groupby.length) { - query.add(col_facet); + + if (col_gb_changed) { + // add col groupbys + var col_facet = this.make_col_groupby_facets(col_groupby), + col_search_facet = query.findWhere({category:'ColGroupBy'}); + + if (col_search_facet) { + col_search_facet.values.reset(col_facet.values); + } else { + if (col_groupby.length) { + query.add(col_facet); + } } } }, diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index b4f06aee3f1..3d8d8fa2d98 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -38,6 +38,9 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ if (this.mode !== 'pivot') { this.$('.graph_heatmap label').addClass('disabled'); + this.$('.graph_main_content').addClass('graph_chart_mode'); + } else { + this.$('.graph_main_content').addClass('graph_pivot_mode'); } openerp.session.rpc('/web_graph/check_xlwt').then(function (result) { @@ -171,10 +174,10 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ if (mode === 'pivot') { this.$('.graph_heatmap label').removeClass('disabled'); - this.$('.graph_main_content').css('position', 'inherit') + this.$('.graph_main_content').removeClass('graph_chart_mode').addClass('graph_pivot_mode'); } else { this.$('.graph_heatmap label').addClass('disabled'); - this.$('.graph_main_content').css('position', 'relative') + this.$('.graph_main_content').removeClass('graph_pivot_mode').addClass('graph_chart_mode'); } this.display_data(); }, @@ -378,11 +381,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Convert Pivot data structure into table structure : // compute rows, cols, colors, cell width, cell height, ... // ---------------------------------------------------------------------- - build_table: function() { + build_table: function(raw) { return { headers: this.build_headers(), measure_row: this.build_measure_row(), - rows: this.build_rows(), + rows: this.build_rows(raw), nbr_measures: this.pivot.measures.length, title: this.title, }; @@ -432,8 +435,8 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return result; }, - make_cell: function (row, col, value, index) { - var formatted_value = openerp.web.format_value(value, {type:this.pivot.measures[index].type}), + make_cell: function (row, col, value, index, raw) { + var formatted_value = raw && !_.isUndefined(value) ? value : openerp.web.format_value(value, {type:this.pivot.measures[index].type}), cell = {value:formatted_value}; if (this.heatmap_mode === 'none') { return cell; } @@ -447,7 +450,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return cell; }, - build_rows: function () { + build_rows: function (raw) { var self = this, pivot = this.pivot, m, cell; @@ -457,13 +460,13 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ _.each(pivot.get_cols_leaves(), function (col) { var values = pivot.get_values(row.id,col.id); for (m = 0; m < pivot.measures.length; m++) { - cells.push(self.make_cell(row,col,values[m], m)); + cells.push(self.make_cell(row,col,values[m], m, raw)); } }); if (pivot.get_cols_leaves().length > 1) { var totals = pivot.get_total(row); for (m = 0; m < pivot.measures.length; m++) { - cell = self.make_cell(row, pivot.main_col(), totals[m], m); + cell = self.make_cell(row, pivot.main_col(), totals[m], m, raw); cell.is_bold = 'true'; cells.push(cell); } @@ -740,7 +743,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ openerp.web.blockUI(); this.session.get_file({ url: '/web_graph/export_xls', - data: {data: JSON.stringify(this.build_table())}, + data: {data: JSON.stringify(this.build_table(true))}, complete: openerp.web.unblockUI, error: c.rpc_error.bind(c) }); |
