summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js
diff options
context:
space:
mode:
authorGery Debongnie <ged@openerp.com>2014-03-19 11:15:09 +0100
committerGery Debongnie <ged@openerp.com>2014-03-19 11:15:09 +0100
commitc0a51ebc3448136e6e2371f981cc56f5cc5c52ef (patch)
treed2c10d0311cccfc7e4c0fa0d8fa8c6618b477075 /addons/web_graph/static/src/js
parent36f2ff879a8726a86c7bab87ceec4657dbbf93b6 (diff)
parenta2f9619e267a45d0959e7a942ba4e520d91fbb94 (diff)
[MERGE] merge from trunk
bzr revid: ged@openerp.com-20140319101509-txjzkcgk7cs4x4rz
Diffstat (limited to 'addons/web_graph/static/src/js')
-rw-r--r--addons/web_graph/static/src/js/graph_view.js52
-rw-r--r--addons/web_graph/static/src/js/graph_widget.js7
2 files changed, 38 insertions, 21 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..3f6acdf87a7 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();
},