[FIX] re-introduce is_set and is_not_set operators in advanced search
bzr revid: al@openerp.com-20130214170019-8c3kw6ehs15z5op3
This commit is contained in:
commit
cf109bdcb8
|
@ -1816,6 +1816,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
|
|||
template: 'SearchView.extended_search.proposition',
|
||||
events: {
|
||||
'change .searchview_extended_prop_field': 'changed',
|
||||
'change .searchview_extended_prop_op': 'operator_changed',
|
||||
'click .searchview_extended_delete_prop': function (e) {
|
||||
e.stopPropagation();
|
||||
this.getParent().remove_proposition(this);
|
||||
|
@ -1847,6 +1848,17 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
|
|||
this.select_field(_.detect(this.fields, function(x) {return x.name == nval;}));
|
||||
}
|
||||
},
|
||||
operator_changed: function (e) {
|
||||
var $value = this.$('.searchview_extended_prop_value');
|
||||
switch ($(e.target).val()) {
|
||||
case '∃':
|
||||
case '∄':
|
||||
$value.hide();
|
||||
break;
|
||||
default:
|
||||
$value.show();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Selects the provided field object
|
||||
*
|
||||
|
@ -1875,7 +1887,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
|
|||
.text(String(operator.text))
|
||||
.appendTo(self.$('.searchview_extended_prop_op'));
|
||||
});
|
||||
var $value_loc = this.$('.searchview_extended_prop_value').empty();
|
||||
var $value_loc = this.$('.searchview_extended_prop_value').show().empty();
|
||||
this.value.appendTo($value_loc);
|
||||
|
||||
},
|
||||
|
@ -1883,19 +1895,12 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
|
|||
if ( this.attrs.selected == null)
|
||||
return null;
|
||||
var field = this.attrs.selected;
|
||||
var op = this.$('.searchview_extended_prop_op')[0];
|
||||
var operator = op.options[op.selectedIndex];
|
||||
var op_select = this.$('.searchview_extended_prop_op')[0];
|
||||
var operator = op_select.options[op_select.selectedIndex];
|
||||
|
||||
return {
|
||||
label: _.str.sprintf(_t('%(field)s %(operator)s "%(value)s"'), {
|
||||
field: field.string,
|
||||
// According to spec, HTMLOptionElement#label should return
|
||||
// HTMLOptionElement#text when not defined/empty, but it does
|
||||
// not in older Webkit (between Safari 5.1.5 and Chrome 17) and
|
||||
// Gecko (pre Firefox 7) browsers, so we need a manual fallback
|
||||
// for those
|
||||
operator: operator.label || operator.text,
|
||||
value: this.value}),
|
||||
value: [field.name, operator.value, this.value.get_value()]
|
||||
label: this.value.get_label(field, operator),
|
||||
value: this.value.get_domain(field, operator),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -1905,6 +1910,37 @@ instance.web.search.ExtendedSearchProposition.Field = instance.web.Widget.extend
|
|||
this._super(parent);
|
||||
this.field = field;
|
||||
},
|
||||
get_label: function (field, operator) {
|
||||
var format;
|
||||
switch (operator.value) {
|
||||
case '∃': case '∄': format = _t('%(field)s %(operator)s'); break;
|
||||
default: format = _t('%(field)s %(operator)s "%(value)s"'); break;
|
||||
}
|
||||
return this.format_label(format, field, operator);
|
||||
},
|
||||
format_label: function (format, field, operator) {
|
||||
return _.str.sprintf(format, {
|
||||
field: field.string,
|
||||
// According to spec, HTMLOptionElement#label should return
|
||||
// HTMLOptionElement#text when not defined/empty, but it does
|
||||
// not in older Webkit (between Safari 5.1.5 and Chrome 17) and
|
||||
// Gecko (pre Firefox 7) browsers, so we need a manual fallback
|
||||
// for those
|
||||
operator: operator.label || operator.text,
|
||||
value: this
|
||||
});
|
||||
},
|
||||
get_domain: function (field, operator) {
|
||||
switch (operator.value) {
|
||||
case '∃': return this.make_domain(field.name, '!=', false);
|
||||
case '∄': return this.make_domain(field.name, '=', false);
|
||||
default: return this.make_domain(
|
||||
field.name, operator.value, this.get_value());
|
||||
}
|
||||
},
|
||||
make_domain: function (field, operator, value) {
|
||||
return [field, operator, value];
|
||||
},
|
||||
/**
|
||||
* Returns a human-readable version of the value, in case the "logical"
|
||||
* and the "semantic" values of a field differ (as for selection fields,
|
||||
|
@ -1924,7 +1960,9 @@ instance.web.search.ExtendedSearchProposition.Char = instance.web.search.Extende
|
|||
{value: "ilike", text: _lt("contains")},
|
||||
{value: "not ilike", text: _lt("doesn't contain")},
|
||||
{value: "=", text: _lt("is equal to")},
|
||||
{value: "!=", text: _lt("is not equal to")}
|
||||
{value: "!=", text: _lt("is not equal to")},
|
||||
{value: "∃", text: _lt("is set")},
|
||||
{value: "∄", text: _lt("is not set")}
|
||||
],
|
||||
get_value: function() {
|
||||
return this.$el.val();
|
||||
|
@ -1938,7 +1976,9 @@ instance.web.search.ExtendedSearchProposition.DateTime = instance.web.search.Ext
|
|||
{value: ">", text: _lt("greater than")},
|
||||
{value: "<", text: _lt("less than")},
|
||||
{value: ">=", text: _lt("greater or equal than")},
|
||||
{value: "<=", text: _lt("less or equal than")}
|
||||
{value: "<=", text: _lt("less or equal than")},
|
||||
{value: "∃", text: _lt("is set")},
|
||||
{value: "∄", text: _lt("is not set")}
|
||||
],
|
||||
/**
|
||||
* Date widgets live in view_form which is not yet loaded when this is
|
||||
|
@ -1972,7 +2012,9 @@ instance.web.search.ExtendedSearchProposition.Integer = instance.web.search.Exte
|
|||
{value: ">", text: _lt("greater than")},
|
||||
{value: "<", text: _lt("less than")},
|
||||
{value: ">=", text: _lt("greater or equal than")},
|
||||
{value: "<=", text: _lt("less or equal than")}
|
||||
{value: "<=", text: _lt("less or equal than")},
|
||||
{value: "∃", text: _lt("is set")},
|
||||
{value: "∄", text: _lt("is not set")}
|
||||
],
|
||||
toString: function () {
|
||||
return this.$el.val();
|
||||
|
@ -1997,7 +2039,9 @@ instance.web.search.ExtendedSearchProposition.Float = instance.web.search.Extend
|
|||
{value: ">", text: _lt("greater than")},
|
||||
{value: "<", text: _lt("less than")},
|
||||
{value: ">=", text: _lt("greater or equal than")},
|
||||
{value: "<=", text: _lt("less or equal than")}
|
||||
{value: "<=", text: _lt("less or equal than")},
|
||||
{value: "∃", text: _lt("is set")},
|
||||
{value: "∄", text: _lt("is not set")}
|
||||
],
|
||||
toString: function () {
|
||||
return this.$el.val();
|
||||
|
@ -2015,7 +2059,9 @@ instance.web.search.ExtendedSearchProposition.Selection = instance.web.search.Ex
|
|||
template: 'SearchView.extended_search.proposition.selection',
|
||||
operators: [
|
||||
{value: "=", text: _lt("is")},
|
||||
{value: "!=", text: _lt("is not")}
|
||||
{value: "!=", text: _lt("is not")},
|
||||
{value: "∃", text: _lt("is set")},
|
||||
{value: "∄", text: _lt("is not set")}
|
||||
],
|
||||
toString: function () {
|
||||
var select = this.$el[0];
|
||||
|
@ -2032,7 +2078,10 @@ instance.web.search.ExtendedSearchProposition.Boolean = instance.web.search.Exte
|
|||
{value: "=", text: _lt("is true")},
|
||||
{value: "!=", text: _lt("is false")}
|
||||
],
|
||||
toString: function () { return ''; },
|
||||
get_label: function (field, operator) {
|
||||
return this.format_label(
|
||||
_t('%(field)s %(operator)s'), field, operator);
|
||||
},
|
||||
get_value: function() {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue