summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js/graph.js
diff options
context:
space:
mode:
authorGery Debongnie <ged@openerp.com>2013-11-27 10:10:53 +0100
committerGery Debongnie <ged@openerp.com>2013-11-27 10:10:53 +0100
commit0b5ff7efff63c791cf0e5d8abe66653973391a16 (patch)
treef3af140eafcc4a3f4db672b867632033838183d0 /addons/web_graph/static/src/js/graph.js
parent8ef078acb323766281f60f40796ae656343b581f (diff)
[IMP] reorganizes all options in graph views (puts them in 4 dropdown menus) (addon web_graph)
bzr revid: ged@openerp.com-20131127091053-ydbo89dj027ndm3o
Diffstat (limited to 'addons/web_graph/static/src/js/graph.js')
-rw-r--r--addons/web_graph/static/src/js/graph.js73
1 files changed, 44 insertions, 29 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js
index 3d218e38eba..9cd2147d9fb 100644
--- a/addons/web_graph/static/src/js/graph.js
+++ b/addons/web_graph/static/src/js/graph.js
@@ -30,6 +30,43 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.switch_mode(mode);
},
+ 'click .graph_expand_selection li' : function (event) {
+ event.preventDefault();
+ switch (event.target.attributes['data-choice'].nodeValue) {
+ case 'fold_columns':
+ this.pivot_table.fold_cols();
+ this.draw_table();
+ break;
+ case 'fold_rows':
+ this.pivot_table.fold_rows();
+ this.draw_table();
+ break;
+ case 'fold_all':
+ this.pivot_table.fold_all();
+ this.draw_table();
+ break;
+ case 'expand_all':
+ this.pivot_table.expand_all().then(this.proxy('draw_table'));
+ break;
+ }
+ },
+
+ 'click .graph_options_selection li' : function (event) {
+ event.preventDefault();
+ switch (event.target.attributes['data-choice'].nodeValue) {
+ case 'swap_axis':
+ this.pivot_table.swap_axis();
+ this.draw_table();
+ break;
+ case 'update_values':
+ this.pivot_table.update_values().then(this.proxy('draw_table'));
+ break;
+ case 'export_data':
+ // Export code... To do...
+ break;
+ }
+ },
+
'click .web_graph_click' : function (event) {
event.preventDefault();
var id = event.target.attributes['data-id'].nodeValue;
@@ -45,38 +82,11 @@ instance.web_graph.GraphView = instance.web.View.extend({
.then(this.proxy('draw_table'));
},
- 'click label.graph_swap_axis' : function (event) {
- this.pivot_table.swap_axis();
- this.draw_table();
- },
-
- '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();
- },
'click label.graph_heat_map' : function (event) {
this.heat_map_mode = !this.heat_map_mode;
this.draw_table();
},
-
- 'click label.graph_expand_all' : function (event) {
- this.pivot_table.expand_all().then(this.proxy('draw_table'));
- },
-
- 'click label.graph_update_values' : function (event) {
- this.pivot_table.update_values().then(this.proxy('draw_table'));
- },
},
view_loading: function (fields_view_get) {
@@ -91,6 +101,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.pivot_table = null;
this.heat_map_mode = false;
+ this.mode = 'pivot';
// get the default groupbys and measure defined in the field view
_.each(fields_view_get.arch.children, function (field) {
@@ -175,7 +186,9 @@ instance.web_graph.GraphView = instance.web.View.extend({
switch_mode: function (mode) {
this.mode = mode;
- if (mode === 'pivot') {
+ var table_modes = ['pivot', 'heatmap', 'row_heatmap', 'col_heatmap'];
+ if (_.contains(table_modes, mode)) {
+ this.draw_table();
this.table.css('display', 'block');
this.svg.css('display','none');
} else {
@@ -317,7 +330,9 @@ instance.web_graph.GraphView = instance.web.View.extend({
cell = $('<td></td>');
cell.append((value === undefined) ? '' : value);
- if ((self.heat_map_mode) && (value !== undefined)) {
+ 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 + ")");
}