[FIX] fixes some issues with the col_group_bys in searchbar (main problem was that do_search is called twice when the user swap axis) (addon web_graph)

bzr revid: ged@openerp.com-20140116095549-3f2hbyzj32nuj147
This commit is contained in:
Gery Debongnie 2014-01-16 10:55:49 +01:00
parent 74d6e75007
commit 588e541387
3 changed files with 16 additions and 4 deletions

View File

@ -78,17 +78,23 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.graph_widget = new openerp.web_graph.Graph(this, this.model, domain, this.widget_config);
this.graph_widget.appendTo(this.$el);
this.graph_widget.on('groupby_changed', this, this.proxy('register_groupby'));
this.graph_widget.on('groupby_swapped', this, this.proxy('swap_groupby'));
this.ViewManager.on('switch_mode', this, function (e) { if (e === 'graph') this.graph_widget.reload(); });
return;
}
if (this.swapped) {
this.swapped = false;
return;
}
this.graph_widget.set(domain, group_by, col_group_by);
},
get_col_groupbys_from_searchview: function () {
var facet = this.search_view.query.findWhere({category:'ColGroupBy'}),
groupby_list = facet ? facet.attributes.values : [];
return _.map(groupby_list, function (g) { return g.value.attrs.context.col_group_by; });
groupby_list = facet ? facet.values.models : [];
return _.map(groupby_list, function (g) { return g.attributes.value.attrs.context.col_group_by; });
},
do_show: function () {
@ -132,6 +138,11 @@ instance.web_graph.GraphView = instance.web.View.extend({
}
},
swap_groupby: function () {
this.swap = true;
this.register_groupby();
},
make_row_groupby_facets: function(groupbys) {
return {
category:'GroupBy',

View File

@ -41,6 +41,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend(openerp.EventDispatcherMixin
self.pivot = new openerp.web_graph.PivotTable(self.model, self.domain, self.fields, self.pivot_options);
self.pivot.on('redraw_required', self, self.proxy('display_data'));
self.pivot.on('groupby_changed', self, function () { self.trigger('groupby_changed'); });
self.pivot.on('groupby_swapped', self, function () { self.trigger('groupby_swapped'); });
openerp.web.bus.on('click', self, function () {
if (self.dropdown) {
self.dropdown.remove();

View File

@ -4,7 +4,7 @@
(function () {
'use strict';
// Pivot Table emits the events 'groupby_changed' and 'redraw_required' when necessary.
// Pivot Table emits the events 'groupby_changed', 'groupby_swapped' and 'redraw_required' when necessary.
// PivotTable is initialized by default 'inactive', and require a call to activate()
// after init to load initial data and start triggering events.
openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherMixin, {
@ -318,7 +318,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherM
var temp = this.rows;
this.rows = this.cols;
this.cols = temp;
this.trigger('groupby_changed');
this.trigger('groupby_swapped');
this.trigger('redraw_required');
},