projects
/
odoo
/
odoo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[FIX] correctly calls the parent of the graph view in the constructor (now, the view...
[odoo/odoo.git]
/
addons
/
web_graph
/
static
/
src
/
js
/
graph.js
diff --git
a/addons/web_graph/static/src/js/graph.js
b/addons/web_graph/static/src/js/graph.js
index
991b219
..
9806e70
100644
(file)
--- a/
addons/web_graph/static/src/js/graph.js
+++ b/
addons/web_graph/static/src/js/graph.js
@@
-18,7
+18,7
@@
instance.web_graph.GraphView = instance.web.View.extend({
view_type: 'graph',
init: function(parent, dataset, view_id, options) {
view_type: 'graph',
init: function(parent, dataset, view_id, options) {
- this._super(parent);
+ this._super(parent, dataset, view_id, options);
this.dataset = dataset;
this.model = new instance.web.Model(dataset.model, {group_by_no_leaf: true});
this.search_view = parent.searchview;
this.dataset = dataset;
this.model = new instance.web.Model(dataset.model, {group_by_no_leaf: true});
this.search_view = parent.searchview;
@@
-57,20
+57,20
@@
instance.web_graph.GraphView = instance.web.View.extend({
if (arch.attrs.type === 'bar' || !_.has(arch.attrs, 'type')) {
this.graph_widget.mode = 'bar_chart';
}
if (arch.attrs.type === 'bar' || !_.has(arch.attrs, 'type')) {
this.graph_widget.mode = 'bar_chart';
}
- if (arch.attrs.stacked === "True") {
+ if (arch.attrs.stacked === 'True') {
stacked = true;
}
_.each(arch.children, function (field) {
if (_.has(field.attrs, 'type')) {
switch (field.attrs.type) {
stacked = true;
}
_.each(arch.children, function (field) {
if (_.has(field.attrs, 'type')) {
switch (field.attrs.type) {
- case "row":
+ case 'row':
self.default_row_groupby.push(field.attrs.name);
break;
self.default_row_groupby.push(field.attrs.name);
break;
- case "col":
+ case 'col':
self.default_col_groupby.push(field.attrs.name);
break;
self.default_col_groupby.push(field.attrs.name);
break;
- case "measure":
+ case 'measure':
measure = field.attrs.name;
break;
}
measure = field.attrs.name;
break;
}
@@
-83,15
+83,14
@@
instance.web_graph.GraphView = instance.web.View.extend({
}
});
this.graph_widget.config({
}
});
this.graph_widget.config({
- measure:measure,
+ measure:measure,
update:false,
bar_ui: (stacked) ? 'stack' : 'group'
});
},
do_search: function (domain, context, group_by) {
update:false,
bar_ui: (stacked) ? 'stack' : 'group'
});
},
do_search: function (domain, context, group_by) {
- var self = this,
- col_groupby = context.col_group_by || [],
+ var col_groupby = context.col_group_by || [],
options = {domain:domain};
this.search_view_groupby = group_by;
options = {domain:domain};
this.search_view_groupby = group_by;
@@
-99,12
+98,12
@@
instance.web_graph.GraphView = instance.web.View.extend({
if (group_by.length && this.groupby_mode !== 'manual') {
if (_.isEqual(col_groupby, [])) {
col_groupby = this.default_col_groupby;
if (group_by.length && this.groupby_mode !== 'manual') {
if (_.isEqual(col_groupby, [])) {
col_groupby = this.default_col_groupby;
- }
+ }
}
if (group_by.length || col_groupby.length) {
this.groupby_mode = 'manual';
}
}
if (group_by.length || col_groupby.length) {
this.groupby_mode = 'manual';
}
- if (!this.graph_widget.enabled) {
+ if (!this.graph_widget.enabled) {
options.update = false;
options.silent = true;
}
options.update = false;
options.silent = true;
}
@@
-120,6
+119,7
@@
instance.web_graph.GraphView = instance.web.View.extend({
if (!this.graph_widget.enabled) {
this.graph_widget.activate_display();
if (!this.graph_widget.enabled) {
this.graph_widget.activate_display();
+ this.ViewManager.on('switch_mode', this, function () {this.graph_widget.pivot.update_data(); });
}
},
}
},
@@
-172,7
+172,7
@@
instance.web_graph.GraphView = instance.web.View.extend({
});
instance.web_graph.Graph = instance.web.Widget.extend({
});
instance.web_graph.Graph = instance.web.Widget.extend({
- template: "GraphWidget",
+ template: 'GraphWidget',
events: {
'click .graph_mode_selection li' : 'mode_selection',
events: {
'click .graph_mode_selection li' : 'mode_selection',
@@
-263,7
+263,7
@@
instance.web_graph.Graph = instance.web.Widget.extend({
this.pivot.on('redraw_required', this, this.proxy('display_data'));
this.pivot.update_data();
this.enabled = true;
this.pivot.on('redraw_required', this, this.proxy('display_data'));
this.pivot.update_data();
this.enabled = true;
- instance.web.bus.on('click', this, function (ev) {
+ instance.web.bus.on('click', this, function () {
if (this.dropdown) {
this.dropdown.remove();
this.dropdown = null;
if (this.dropdown) {
this.dropdown.remove();
this.dropdown = null;
@@
-273,6
+273,7
@@
instance.web_graph.Graph = instance.web.Widget.extend({
display_data: function () {
this.$('.graph_main_content svg').remove();
display_data: function () {
this.$('.graph_main_content svg').remove();
+ this.$('.graph_main_content div').remove();
this.table.empty();
if (this.visible_ui) {
this.table.empty();
if (this.visible_ui) {
@@
-281,8
+282,7
@@
instance.web_graph.Graph = instance.web.Widget.extend({
this.$('.graph_header').css('display', 'none');
}
if (this.pivot.no_data) {
this.$('.graph_header').css('display', 'none');
}
if (this.pivot.no_data) {
- var msg = 'No data available. Try to remove any filter or add some data.';
- this.table.append($('<tr><td>' + msg + '</td></tr>'));
+ this.$('.graph_main_content').append($(QWeb.render('graph_no_data')));
} else {
var table_modes = ['pivot', 'heatmap', 'row_heatmap', 'col_heatmap'];
if (_.contains(table_modes, this.mode)) {
} else {
var table_modes = ['pivot', 'heatmap', 'row_heatmap', 'col_heatmap'];
if (_.contains(table_modes, this.mode)) {
@@
-336,8
+336,7
@@
instance.web_graph.Graph = instance.web.Widget.extend({
event.stopPropagation();
var id = event.target.attributes['data-id'].nodeValue,
header = this.pivot.get_header(id),
event.stopPropagation();
var id = event.target.attributes['data-id'].nodeValue,
header = this.pivot.get_header(id),
- self = this,
- dim = header.root.groupby.length;
+ self = this;
if (header.is_expanded) {
this.pivot.fold(header);
if (header.is_expanded) {
this.pivot.fold(header);
@@
-363,8
+362,7
@@
instance.web_graph.Graph = instance.web.Widget.extend({
},
field_selection: function (event) {
},
field_selection: function (event) {
- var self = this,
- id = event.target.attributes['data-id'].nodeValue,
+ var id = event.target.attributes['data-id'].nodeValue,
field_id = event.target.attributes['data-field-id'].nodeValue;
event.preventDefault();
this.pivot.expand(id, field_id);
field_id = event.target.attributes['data-field-id'].nodeValue;
event.preventDefault();
this.pivot.expand(id, field_id);
@@
-582,6
+580,8
@@
instance.web_graph.Graph = instance.web.Widget.extend({
.stacked(self.bar_ui === 'stack')
.staggerLabels(true);
.stacked(self.bar_ui === 'stack')
.staggerLabels(true);
+ if (dim_x === 1 && dim_y === 0) { chart.showControls(false); }
+
d3.select(self.svg)
.datum(data)
.attr('width', self.width)
d3.select(self.svg)
.datum(data)
.attr('width', self.width)
@@
-631,8
+631,7
@@
instance.web_graph.Graph = instance.web.Widget.extend({
pie_chart: function () {
var self = this,
pie_chart: function () {
var self = this,
- dim_x = this.pivot.rows.groupby.length,
- dim_y = this.pivot.cols.groupby.length;
+ dim_x = this.pivot.rows.groupby.length;
var data = _.map(this.pivot.get_rows_leaves(), function (row) {
var title = _.map(row.path, function (p) {
var data = _.map(this.pivot.get_rows_leaves(), function (row) {
var title = _.map(row.path, function (p) {