Merge lp:~openerp-dev/openerp-web/7.0-filter-empty-fields-xmo into lp:openerp-web/7.0

Proposed by Xavier (Open ERP)
Status: Merged
Merged at revision: 3759
Proposed branch: lp:~openerp-dev/openerp-web/7.0-filter-empty-fields-xmo
Merge into: lp:openerp-web/7.0
Diff against target: 133 lines (+49/-10)
1 file modified
addons/web/static/src/js/search.js (+49/-10)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-filter-empty-fields-xmo
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+148461@code.launchpad.net

Description of the change

Being able to filter on a field being empty or not empty (alt: set or not set) was added to advanced filters in 6.1, but never merged into (then) trunk and thus never in 7.0.

See https://bugs.launchpad.net/openerp-web/+bug/1013528 for ticket opened at the time

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/static/src/js/search.js'
--- addons/web/static/src/js/search.js 2013-01-31 13:51:25 +0000
+++ addons/web/static/src/js/search.js 2013-02-14 14:13:25 +0000
@@ -1816,6 +1816,7 @@
1816 template: 'SearchView.extended_search.proposition',1816 template: 'SearchView.extended_search.proposition',
1817 events: {1817 events: {
1818 'change .searchview_extended_prop_field': 'changed',1818 'change .searchview_extended_prop_field': 'changed',
1819 'change .searchview_extended_prop_op': 'operator_changed',
1819 'click .searchview_extended_delete_prop': function (e) {1820 'click .searchview_extended_delete_prop': function (e) {
1820 e.stopPropagation();1821 e.stopPropagation();
1821 this.getParent().remove_proposition(this);1822 this.getParent().remove_proposition(this);
@@ -1847,6 +1848,17 @@
1847 this.select_field(_.detect(this.fields, function(x) {return x.name == nval;}));1848 this.select_field(_.detect(this.fields, function(x) {return x.name == nval;}));
1848 }1849 }
1849 },1850 },
1851 operator_changed: function (e) {
1852 var $value = self.$('.searchview_extended_prop_value');
1853 switch ($(e.target).val()) {
1854 case '∃':
1855 case '∄':
1856 $value.hide();
1857 break;
1858 default:
1859 $value.show();
1860 }
1861 },
1850 /**1862 /**
1851 * Selects the provided field object1863 * Selects the provided field object
1852 *1864 *
@@ -1875,7 +1887,7 @@
1875 .text(String(operator.text))1887 .text(String(operator.text))
1876 .appendTo(self.$('.searchview_extended_prop_op'));1888 .appendTo(self.$('.searchview_extended_prop_op'));
1877 });1889 });
1878 var $value_loc = this.$('.searchview_extended_prop_value').empty();1890 var $value_loc = this.$('.searchview_extended_prop_value').show().empty();
1879 this.value.appendTo($value_loc);1891 this.value.appendTo($value_loc);
18801892
1881 },1893 },
@@ -1883,10 +1895,27 @@
1883 if ( this.attrs.selected == null)1895 if ( this.attrs.selected == null)
1884 return null;1896 return null;
1885 var field = this.attrs.selected;1897 var field = this.attrs.selected;
1886 var op = this.$('.searchview_extended_prop_op')[0];1898 var op_select = this.$('.searchview_extended_prop_op')[0];
1887 var operator = op.options[op.selectedIndex];1899 var operator = op_select.options[op_select.selectedIndex];
1900 var op, val, format;
1901 switch (operator.value) {
1902 case '∃':
1903 case '∄':
1904 format = _t('%(field)s %(operator)s');
1905 val = false;
1906 break;
1907 default:
1908 op = operator.value;
1909 val = this.value.get_value();
1910 format = _t('%(field)s %(operator)s "%(value)s"');
1911 }
1912 switch (operator.value) {
1913 case '∃': op = '!='; break;
1914 case '∄': op = '='; break;
1915 }
1916
1888 return {1917 return {
1889 label: _.str.sprintf(_t('%(field)s %(operator)s "%(value)s"'), {1918 label: _.str.sprintf(format, {
1890 field: field.string,1919 field: field.string,
1891 // According to spec, HTMLOptionElement#label should return1920 // According to spec, HTMLOptionElement#label should return
1892 // HTMLOptionElement#text when not defined/empty, but it does1921 // HTMLOptionElement#text when not defined/empty, but it does
@@ -1895,7 +1924,7 @@
1895 // for those1924 // for those
1896 operator: operator.label || operator.text,1925 operator: operator.label || operator.text,
1897 value: this.value}),1926 value: this.value}),
1898 value: [field.name, operator.value, this.value.get_value()]1927 value: [field.name, op, val]
1899 };1928 };
1900 }1929 }
1901});1930});
@@ -1924,7 +1953,9 @@
1924 {value: "ilike", text: _lt("contains")},1953 {value: "ilike", text: _lt("contains")},
1925 {value: "not ilike", text: _lt("doesn't contain")},1954 {value: "not ilike", text: _lt("doesn't contain")},
1926 {value: "=", text: _lt("is equal to")},1955 {value: "=", text: _lt("is equal to")},
1927 {value: "!=", text: _lt("is not equal to")}1956 {value: "!=", text: _lt("is not equal to")},
1957 {value: "∃", text: _lt("is set")},
1958 {value: "∄", text: _lt("is not set")}
1928 ],1959 ],
1929 get_value: function() {1960 get_value: function() {
1930 return this.$el.val();1961 return this.$el.val();
@@ -1938,7 +1969,9 @@
1938 {value: ">", text: _lt("greater than")},1969 {value: ">", text: _lt("greater than")},
1939 {value: "<", text: _lt("less than")},1970 {value: "<", text: _lt("less than")},
1940 {value: ">=", text: _lt("greater or equal than")},1971 {value: ">=", text: _lt("greater or equal than")},
1941 {value: "<=", text: _lt("less or equal than")}1972 {value: "<=", text: _lt("less or equal than")},
1973 {value: "∃", text: _lt("is set")},
1974 {value: "∄", text: _lt("is not set")}
1942 ],1975 ],
1943 /**1976 /**
1944 * Date widgets live in view_form which is not yet loaded when this is1977 * Date widgets live in view_form which is not yet loaded when this is
@@ -1972,7 +2005,9 @@
1972 {value: ">", text: _lt("greater than")},2005 {value: ">", text: _lt("greater than")},
1973 {value: "<", text: _lt("less than")},2006 {value: "<", text: _lt("less than")},
1974 {value: ">=", text: _lt("greater or equal than")},2007 {value: ">=", text: _lt("greater or equal than")},
1975 {value: "<=", text: _lt("less or equal than")}2008 {value: "<=", text: _lt("less or equal than")},
2009 {value: "∃", text: _lt("is set")},
2010 {value: "∄", text: _lt("is not set")}
1976 ],2011 ],
1977 toString: function () {2012 toString: function () {
1978 return this.$el.val();2013 return this.$el.val();
@@ -1997,7 +2032,9 @@
1997 {value: ">", text: _lt("greater than")},2032 {value: ">", text: _lt("greater than")},
1998 {value: "<", text: _lt("less than")},2033 {value: "<", text: _lt("less than")},
1999 {value: ">=", text: _lt("greater or equal than")},2034 {value: ">=", text: _lt("greater or equal than")},
2000 {value: "<=", text: _lt("less or equal than")}2035 {value: "<=", text: _lt("less or equal than")},
2036 {value: "∃", text: _lt("is set")},
2037 {value: "∄", text: _lt("is not set")}
2001 ],2038 ],
2002 toString: function () {2039 toString: function () {
2003 return this.$el.val();2040 return this.$el.val();
@@ -2015,7 +2052,9 @@
2015 template: 'SearchView.extended_search.proposition.selection',2052 template: 'SearchView.extended_search.proposition.selection',
2016 operators: [2053 operators: [
2017 {value: "=", text: _lt("is")},2054 {value: "=", text: _lt("is")},
2018 {value: "!=", text: _lt("is not")}2055 {value: "!=", text: _lt("is not")},
2056 {value: "∃", text: _lt("is set")},
2057 {value: "∄", text: _lt("is not set")}
2019 ],2058 ],
2020 toString: function () {2059 toString: function () {
2021 var select = this.$el[0];2060 var select = this.$el[0];