2011-04-15 06:42:41 +00:00
|
|
|
/*---------------------------------------------------------
|
2011-09-05 12:28:15 +00:00
|
|
|
* OpenERP web_graph
|
2011-04-15 06:42:41 +00:00
|
|
|
*---------------------------------------------------------*/
|
2013-11-08 13:08:06 +00:00
|
|
|
/*global openerp:true*/
|
|
|
|
/*global $:true*/
|
|
|
|
'use strict';
|
2011-04-15 06:42:41 +00:00
|
|
|
|
2012-04-17 12:48:30 +00:00
|
|
|
openerp.web_graph = function (instance) {
|
2011-06-17 13:25:50 +00:00
|
|
|
|
2012-06-07 14:17:12 +00:00
|
|
|
var _lt = instance.web._lt;
|
2013-01-25 07:02:40 +00:00
|
|
|
var _t = instance.web._t;
|
2012-05-07 08:19:08 +00:00
|
|
|
|
2012-04-17 12:48:30 +00:00
|
|
|
instance.web.views.add('graph', 'instance.web_graph.GraphView');
|
2013-11-08 13:08:06 +00:00
|
|
|
|
2012-04-17 12:48:30 +00:00
|
|
|
instance.web_graph.GraphView = instance.web.View.extend({
|
2013-11-08 13:08:06 +00:00
|
|
|
template: 'GraphView',
|
2011-12-16 13:00:00 +00:00
|
|
|
display_name: _lt('Graph'),
|
2013-11-08 13:08:06 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2011-04-15 06:42:41 +00:00
|
|
|
|
2011-10-07 15:21:16 +00:00
|
|
|
init: function(parent, dataset, view_id, options) {
|
2013-11-08 11:32:10 +00:00
|
|
|
this._super(parent, dataset, view_id, options);
|
2013-11-08 13:08:06 +00:00
|
|
|
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();
|
2011-05-06 12:41:08 +00:00
|
|
|
},
|
2012-05-07 09:40:59 +00:00
|
|
|
|
2013-11-08 11:32:10 +00:00
|
|
|
do_show: function () {
|
2012-01-03 16:06:50 +00:00
|
|
|
this.do_push_state({});
|
|
|
|
return this._super();
|
2012-05-07 08:19:08 +00:00
|
|
|
},
|
2013-11-08 13:08:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
|
|
|
},
|
2013-11-08 11:32:10 +00:00
|
|
|
|
2013-11-08 13:08:06 +00:00
|
|
|
hide: function () {
|
|
|
|
this.$el.css('display', 'none');
|
|
|
|
},
|
2013-11-08 11:32:10 +00:00
|
|
|
|
2011-04-15 06:42:41 +00:00
|
|
|
});
|
2013-11-08 13:08:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-15 06:42:41 +00:00
|
|
|
};
|