summaryrefslogtreecommitdiff
path: root/addons/web_graph/static/src/js/graph.js
diff options
context:
space:
mode:
authorGery Debongnie <ged@openerp.com>2013-11-08 14:08:06 +0100
committerGery Debongnie <ged@openerp.com>2013-11-08 14:08:06 +0100
commit7ad9aecc13e23ce40a4b22e31ed5f7f9435adf4c (patch)
treeaa60d6fcfe45719fb1f35f68d78ae00e27f8ba4e /addons/web_graph/static/src/js/graph.js
parent23b9f226c782e1b8290171df530dfb0465933204 (diff)
[IMP] add widgets (chart view and pivot view) in addon web_graph
bzr revid: ged@openerp.com-20131108130806-ez2a6sxdsy0bzg62
Diffstat (limited to 'addons/web_graph/static/src/js/graph.js')
-rw-r--r--addons/web_graph/static/src/js/graph.js57
1 files changed, 54 insertions, 3 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js
index af63c78cff1..173f2e8973a 100644
--- a/addons/web_graph/static/src/js/graph.js
+++ b/addons/web_graph/static/src/js/graph.js
@@ -1,28 +1,79 @@
/*---------------------------------------------------------
* OpenERP web_graph
*---------------------------------------------------------*/
+/*global openerp:true*/
+/*global $:true*/
+'use strict';
openerp.web_graph = function (instance) {
var _lt = instance.web._lt;
var _t = instance.web._t;
-
instance.web.views.add('graph', 'instance.web_graph.GraphView');
+
instance.web_graph.GraphView = instance.web.View.extend({
- template: "GraphView",
+ template: 'GraphView',
display_name: _lt('Graph'),
- view_type: "graph",
+ view_type: 'graph',
+ events: {
+ 'click .graph_mode_selection li' : function (event) {
+ event.preventDefault();
+ var mode = event.target.attributes['data-mode'].nodeValue;
+ if (mode == 'data') {
+ this.chart_view.hide();
+ this.pivot_table.show();
+ } else {
+ this.pivot_table.hide();
+ this.chart_view.show(mode);
+ }
+ },
+ },
init: function(parent, dataset, view_id, options) {
this._super(parent, dataset, view_id, options);
+ this.pivot_table = new PivotTable(this);
+ this.chart_view = new ChartView(this);
+ },
+
+ view_loading: function (fields_view_get) {
+ this.pivot_table.appendTo('.graph_pivot');
+ this.chart_view.appendTo('.graph_chart');
+ this.chart_view.hide();
},
do_show: function () {
this.do_push_state({});
return this._super();
},
+});
+
+var PivotTable = instance.web.Widget.extend({
+ template: 'pivot_table',
+
+ show: function () {
+ this.$el.css('display', 'block');
+ },
+
+ hide: function () {
+ this.$el.css('display', 'none');
+ },
+
+});
+
+var ChartView = instance.web.Widget.extend({
+ template: 'chart_view',
+
+ show: function () {
+ this.$el.css('display', 'block');
+ },
+ hide: function () {
+ this.$el.css('display', 'none');
+ },
});
+
+
+
};