[REF] removes all references to measure label in pivot table (addon web_graph)

bzr revid: ged@openerp.com-20131128084551-19hc23fmw3gvtoc9
This commit is contained in:
Gery Debongnie 2013-11-28 09:45:51 +01:00
parent 51e4b240f8
commit be00aca052
2 changed files with 19 additions and 12 deletions

View File

@ -34,7 +34,8 @@ instance.web_graph.GraphView = instance.web.View.extend({
'click .graph_measure_selection li' : function (event) {
event.preventDefault();
var measure = event.target.attributes['data-choice'].nodeValue;
this.pivot_table.set_measure(measure)
this.measure = (measure === '__count') ? null : measure;
this.pivot_table.set_measure(this.measure)
.then(this.proxy('display_data'));
},
@ -99,6 +100,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.pivot_table = null;
this.heat_map_mode = false;
this.mode = 'pivot';
this.measure = null;
this.measure_list = [];
this.important_fields = [];
},
@ -133,6 +135,9 @@ instance.web_graph.GraphView = instance.web.View.extend({
}
}
});
if (this.measure_list.length > 0) {
this.measure = this.measure_list[0];
}
// get the most important fields (of the model) by looking at the
// groupby filters defined in the search view
@ -161,12 +166,12 @@ instance.web_graph.GraphView = instance.web.View.extend({
return $.when(important_fields_def, field_descr_def)
.then(function () {
self.fields = fields;
self.data = {
model: model,
domain: domain,
fields: fields,
measure: self.measure_list[0],
measure_label: fields[self.measure_list[0]].string,
measure: self.measure,
col_groupby: [],
row_groupby: row_groupby,
groups: [],
@ -261,7 +266,13 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.$('.field-selection').next('.dropdown-menu').toggle();
},
measure_label: function () {
return (this.measure) ? this.fields[this.measure].string : 'Quantity';
},
draw_table: function () {
this.pivot_table.rows.main.title = 'Total';
this.pivot_table.cols.main.title = this.measure_label();
this.draw_top_headers();
_.each(this.pivot_table.rows.headers, this.proxy('draw_row'));
},

View File

@ -12,7 +12,6 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
this.model = options.model;
this.domain = options.domain;
this.measure = options.measure;
this.measure_label = options.measure_label;
this.total = 0;
this.id_seed = 0;
this.no_data = true;
@ -58,7 +57,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
},
set_measure: function (measure) {
this.measure = (measure === '__count') ? null : measure;
this.measure = measure;
return this.update_values();
},
@ -143,9 +142,6 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
var temp = this.rows;
this.rows = this.cols;
this.cols = temp;
this.rows.main.title = 'Total';
this.cols.main.title = this.measure_label;
},
fold_rows: function () {
@ -173,8 +169,8 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
self.rows.main = self.rows.headers[0];
self.cols.main = self.cols.headers[0];
self.total = self.rows.main.total;
self.rows.main.title = 'Total';
self.cols.main.title = self.measure_label;
self.rows.main.title = '';
self.cols.main.title = '';
_.each(self.rows.headers, function (row) {
row.root = self.rows;
row.is_expanded = (row.children.length > 0);
@ -269,8 +265,8 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
col.root = self.cols;
});
self.cells = result.cells;
self.rows.main.title = 'Total';
self.cols.main.title = self.measure_label;
self.rows.main.title = '';
self.cols.main.title = '';
});
},