diff options
| author | Aaron Bohy <aab@odoo.com> | 2016-04-21 13:58:22 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2016-04-21 15:21:42 +0200 |
| commit | 6768bbfcc02e0f498110cda2ba9adbc2fd23d24c (patch) | |
| tree | 7dccb1019434582874b285276189b1b3dcbb96a9 /addons/web/static/src/js/views/graph_view.js | |
| parent | e1bfd3fbda97ac7a64a585b07be161d5be606cf9 (diff) | |
| parent | 8e440b173e3b273b3aac541f2ec12527f67dfa60 (diff) | |
[MERGE] *: stop duplicating web
Avoid duplicating web addon in enterprise by extracting a common basis.
Enterprise features stay in enterprise, but use that common basis.
In web, mainly:
- JS refactoring and linting
- Conversion of .sass into .less split into multiple files
- Templates cleaning and DOM simplification
- Re-generation of web.pot, and update of .po files
Minor tweaks in some other addons to make them work with this new structure.
Diffstat (limited to 'addons/web/static/src/js/views/graph_view.js')
| -rw-r--r-- | addons/web/static/src/js/views/graph_view.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/addons/web/static/src/js/views/graph_view.js b/addons/web/static/src/js/views/graph_view.js index 62ee1e62c23..c8ff16cd0f1 100644 --- a/addons/web/static/src/js/views/graph_view.js +++ b/addons/web/static/src/js/views/graph_view.js @@ -14,7 +14,7 @@ var _t = core._t; var QWeb = core.qweb; var GraphView = View.extend({ - className: 'oe_graph', + className: 'o_graph', display_name: _lt('Graph'), icon: 'fa-bar-chart', require_fields: true, @@ -54,12 +54,14 @@ var GraphView = View.extend({ if ($node) { var context = {measures: _.pairs(_.omit(this.measures, '__count__'))}; this.$buttons = $(QWeb.render('GraphView.buttons', context)); - this.$measure_list = this.$buttons.find('.oe-measure-list'); + this.$measure_list = this.$buttons.find('.o_graph_measures_list'); this.update_measure(); this.$buttons.find('button').tooltip(); this.$buttons.click(this.on_button_click.bind(this)); - this.$buttons.appendTo($node); + this.$buttons.find('.o_graph_button[data-mode="' + this.widget.mode + '"]').addClass('active'); + + this.$buttons.appendTo($node); } }, update_measure: function () { @@ -86,7 +88,7 @@ var GraphView = View.extend({ }, do_search: function (domain, context, group_by) { if (!this.widget) { - this.initial_groupbys = context.graph_groupbys || this.initial_groupbys; + this.initial_groupbys = context.graph_groupbys || (group_by.length ? group_by : this.initial_groupbys); this.widget = new GraphWidget(this, this.model, { measure: context.graph_measure || this.active_measure, mode: context.graph_mode || this.active_mode, @@ -112,14 +114,16 @@ var GraphView = View.extend({ }, on_button_click: function (event) { var $target = $(event.target); - if ($target.hasClass('oe-bar-mode')) {this.widget.set_mode('bar');} - if ($target.hasClass('oe-line-mode')) {this.widget.set_mode('line');} - if ($target.hasClass('oe-pie-mode')) {this.widget.set_mode('pie');} - if ($target.parents('.oe-measure-list').length) { - var parent = $target.parent(), - field = parent.data('field'); + if ($target.hasClass('o_graph_button')) { + this.widget.set_mode($target.data('mode')); + this.$buttons.find('.o_graph_button.active').removeClass('active'); + $target.addClass('active'); + } + else if ($target.parents('.o_graph_measures_list').length) { + var parent = $target.parent(); + var field = parent.data('field'); this.active_measure = field; - parent.toggleClass('selected'); + event.preventDefault(); event.stopPropagation(); this.update_measure(); this.widget.set_measure(this.active_measure); |
