[MERGE] merge various graph view fixes

bzr revid: ged@openerp.com-20140211154441-6sq778kxoxeg7zrf
This commit is contained in:
Gery Debongnie 2014-02-11 16:44:41 +01:00
commit 1f06a50153
5 changed files with 61 additions and 43 deletions

View File

@ -2142,7 +2142,7 @@
}
.openerp .oe_form .oe_form_label_help[for] span, .openerp .oe_form .oe_form_label[for] span {
font-size: 80%;
color: darkGreen;
color: darkgreen;
vertical-align: top;
position: relative;
top: -4px;
@ -3138,10 +3138,6 @@
border: none;
padding: 10px 0 3px 0;
}
.openerp .jqstooltip {
height: auto !important;
width: auto !important;
}
.openerp h5 {
font-weight: bold;
font-size: smaller;
@ -3153,6 +3149,12 @@
margin: 3px 3px 0 !important;
}
.jqstooltip {
height: auto !important;
width: auto !important;
padding: 0;
}
@-moz-document url-prefix() {
.openerp .oe_searchview .oe_searchview_search {
top: -1px;

View File

@ -2517,10 +2517,7 @@ $sheet-padding: 16px
border: none
padding: 10px 0 3px 0
// Customize for kanban tooltip
.jqstooltip
height: auto !important
width: auto !important
// Customize for chatter
h5
@ -2531,7 +2528,12 @@ $sheet-padding: 16px
.oe_msg_subtype_check
margin: 3px 3px 0 !important
// }}}
// Customize for kanban tooltip
.jqstooltip
height: auto !important
width: auto !important
padding: 0
@-moz-document url-prefix()
.openerp
.oe_searchview .oe_searchview_search

View File

@ -50,7 +50,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
var field_name = field.attrs.name;
if (_.has(field.attrs, 'interval')) {
field_name = field.attrs.name + ':' + field.attrs.interval;
}
}
if (_.has(field.attrs, 'type')) {
switch (field.attrs.type) {
case 'row':
@ -77,15 +77,20 @@ instance.web_graph.GraphView = instance.web.View.extend({
},
do_search: function (domain, context, group_by) {
if (this.ignore_do_search) {
this.ignore_do_search = false;
return;
}
var self = this,
col_group_by = context.col_group_by || this.get_groupbys_from_searchview('ColGroupBy', 'col_group_by');
col_group_by = self.get_groupbys_from_searchview('ColGroupBy', 'col_group_by');
if (!this.graph_widget) {
if (group_by.length) {
this.widget_config.row_groupby = group_by;
}
if (col_group_by.length) {
this.widget_config.col_groupby = group_by;
this.widget_config.col_groupby = col_group_by;
}
this.graph_widget = new openerp.web_graph.Graph(this, this.model, domain, this.widget_config);
this.graph_widget.appendTo(this.$el);
@ -101,16 +106,18 @@ instance.web_graph.GraphView = instance.web.View.extend({
this.graph_widget.set(domain, group_by, col_group_by);
},
extract_groupby: function (cat_field, context) {
context = (_.isString(context)) ? py.eval(context) : context;
return context[cat_field];
},
get_groupbys_from_searchview: function (cat_name, cat_field) {
var facet = this.search_view.query.findWhere({category:cat_name}),
var self=this,
facet = this.search_view.query.findWhere({category:cat_name}),
groupby_list = facet ? facet.values.models : [];
return _.map(groupby_list, function (g) {
var context = g.attributes.value.attrs.context;
if (_.isString(context)) {
return py.eval(context).group_by;
} else {
return context[cat_field];
}
return self.extract_groupby(cat_field, context);
});
},
@ -129,6 +136,14 @@ instance.web_graph.GraphView = instance.web.View.extend({
if (!_.has(this.search_view, '_s_groupby')) { return; }
if (row_groupby.length && col_groupby.length) {
// when two changes to the search view will be done, the method do_search
// will be called twice, once with the correct groupby and incorrect col_groupby,
// and once with correct informations. This flag is necessary to prevent the
// incorrect informations to propagate and trigger useless queries
this.ignore_do_search = true;
}
// add row groupbys
var row_facet = this.make_row_groupby_facets(row_groupby),
row_search_facet = query.findWhere({category:'GroupBy'});

View File

@ -258,9 +258,6 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
case 'swap_axis':
this.swap_axis();
break;
case 'expand_all':
this.pivot.expand_all().then(this.proxy('display_data'));
break;
case 'update_values':
this.pivot.update_data().then(this.proxy('display_data'));
break;
@ -287,25 +284,30 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
if (header.expanded) {
this.fold(header);
} else {
if (header.path.length < header.root.groupby.length) {
this.expand(id);
} else {
if (!this.important_fields.length) {
return;
}
var fields = _.map(this.important_fields, function (field) {
return {id: field.field, value: field.string, type:self.fields[field.field.split(':')[0]].type};
});
this.dropdown = $(QWeb.render('field_selection', {fields:fields, header_id:id}));
$(event.target).after(this.dropdown);
this.dropdown.css({position:'absolute',
left:event.pageX,
top:event.pageY});
this.$('.field-selection').next('.dropdown-menu').toggle();
}
return;
}
if (header.path.length < header.root.groupby.length) {
this.expand(id);
return;
}
if (!this.important_fields.length) {
return;
}
var fields = _.map(this.important_fields, function (field) {
return {id: field.field, value: field.string, type:self.fields[field.field.split(':')[0]].type};
});
if (this.dropdown) {
this.dropdown.remove();
}
this.dropdown = $(QWeb.render('field_selection', {fields:fields, header_id:id}));
$(event.target).after(this.dropdown);
this.dropdown.css({position:'absolute',
left:event.pageX,
top:event.pageY});
this.$('.field-selection').next('.dropdown-menu').toggle();
},
field_selection: function (event) {

View File

@ -35,9 +35,6 @@
<label class="btn btn-default" data-choice="swap_axis" title="Swap Axis">
<span class="fa fa-expand"></span>
</label>
<label class="btn btn-default" data-choice="expand_all" title="Expand All">
<span class="fa fa-arrows-alt"></span>
</label>
<label class="btn btn-default" data-choice="update_values" title="Reload Data">
<span class="fa fa-refresh"></span>
</label>