[IMP] makes sure that the graph view does not reload data if the user removes a measure. Also, display the 'no data' screen if there are no current measure in graph view (addon web_graph)

bzr revid: ged@openerp.com-20140117102339-99kka9v6wfsgesdn
This commit is contained in:
Gery Debongnie 2014-01-17 11:23:39 +01:00
parent c374766f9d
commit 6839fcaddd
2 changed files with 20 additions and 5 deletions

View File

@ -61,16 +61,25 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherM
toggle_measure: function (field_id) {
var current_measure = _.findWhere(this.measures, {field:field_id});
if (current_measure) {
if (current_measure) { // remove current_measure
var index = this.measures.indexOf(current_measure);
this.measures = _.without(this.measures, current_measure);
} else {
if (this.measures.length === 0) {
this.nodata = true;
} else {
_.each(this.cells, function (cell) {
cell.values.splice(index, 1);
});
}
if (this.active) { this.trigger('redraw_required'); }
} else { // add a new measure
this.measures.push({
field: field_id,
type: this.fields[field_id].type,
string: this.fields[field_id].string
});
if (this.active) { this.update_data(); }
}
if (this.active) { this.update_data(); }
},
set: function (domain, row_groupby, col_groupby) {
@ -401,6 +410,12 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend(openerp.EventDispatcherM
rows = this.rows.groupby,
visible_fields = rows.concat(cols, self.measures);
if (this.measures.length === 0) {
var result = $.Deferred();
result.resolve()
return result;
}
var groupbys = _.map(_.range(cols.length + 1), function (i) {
return cols.slice(0, i).concat(rows);
});

View File

@ -102,8 +102,8 @@
<div class="oe_empty_custom_dashboard">
<p><b>No data to display.</b></p>
<p>
No data are available. Try to add some records, or make sure
that there is no active filter in the search bar.
No data available for this graph. Try to add some records, or make sure
that there is at least one measure and no active filter in the search bar.
</p>
</div>
</div>