[FIX] correct fix for the scrolling problem in graph view: the view now saves its scrolling position before redrawing itself (addon web_graph)
bzr revid: ged@openerp.com-20140422150316-m51u750732re8qib
This commit is contained in:
parent
8c001acda0
commit
f584b030bc
|
@ -29,8 +29,8 @@ my.Facet = B.Model.extend({
|
||||||
B.Model.prototype.initialize.apply(this, arguments);
|
B.Model.prototype.initialize.apply(this, arguments);
|
||||||
|
|
||||||
this.values = new my.FacetValues(values || []);
|
this.values = new my.FacetValues(values || []);
|
||||||
this.values.on('add remove change reset', function () {
|
this.values.on('add remove change reset', function (_, options) {
|
||||||
this.trigger('change', this);
|
this.trigger('change', this, options);
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
get: function (key) {
|
get: function (key) {
|
||||||
|
@ -399,7 +399,8 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
this.setup_global_completion();
|
this.setup_global_completion();
|
||||||
this.query = new my.SearchQuery()
|
this.query = new my.SearchQuery()
|
||||||
.on('add change reset remove', this.proxy('do_search'))
|
.on('add change reset remove', this.proxy('do_search'))
|
||||||
.on('add change reset remove', this.proxy('renderFacets'));
|
.on('change', this.proxy('renderChangedFacets'))
|
||||||
|
.on('add reset remove', this.proxy('renderFacets'));
|
||||||
|
|
||||||
if (this.options.hidden) {
|
if (this.options.hidden) {
|
||||||
this.$el.hide();
|
this.$el.hide();
|
||||||
|
@ -578,14 +579,20 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
.trigger('blur');
|
.trigger('blur');
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
*
|
* Call the renderFacets method with the correct arguments.
|
||||||
* @param {openerp.web.search.SearchQuery | openerp.web.search.Facet} _1
|
* This is due to the fact that change events are called with two arguments
|
||||||
* @param {openerp.web.search.Facet} [_2]
|
* (model, options) while add, reset and remove events are called with
|
||||||
|
* (collection, model, options) as arguments
|
||||||
|
*/
|
||||||
|
renderChangedFacets: function (model, options) {
|
||||||
|
this.renderFacets(undefined, model, options);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {openerp.web.search.SearchQuery | undefined} Undefined if event is change
|
||||||
|
* @param {openerp.web.search.Facet}
|
||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
*/
|
*/
|
||||||
renderFacets: function (_1, _2, options) {
|
renderFacets: function (collection, model, options) {
|
||||||
// _1: model if event=change, otherwise collection
|
|
||||||
// _2: undefined if event=change, otherwise model
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var started = [];
|
var started = [];
|
||||||
var $e = this.$('div.oe_searchview_facets');
|
var $e = this.$('div.oe_searchview_facets');
|
||||||
|
@ -610,6 +617,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
});
|
});
|
||||||
|
|
||||||
$.when.apply(null, started).then(function () {
|
$.when.apply(null, started).then(function () {
|
||||||
|
if (options && options.focus_input === false) return;
|
||||||
var input_to_focus;
|
var input_to_focus;
|
||||||
// options.at: facet inserted at given index, focus next input
|
// options.at: facet inserted at given index, focus next input
|
||||||
// otherwise just focus last input
|
// otherwise just focus last input
|
||||||
|
@ -618,7 +626,6 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
} else {
|
} else {
|
||||||
input_to_focus = self.input_subviews[(options.at + 1) * 2];
|
input_to_focus = self.input_subviews[(options.at + 1) * 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
input_to_focus.$el.focus();
|
input_to_focus.$el.focus();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -167,7 +167,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
||||||
row_search_facet = query.findWhere({category:'GroupBy'});
|
row_search_facet = query.findWhere({category:'GroupBy'});
|
||||||
|
|
||||||
if (row_search_facet) {
|
if (row_search_facet) {
|
||||||
row_search_facet.values.reset(row_facet.values);
|
row_search_facet.values.reset(row_facet.values, {focus_input:false});
|
||||||
} else {
|
} else {
|
||||||
if (row_groupby.length) {
|
if (row_groupby.length) {
|
||||||
query.add(row_facet);
|
query.add(row_facet);
|
||||||
|
@ -181,7 +181,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
|
||||||
col_search_facet = query.findWhere({category:'ColGroupBy'});
|
col_search_facet = query.findWhere({category:'ColGroupBy'});
|
||||||
|
|
||||||
if (col_search_facet) {
|
if (col_search_facet) {
|
||||||
col_search_facet.values.reset(col_facet.values);
|
col_search_facet.values.reset(col_facet.values, {focus_input:false});
|
||||||
} else {
|
} else {
|
||||||
if (col_groupby.length) {
|
if (col_groupby.length) {
|
||||||
query.add(col_facet);
|
query.add(col_facet);
|
||||||
|
|
|
@ -26,8 +26,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
|
||||||
this.graph_view = options.graph_view || null;
|
this.graph_view = options.graph_view || null;
|
||||||
this.pivot_options = options;
|
this.pivot_options = options;
|
||||||
this.title = options.title || 'Data';
|
this.title = options.title || 'Data';
|
||||||
|
|
||||||
this.scroll = 0;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function() {
|
start: function() {
|
||||||
|
@ -356,7 +354,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
|
||||||
groupby = groupby || header.root.groupby[header.path.length];
|
groupby = groupby || header.root.groupby[header.path.length];
|
||||||
|
|
||||||
this.pivot.expand(header_id, groupby).then(function () {
|
this.pivot.expand(header_id, groupby).then(function () {
|
||||||
self.scroll = $(window).scrollTop();
|
|
||||||
if (update_groupby && self.graph_view) {
|
if (update_groupby && self.graph_view) {
|
||||||
self.graph_view.register_groupby(self.pivot.rows.groupby, self.pivot.cols.groupby);
|
self.graph_view.register_groupby(self.pivot.rows.groupby, self.pivot.cols.groupby);
|
||||||
}
|
}
|
||||||
|
@ -501,6 +498,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
|
||||||
// Main display method
|
// Main display method
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
display_data: function () {
|
display_data: function () {
|
||||||
|
var scroll = $(window).scrollTop();
|
||||||
this.$('.graph_main_content svg').remove();
|
this.$('.graph_main_content svg').remove();
|
||||||
this.$('.graph_main_content div').remove();
|
this.$('.graph_main_content div').remove();
|
||||||
this.table.empty();
|
this.table.empty();
|
||||||
|
@ -515,7 +513,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
|
||||||
} else {
|
} else {
|
||||||
if (this.mode === 'pivot') {
|
if (this.mode === 'pivot') {
|
||||||
this.draw_table();
|
this.draw_table();
|
||||||
$(window).scrollTop(this.scroll);
|
$(window).scrollTop(scroll);
|
||||||
} else {
|
} else {
|
||||||
this.$('.graph_main_content').append($('<div><svg>'));
|
this.$('.graph_main_content').append($('<div><svg>'));
|
||||||
this.svg = this.$('.graph_main_content svg')[0];
|
this.svg = this.$('.graph_main_content svg')[0];
|
||||||
|
|
Loading…
Reference in New Issue