[REF] many small code cleanups in addon web_graph

bzr revid: ged@openerp.com-20131206160411-9ajcschidssftb49
This commit is contained in:
Gery Debongnie 2013-12-06 17:04:11 +01:00
parent 6a06f0d0ee
commit 5c04caf2ee
2 changed files with 8 additions and 28 deletions

View File

@ -38,7 +38,6 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.set_default_options(options);
this.dropdown = null;
this.mode = 'pivot'; // pivot, bar_chart, line_chart, pie_chart, heatmap, row_heatmap, col_heatmap
this.measure = null;
this.measure_list = [];
this.important_fields = [];
this.search_view = parent.searchview;
@ -125,9 +124,6 @@ instance.web_graph.GraphView = instance.web.View.extend({
if (group_by.length || col_groupby.length) {
this.groupby_mode = 'manual';
// if (!group_by.length) {
// group_by = this.default_row_groupby;
// }
}
this.pivot_table.set_domain(domain);
@ -214,7 +210,6 @@ instance.web_graph.GraphView = instance.web.View.extend({
var mode = event.target.attributes['data-mode'].nodeValue;
this.mode = mode;
this.display_data();
},
register_groupby: function() {
@ -222,7 +217,6 @@ instance.web_graph.GraphView = instance.web.View.extend({
query = this.search_view.query;
this.groupby_mode = 'manual';
var rows = _.map(this.pivot_table.rows.groupby, function (group) {
return make_facet('GroupBy', group);
});
@ -259,8 +253,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
measure_selection: function (event) {
event.preventDefault();
var measure = event.target.attributes['data-choice'].nodeValue;
this.measure = (measure === '__count') ? null : measure;
this.pivot_table.set_measure(this.measure);
this.pivot_table.set_measure((measure === '__count') ? null : measure);
this.display_data();
},
@ -276,7 +269,8 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.register_groupby();
break;
case 'fold_all':
this.pivot_table.fold_all();
this.pivot_table.fold_cols();
this.pivot_table.fold_rows();
this.register_groupby();
break;
case 'expand_all':
@ -287,7 +281,6 @@ instance.web_graph.GraphView = instance.web.View.extend({
},
option_selection: function (event) {
var pivot = this.pivot_table;
event.preventDefault();
switch (event.target.attributes['data-choice'].nodeValue) {
case 'swap_axis':
@ -299,7 +292,6 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.display_data();
break;
case 'export_data':
this.register_groupby();
// Export code... To do...
break;
}
@ -353,7 +345,8 @@ instance.web_graph.GraphView = instance.web.View.extend({
},
measure_label: function () {
return (this.measure) ? this.fields[this.measure].string : 'Quantity';
var pivot = this.pivot_table;
return (pivot.measure) ? this.fields[pivot.measure].string : 'Quantity';
},
make_border_cell: function (colspan, rowspan) {

View File

@ -1,9 +1,6 @@
/* jshint undef: false */
// TO DO : use _.uniqueID()
(function () {
'use strict';
@ -21,11 +18,6 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
this.stale_data = true;
},
generate_id: function () {
this.id_seed += 1;
return this.id_seed;
},
visible_fields: function () {
var result = this.rows.groupby.concat(this.cols.groupby);
if (this.measure) {
@ -159,7 +151,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
make_header: function (groups, parent) {
var name = groups[0].attributes.value[1],
new_header = {
id: this.generate_id(),
id: _.uniqueId(),
path: parent.path.concat(name),
title: name,
is_expanded: false,
@ -187,11 +179,6 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
this.fold(this.cols.main);
},
fold_all: function () {
this.fold_rows();
this.fold_cols();
},
expand_headers: function (root, new_headers) {
root.headers = new_headers;
root.main = new_headers[0];
@ -336,7 +323,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
function make_headers (data, depth) {
var main = {
id: self.generate_id(),
id: _.uniqueId(),
path: [],
parent: null,
children: [],
@ -367,7 +354,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
function make_tree_headers (data_pt, parent, max_depth) {
var node = {
id: self.generate_id(),
id: _.uniqueId(),
path: parent.path.concat(data_pt.attributes.value[1]),
title: data_pt.attributes.value[1],
domain: data_pt.model._domain,