summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2014-05-01 19:25:08 +0200
committerAntony Lesuisse <al@openerp.com>2014-05-01 19:25:08 +0200
commit5e21a4235d1c1b5b8d10a1f4fef147f84812ce5f (patch)
tree19c3ec192b18549dd37b20da8a5aca8bf859bab9 /addons/web_graph/static/src/js
parent2998bec0e0684fae3e5755e4c86354d8576dba53 (diff)
parentabbe08f76a87be47c78abafa7b0af0064df3a6a4 (diff)
[MERGE] saas-4 up to dle@openerp.com-20140501121915-q88k37nd25ietw8c
bzr revid: al@openerp.com-20140501172508-tjennzht30ktw3nz
Diffstat (limited to 'addons/web_graph/static/src/js')
-rw-r--r--addons/web_graph/static/src/js/graph_view.js4
-rw-r--r--addons/web_graph/static/src/js/graph_widget.js35
-rw-r--r--addons/web_graph/static/src/js/pivot_table.js11
3 files changed, 31 insertions, 19 deletions
diff --git a/addons/web_graph/static/src/js/graph_view.js b/addons/web_graph/static/src/js/graph_view.js
index 25a1f932cc4..e4e074b2e7f 100644
--- a/addons/web_graph/static/src/js/graph_view.js
+++ b/addons/web_graph/static/src/js/graph_view.js
@@ -167,7 +167,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
row_search_facet = query.findWhere({category:'GroupBy'});
if (row_search_facet) {
- row_search_facet.values.reset(row_facet.values);
+ row_search_facet.values.reset(row_facet.values, {focus_input:false});
} else {
if (row_groupby.length) {
query.add(row_facet);
@@ -181,7 +181,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
col_search_facet = query.findWhere({category:'ColGroupBy'});
if (col_search_facet) {
- col_search_facet.values.reset(col_facet.values);
+ col_search_facet.values.reset(col_facet.values, {focus_input:false});
} 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 ce73a0b51c6..9946e149d96 100644
--- a/addons/web_graph/static/src/js/graph_widget.js
+++ b/addons/web_graph/static/src/js/graph_widget.js
@@ -51,7 +51,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
this.search_view = parent.searchview;
openerp.session.rpc('/web_graph/check_xlwt').then(function (result) {
- self.$('.graph_options_selection label').toggle(result);
+ self.$('.graph_options_selection label').last().toggle(result);
});
return this.model.call('fields_get', []).then(function (f) {
@@ -296,11 +296,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
if (header.expanded) {
this.fold(header);
return;
- }
+ }
if (header.path.length < header.root.groupby.length) {
this.expand(id);
return;
- }
+ }
if (!this.important_fields.length) {
return;
}
@@ -499,10 +499,12 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
// Main display method
// ----------------------------------------------------------------------
display_data: function () {
+ var scroll = $(window).scrollTop();
this.$('.graph_main_content svg').remove();
this.$('.graph_main_content div').remove();
this.table.empty();
this.table.toggleClass('heatmap', this.heatmap_mode !== 'none');
+ this.$('.graph_options_selection label').last().toggleClass('disabled', this.pivot.no_data);
this.width = this.$el.width();
this.height = Math.min(Math.max(document.documentElement.clientHeight - 116 - 60, 250), Math.round(0.8*this.$el.width()));
@@ -512,6 +514,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
} else {
if (this.mode === 'pivot') {
this.draw_table();
+ $(window).scrollTop(scroll);
} else {
this.$('.graph_main_content').append($('<div><svg>'));
this.svg = this.$('.graph_main_content svg')[0];
@@ -626,7 +629,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
if ((dim_x === 0) && (dim_y === 0)) {
data = [{key: _t('Total'), values:[{
x: _t('Total'),
- y: this.pivot.get_total(),
+ y: this.pivot.get_total()[0],
}]}];
// Only column groupbys
} else if ((dim_x === 0) && (dim_y >= 1)){
@@ -639,7 +642,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
// Just 1 row groupby
} else if ((dim_x === 1) && (dim_y === 0)) {
data = _.map(this.pivot.main_row().children, function (pt) {
- var value = self.pivot.get_total(pt),
+ var value = self.pivot.get_total(pt)[0],
title = (pt.title !== undefined) ? pt.title : _t('Undefined');
return {x: title, y: value};
});
@@ -676,8 +679,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
nv.addGraph(function () {
var chart = nv.models.multiBarChart()
- .width(self.width)
- .height(self.height)
.reduceXTicks(false)
.stacked(self.bar_ui === 'stack')
.showControls(show_controls);
@@ -705,9 +706,12 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
dim_x = this.pivot.rows.groupby.length,
dim_y = this.pivot.cols.groupby.length;
+ var rows = this.pivot.get_rows_with_depth(dim_x),
+ labels = _.pluck(rows, 'title');
+
var data = _.map(this.pivot.get_cols_leaves(), function (col) {
- var values = _.map(self.pivot.get_rows_with_depth(dim_x), function (row) {
- return {x: row.title, y: self.pivot.get_values(row.id,col.id)[0] || 0};
+ var values = _.map(rows, function (row, index) {
+ return {x: index, y: self.pivot.get_values(row.id,col.id)[0] || 0};
});
var title = _.map(col.path, function (p) {
return p || _t('Undefined');
@@ -720,10 +724,9 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
nv.addGraph(function () {
var chart = nv.models.lineChart()
- .x(function (d,u) { return u; })
- .width(self.width)
- .height(self.height)
- .margin({top: 30, right: 20, bottom: 20, left: 60});
+ .x(function (d,u) { return u; });
+
+ chart.xAxis.tickFormat(function (d,u) {return labels[d];});
d3.select(self.svg)
.attr('width', self.width)
@@ -745,14 +748,14 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
if (dim_x === 0) {
title = self.measure_label;
}
- return {x: title, y: self.pivot.get_total(row)};
+ return {x: title, y: self.pivot.get_total(row)[0]};
});
nv.addGraph(function () {
var chart = nv.models.pieChart()
- .color(d3.scale.category10().range())
.width(self.width)
- .height(self.height);
+ .height(self.height)
+ .color(d3.scale.category10().range());
d3.select(self.svg)
.datum(data)
diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js
index 6b12829982e..48ae9ec3830 100644
--- a/addons/web_graph/static/src/js/pivot_table.js
+++ b/addons/web_graph/static/src/js/pivot_table.js
@@ -14,6 +14,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
this.cells = [];
this.domain = domain;
this.no_data = true;
+ this.updating = false;
this.model = model;
this.fields = fields;
this.fields.__count = {type: 'integer', string:_t('Quantity')};
@@ -55,6 +56,13 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
},
set: function (domain, row_groupby, col_groupby) {
+ var self = this;
+ if (this.updating) {
+ return this.updating.then(function () {
+ self.updating = false;
+ return self.set(domain, row_groupby,col_groupby);
+ });
+ }
var row_gb_changed = !_.isEqual(row_groupby, this.rows.groupby),
col_gb_changed = !_.isEqual(col_groupby, this.cols.groupby);
@@ -251,7 +259,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
// to null before calling update_data.
update_data: function () {
var self = this;
- return this.perform_requests().then (function () {
+ this.updating = this.perform_requests().then (function () {
var data = Array.prototype.slice.call(arguments);
self.no_data = !data[0].length;
if (self.no_data) {
@@ -273,6 +281,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
self.set_headers(row_headers, self.rows);
self.set_headers(col_headers, self.cols);
});
+ return this.updating;
},
make_headers_and_cell: function (data_pts, row_headers, col_headers, index, prefix, expand) {