From b34a2307cd60d857d4bcbf8cec053cf6748a8dc0 Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Mon, 18 Nov 2013 14:07:56 +0100 Subject: [PATCH] [REF] moves the loading data code from start to draw function, in widget pivottable (addon web_graph) bzr revid: ged@openerp.com-20131118130756-rx6wqcejn92j5sl4 --- addons/web_graph/static/src/js/graph.js | 45 +++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 558e101c921..a1a9ef68429 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -117,7 +117,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ this.data.domain = new instance.web.CompoundDomain(domain); if (this.pivot_table) { - this.pivot_table.draw(); + this.pivot_table.draw(true); } else { this.pivot_table = new PivotTable(this.data); this.pivot_table.appendTo('.graph_main_content'); @@ -133,7 +133,6 @@ instance.web_graph.GraphView = instance.web.View.extend({ }); - /** * PivotTable widget. It displays the data in tabular data and allows the * user to drill down and up in the table @@ -186,35 +185,39 @@ var PivotTable = instance.web.Widget.extend({ this.expand_row(row_id, field_id); }, }, - + init: function (data) { this.data = data; }, start: function () { - var self = this; - this.get_groups(this.data.row_groupby) - .then(function (groups) { - self.data.groups = groups; - return self.get_groups([]); - }).then(function (total) { - self.data.total = total; - self.build_table(); - self.draw(); - }); + this.draw(true); }, - draw: function () { + draw: function (load_data) { var self = this; - this.$el.empty(); - _.each(this.headers, function (header) { - self.$el.append(header); - }); + if (load_data === true) { + this.get_groups(this.data.row_groupby) + .then(function (groups) { + self.data.groups = groups; + return self.get_groups([]); + }).then(function (total) { + self.data.total = total; + self.build_table(); + self.draw(false); + }); + } else { + this.$el.empty(); - _.each(this.rows, function (row) { - self.$el.append(row.html); - }); + _.each(this.headers, function (header) { + self.$el.append(header); + }); + + _.each(this.rows, function (row) { + self.$el.append(row.html); + }); + } }, show: function () {