[REF] small code cleanups... removing old commented code, and small tweaks (addon web_graph)

bzr revid: ged@openerp.com-20131127092052-n2ub66oczqrtmr33
This commit is contained in:
Gery Debongnie 2013-11-27 10:20:52 +01:00
parent 0b5ff7efff
commit 1f8b8165e8
3 changed files with 21 additions and 38 deletions

View File

@ -33,7 +33,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
'click .graph_expand_selection li' : function (event) {
event.preventDefault();
switch (event.target.attributes['data-choice'].nodeValue) {
case 'fold_columns':
case 'fold_columns':
this.pivot_table.fold_cols();
this.draw_table();
break;
@ -54,7 +54,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
'click .graph_options_selection li' : function (event) {
event.preventDefault();
switch (event.target.attributes['data-choice'].nodeValue) {
case 'swap_axis':
case 'swap_axis':
this.pivot_table.swap_axis();
this.draw_table();
break;
@ -81,12 +81,6 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.pivot_table.expand(id, field_id)
.then(this.proxy('draw_table'));
},
'click label.graph_heat_map' : function (event) {
this.heat_map_mode = !this.heat_map_mode;
this.draw_table();
},
},
view_loading: function (fields_view_get) {
@ -96,7 +90,6 @@ instance.web_graph.GraphView = instance.web.View.extend({
measure = null,
fields,
important_fields = [],
col_groupby = [],
row_groupby = [];
this.pivot_table = null;
@ -214,9 +207,9 @@ instance.web_graph.GraphView = instance.web.View.extend({
var field = header.root.groupby[header.path.length];
pivot.expand(id, field).then(this.proxy('draw_table'));
} else {
this.display_dropdown({id:header.id,
target: $(options.event.target),
x: options.event.pageX,
this.display_dropdown({id:header.id,
target: $(options.event.target),
x: options.event.pageX,
y: options.event.pageY});
}
}
@ -306,7 +299,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
}
_.each(header_cells, function (cells) {
self.table.append($("<tr></tr>").append(cells));
self.table.append($('<tr></tr>').append(cells));
});
},
@ -330,15 +323,13 @@ instance.web_graph.GraphView = instance.web.View.extend({
cell = $('<td></td>');
cell.append((value === undefined) ? '' : value);
console.log("self.mode",self.mode);
if ((self.mode == 'heatmap') && (value !== undefined)) {
console.log("yop");
var color = Math.floor(50 + 205*(pivot.total - value)/pivot.total);
cell.css("background-color", "rgb(255," + color + "," + color + ")");
cell.css('background-color', 'rgb(255,' + color + ',' + color + ')');
}
if (row.is_expanded && (row.path.length <= 2)) {
var color = row.path.length * 5 + 240;
cell.css("background-color", "rgb(" + [color, color, color].join() + ")");
cell.css('background-color', 'rgb(' + [color, color, color].join() + ')');
}
html_row.append(cell);
}
@ -349,10 +340,10 @@ instance.web_graph.GraphView = instance.web.View.extend({
.css('font-weight', 'bold');
if (row.is_expanded && (row.path.length <= 2)) {
var color = row.path.length * 5 + 240;
cell.css("background-color", "rgb(" + [color, color, color].join() + ")");
cell.css('background-color', 'rgb(' + [color, color, color].join() + ')');
} else if (self.heat_map_mode) {
var color = Math.floor(50 + 205*(pivot.total - total)/pivot.total);
cell.css("background-color", "rgb(255," + color + "," + color + ")");
cell.css('background-color', 'rgb(255,' + color + ',' + color + ')');
}
if (pivot.cols.main.children.length > 0) {

View File

@ -11,7 +11,7 @@ var PivotTable = openerp.web.Class.extend({
parent: null,
children: [],
domain: options.domain,
};
};
main_col = {
id: this.generate_id(),
path: [],
@ -19,7 +19,7 @@ var PivotTable = openerp.web.Class.extend({
is_expanded: false,
parent: null,
children: [],
domain: options.domain,
domain: options.domain,
};
this.rows = {
@ -93,7 +93,7 @@ var PivotTable = openerp.web.Class.extend({
get_header: function (id) {
return _.find(this.rows.headers.concat(this.cols.headers), function (header) {
return header.id == id;
});
});
},
fold: function (header) {
@ -108,7 +108,7 @@ var PivotTable = openerp.web.Class.extend({
header.root.headers = _.difference(header.root.headers, _.rest(list));
header.is_expanded = false;
var fold_lvls = _.map(header.root.headers, function(g) {return g.path.length;});
var new_groupby_length = _.max(fold_lvls);
var new_groupby_length = _.max(fold_lvls);
header.root.groupby.splice(new_groupby_length);
header.children = [];
this.cells = _.reject(this.cells, function (cell) {
@ -118,7 +118,7 @@ var PivotTable = openerp.web.Class.extend({
expand: function (row_id, field_id) {
var self = this,
row = this.get_header(row_id);
row = this.get_header(row_id);
if (row.path.length == row.root.groupby.length) {
row.root.groupby.push(field_id);
@ -158,7 +158,7 @@ var PivotTable = openerp.web.Class.extend({
domain: groups[0].model._domain,
root: parent.root,
};
parent.children.splice(0,0, new_header)
parent.children.splice(0,0, new_header);
insertAfter(parent.root.headers, parent, new_header);
return new_header.id;
},
@ -199,11 +199,11 @@ var PivotTable = openerp.web.Class.extend({
self.cols.main.title = self.measure_label;
_.each(self.rows.headers, function (row) {
row.root = self.rows;
row.is_expanded = (row.children.length > 0)
row.is_expanded = (row.children.length > 0);
});
_.each(self.cols.headers, function (col) {
col.root = self.cols;
col.is_expanded = (col.children.length > 0)
col.is_expanded = (col.children.length > 0);
});
});
@ -227,7 +227,7 @@ var PivotTable = openerp.web.Class.extend({
corresponding_col.is_expanded = true;
_.each(corresponding_col.children, function (c) {
c.is_expanded = false;
})
});
} else {
corresponding_col.is_expanded = false;
}
@ -257,7 +257,7 @@ var PivotTable = openerp.web.Class.extend({
corresponding_row.is_expanded = true;
_.each(corresponding_row.children, function (c) {
c.is_expanded = false;
})
});
} else {
corresponding_row.is_expanded = false;
}
@ -275,7 +275,6 @@ var PivotTable = openerp.web.Class.extend({
});
self.rows.main = self.rows.headers[0];
// now some more tweaks
self.total = self.rows.main.total;
_.each(self.rows.headers, function (row) {

View File

@ -35,14 +35,7 @@
<li role="presentation" class="divider"></li>
<li><a data-choice="expand_all" href="#">Expand All</a></li>
</ul>
<!-- <label type="button" class="btn btn-default graph_swap_axis">Swap Axis</label>
<label type="button" class="btn btn-default graph_fold_rows">Fold Rows</label>
<label type="button" class="btn btn-default graph_fold_cols">Fold Cols</label>
<label type="button" class="btn btn-default graph_fold_all">Fold All</label>
<label type="button" class="btn btn-default graph_heat_map">Heat Map</label>
<label type="button" class="btn btn-default graph_expand_all">Expand All</label>
<label type="button" class="btn btn-default graph_update_values">Update Values</label>
--> </div>
</div>
<div class="btn-group">
<label type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
Options <span class="caret"></span>