[ADD] re-introduce 'is set' and 'is not set' operators which were added to 6.1 but never ported to 7.0

lp bug: https://launchpad.net/bugs/1013528 fixed

bzr revid: xmo@openerp.com-20130214140637-rk46j7csu0i4an31
This commit is contained in:
Xavier Morel 2013-02-14 15:06:37 +01:00
parent e72d321e01
commit 195fef053e
1 changed files with 49 additions and 10 deletions

View File

@ -1816,6 +1816,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
template: 'SearchView.extended_search.proposition', template: 'SearchView.extended_search.proposition',
events: { events: {
'change .searchview_extended_prop_field': 'changed', 'change .searchview_extended_prop_field': 'changed',
'change .searchview_extended_prop_op': 'operator_changed',
'click .searchview_extended_delete_prop': function (e) { 'click .searchview_extended_delete_prop': function (e) {
e.stopPropagation(); e.stopPropagation();
this.getParent().remove_proposition(this); 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;})); this.select_field(_.detect(this.fields, function(x) {return x.name == nval;}));
} }
}, },
operator_changed: function (e) {
var $value = self.$('.searchview_extended_prop_value');
switch ($(e.target).val()) {
case '∃':
case '∄':
$value.hide();
break;
default:
$value.show();
}
},
/** /**
* Selects the provided field object * Selects the provided field object
* *
@ -1875,7 +1887,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
.text(String(operator.text)) .text(String(operator.text))
.appendTo(self.$('.searchview_extended_prop_op')); .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); this.value.appendTo($value_loc);
}, },
@ -1883,10 +1895,27 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
if ( this.attrs.selected == null) if ( this.attrs.selected == null)
return null; return null;
var field = this.attrs.selected; var field = this.attrs.selected;
var op = this.$('.searchview_extended_prop_op')[0]; var op_select = this.$('.searchview_extended_prop_op')[0];
var operator = op.options[op.selectedIndex]; var operator = op_select.options[op_select.selectedIndex];
var op, val, format;
switch (operator.value) {
case '∃':
case '∄':
format = _t('%(field)s %(operator)s');
val = false;
break;
default:
op = operator.value;
val = this.value.get_value();
format = _t('%(field)s %(operator)s "%(value)s"');
}
switch (operator.value) {
case '∃': op = '!='; break;
case '∄': op = '='; break;
}
return { return {
label: _.str.sprintf(_t('%(field)s %(operator)s "%(value)s"'), { label: _.str.sprintf(format, {
field: field.string, field: field.string,
// According to spec, HTMLOptionElement#label should return // According to spec, HTMLOptionElement#label should return
// HTMLOptionElement#text when not defined/empty, but it does // HTMLOptionElement#text when not defined/empty, but it does
@ -1895,7 +1924,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
// for those // for those
operator: operator.label || operator.text, operator: operator.label || operator.text,
value: this.value}), value: this.value}),
value: [field.name, operator.value, this.value.get_value()] value: [field.name, op, val]
}; };
} }
}); });
@ -1924,7 +1953,9 @@ instance.web.search.ExtendedSearchProposition.Char = instance.web.search.Extende
{value: "ilike", text: _lt("contains")}, {value: "ilike", text: _lt("contains")},
{value: "not ilike", text: _lt("doesn't contain")}, {value: "not ilike", text: _lt("doesn't contain")},
{value: "=", text: _lt("is equal to")}, {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() { get_value: function() {
return this.$el.val(); return this.$el.val();
@ -1938,7 +1969,9 @@ instance.web.search.ExtendedSearchProposition.DateTime = instance.web.search.Ext
{value: ">", text: _lt("greater than")}, {value: ">", text: _lt("greater than")},
{value: "<", text: _lt("less than")}, {value: "<", text: _lt("less than")},
{value: ">=", text: _lt("greater or equal 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 * Date widgets live in view_form which is not yet loaded when this is
@ -1972,7 +2005,9 @@ instance.web.search.ExtendedSearchProposition.Integer = instance.web.search.Exte
{value: ">", text: _lt("greater than")}, {value: ">", text: _lt("greater than")},
{value: "<", text: _lt("less than")}, {value: "<", text: _lt("less than")},
{value: ">=", text: _lt("greater or equal 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 () { toString: function () {
return this.$el.val(); return this.$el.val();
@ -1997,7 +2032,9 @@ instance.web.search.ExtendedSearchProposition.Float = instance.web.search.Extend
{value: ">", text: _lt("greater than")}, {value: ">", text: _lt("greater than")},
{value: "<", text: _lt("less than")}, {value: "<", text: _lt("less than")},
{value: ">=", text: _lt("greater or equal 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 () { toString: function () {
return this.$el.val(); return this.$el.val();
@ -2015,7 +2052,9 @@ instance.web.search.ExtendedSearchProposition.Selection = instance.web.search.Ex
template: 'SearchView.extended_search.proposition.selection', template: 'SearchView.extended_search.proposition.selection',
operators: [ operators: [
{value: "=", text: _lt("is")}, {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 () { toString: function () {
var select = this.$el[0]; var select = this.$el[0];