summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js/graph_widget.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2014-10-14 11:02:11 +0200
committerGéry Debongnie <ged@odoo.com>2014-10-21 09:33:52 +0200
commitef636ed520852357241862b9e6ece7bb32c9e676 (patch)
tree86768c94b83922960c303dd5999851ff5dd87bb2 /addons/web_graph/static/src/js/graph_widget.js
parent307c687997f298a9acc21cc515f3874e38c9f85d (diff)
[FIX] various small UI tweaks
Diffstat (limited to 'addons/web_graph/static/src/js/graph_widget.js')
-rw-r--r--addons/web_graph/static/src/js/graph_widget.js53
1 files changed, 12 insertions, 41 deletions
diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js
index ffdcd4c62cd..3731d301b2b 100644
--- a/addons/web_graph/static/src/js/graph_widget.js
+++ b/addons/web_graph/static/src/js/graph_widget.js
@@ -20,7 +20,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
this.model = model;
this.domain = domain;
this.mode = options.mode || 'pivot'; // pivot, bar, pie, line
- this.heatmap_mode = options.heatmap_mode || 'none';
this.visible_ui = options.visible_ui || true;
this.bar_ui = options.bar_ui || 'group';
this.graph_view = options.graph_view || null;
@@ -34,27 +33,28 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
this.table = $('<table>');
this.$('.graph_main_content').append(this.table);
- var $pivot_button = this.$buttons.find('.oe-pivot-mode');
- $pivot_button.click(function () {
+ this.$buttons.find('.oe-pivot-mode').click(function () {
self.set_mode.bind(self)('pivot');
});
this.$measure_list = this.$buttons.find('.oe-measure-list');
- var $barchart_button = this.$buttons.find('.oe-bar-mode');
- $barchart_button.click(function () {
+ this.$buttons.find('.oe-bar-mode').click(function () {
self.set_mode.bind(self)('bar');
});
- var $line_chart_button = this.$buttons.find('.oe-line-mode');
- $line_chart_button.click(function () {
+ this.$buttons.find('.oe-line-mode').click(function () {
self.set_mode.bind(self)('line');
});
- var $pie_chart_button = this.$buttons.find('.oe-pie-mode');
- $pie_chart_button.click(function () {
+ this.$buttons.find('.oe-pie-mode').click(function () {
self.set_mode.bind(self)('pie');
});
+ this.$buttons.find('.fa-expand').click(this.swap_axis.bind(this));
+ this.$buttons.find('.fa-arrows-alt').click(function () {
+ self.pivot.expand_all().then(self.proxy('display_data'));
+ });
+ this.$buttons.find('.fa-download').click(this.export_xls.bind(this));
var indexes = {'pivot': 0, 'bar': 1, 'line': 2, 'chart': 3};
- this.$('.graph_mode_selection label').eq(indexes[this.mode]).addClass('active');
+ this.$('.graph_mode_selection label').eq(indexes[this.mode]).addClass('selected');
if (this.mode !== 'pivot') {
this.$('.graph_heatmap label').addClass('disabled');
@@ -233,15 +233,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
this.display_data();
},
- set_heatmap_mode: function (mode) { // none, row, col, all
- this.heatmap_mode = mode;
- if (mode === 'none') {
- this.$('.graph_heatmap label').removeClass('disabled');
- this.$('.graph_heatmap label').removeClass('active');
- }
- this.display_data();
- },
-
create_field_value: function (f) {
var field = (_.contains(f, ':')) ? f.split(':')[0] : f,
groupby_field = _.findWhere(this.groupby_fields, {field:field}),
@@ -303,10 +294,10 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
put_measure_checkmarks: function () {
var self = this,
measures_li = this.$measure_list.find('li');
- measures_li.removeClass('active');
+ measures_li.removeClass('selected');
_.each(this.measure_list, function (measure, index) {
if (_.findWhere(self.pivot.measures, measure)) {
- measures_li.eq(index).addClass('active');
+ measures_li.eq(index).addClass('selected');
}
});
@@ -330,17 +321,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
}
},
- heatmap_mode_selection: function (event) {
- event.preventDefault();
- var mode = event.currentTarget.getAttribute('data-mode');
- if (this.heatmap_mode === mode) {
- event.stopPropagation();
- this.set_heatmap_mode('none');
- } else {
- this.set_heatmap_mode(mode);
- }
- },
-
header_cell_clicked: function (event) {
event.preventDefault();
event.stopPropagation();
@@ -518,14 +498,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
var formatted_value = raw && !_.isUndefined(value) ? value : openerp.web.format_value(value, {type:this.pivot.measures[index].type}),
cell = {value:formatted_value};
- if (this.heatmap_mode === 'none') { return cell; }
- var total = (this.heatmap_mode === 'both') ? this.pivot.get_total()[index]
- : (this.heatmap_mode === 'row') ? this.pivot.get_total(row)[index]
- : this.pivot.get_total(col)[index];
- var color = Math.floor(90 + 165*(total - Math.abs(value))/total);
- if (color < 255) {
- cell.color = color;
- }
return cell;
},
@@ -591,7 +563,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
this.$('.graph_main_content svg').remove();
this.$('.graph_main_content div').remove();
this.table.empty();
- this.table.toggleClass('heatmap', this.heatmap_mode !== 'none');
this.$('.graph_options_selection label').last().toggleClass('disabled', this.pivot.no_data);
this.width = this.$el.width();
this.height = Math.min(Math.max(document.documentElement.clientHeight - 116 - 60, 250), Math.round(0.8*this.$el.width()));