diff options
Diffstat (limited to 'addons/web_graph/static/src')
| -rw-r--r-- | addons/web_graph/static/src/js/charts.js | 4 | ||||
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 16 | ||||
| -rw-r--r-- | addons/web_graph/static/src/js/pivot.js | 19 | ||||
| -rw-r--r-- | addons/web_graph/static/src/xml/web_graph.xml | 4 |
4 files changed, 35 insertions, 8 deletions
diff --git a/addons/web_graph/static/src/js/charts.js b/addons/web_graph/static/src/js/charts.js index 036299ebdfd..6944aef9672 100644 --- a/addons/web_graph/static/src/js/charts.js +++ b/addons/web_graph/static/src/js/charts.js @@ -1,4 +1,8 @@ +function draw_chart (svg, mode, pivot) { + Charts[mode](pivot); +} + function format_chart_data (pivot) { var values = _.map(pivot.rows.headers[0].children.reverse(), function (pt) { var val = pivot.get_value(pt.id, 2); diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index cd6cb44f93c..c0ccb80285a 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -63,8 +63,18 @@ instance.web_graph.GraphView = instance.web.View.extend({ this.draw_table(); }, - 'click label.graph_clear_all' : function (event) { - this.pivot_table.clear_all(); + 'click label.graph_fold_all' : function (event) { + this.pivot_table.fold_all(); + this.draw_table(); + }, + + 'click label.graph_fold_rows' : function (event) { + this.pivot_table.fold_rows(); + this.draw_table(); + }, + + 'click label.graph_fold_cols' : function (event) { + this.pivot_table.fold_cols(); this.draw_table(); }, }, @@ -172,7 +182,7 @@ instance.web_graph.GraphView = instance.web.View.extend({ this.svg.remove(); this.svg = $('<div><svg></svg></div>'); this.$el.filter('.graph_main_content').append(this.svg); - Charts[mode](this.pivot_table); + draw_chart(this.svg, mode, this.pivot_table); } }, diff --git a/addons/web_graph/static/src/js/pivot.js b/addons/web_graph/static/src/js/pivot.js index a4f8ad5246a..06b8a97a05d 100644 --- a/addons/web_graph/static/src/js/pivot.js +++ b/addons/web_graph/static/src/js/pivot.js @@ -154,7 +154,7 @@ var PivotTable = openerp.web.Class.extend({ children: [], domain: groups[0].model._domain, }; - parent.children.push(new_header); + parent.children.splice(0,0, new_header) insertAfter(header_list, parent, new_header); return new_header.id; }, @@ -169,7 +169,7 @@ var PivotTable = openerp.web.Class.extend({ return query_groups_data(this.model, this.visible_fields(), col.domain, this.rows.groupby, field_id) .then(function (groups) { - _.each(groups, function (group) { + _.each(groups.reverse(), function (group) { var new_col_id = self.make_header(group, col, self.cols.headers); _.each(group, function (data) { var row = _.find(self.rows.headers, function (c) { @@ -188,6 +188,8 @@ var PivotTable = openerp.web.Class.extend({ var temp = this.rows; this.rows = this.cols; this.cols = temp; + this.rows.main.name = "Total"; + this.cols.main.name = this.measure_label; _.each(this.cells, function (cell) { temp = cell.row_id; @@ -196,10 +198,19 @@ var PivotTable = openerp.web.Class.extend({ }); }, - clear_all: function () { + fold_rows: function () { this.fold_row(this.rows.main); + }, + + fold_cols: function () { this.fold_col(this.cols.main); - } + }, + + fold_all: function () { + this.fold_rows(); + this.fold_cols(); + }, + }); diff --git a/addons/web_graph/static/src/xml/web_graph.xml b/addons/web_graph/static/src/xml/web_graph.xml index fd1929dd81c..bce35d40f9c 100644 --- a/addons/web_graph/static/src/xml/web_graph.xml +++ b/addons/web_graph/static/src/xml/web_graph.xml @@ -13,7 +13,9 @@ <li><a data-mode="pie_chart" href="#">Pie chart</a></li> </ul> <label type="button" class="btn btn-default graph_swap_axis">Swap axis</label> - <label type="button" class="btn btn-default graph_clear_all">Clear all groups</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> </div> </div> <div class="graph_main_content"></div> |
