summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2013-02-14 15:06:37 +0100
committerXavier Morel <xmo@openerp.com>2013-02-14 15:06:37 +0100
commit195fef053e042e1fe0e0e99cd4ecb4d9a5052b4c (patch)
tree4ce5e28bdff25a9ca03fb626db820727eb876bb1 /addons
parente72d321e01ac24e3aed8bc8b7c9f18fba1db42dd (diff)
[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
Diffstat (limited to 'addons')
-rw-r--r--addons/web/static/src/js/search.js59
1 files changed, 49 insertions, 10 deletions
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js
index 8391f7a8ca5..933efe903ab 100644
--- a/addons/web/static/src/js/search.js
+++ b/addons/web/static/src/js/search.js
@@ -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 = self.$('.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,10 +1895,27 @@ 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];
+ 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 {
- label: _.str.sprintf(_t('%(field)s %(operator)s "%(value)s"'), {
+ label: _.str.sprintf(format, {
field: field.string,
// According to spec, HTMLOptionElement#label should return
// HTMLOptionElement#text when not defined/empty, but it does
@@ -1895,7 +1924,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
// for those
operator: operator.label || operator.text,
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: "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 +1969,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 +2005,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 +2032,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 +2052,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];