[IMP] make filtergroups [OR] their component filters instead of [AND]-ing them

bzr revid: xmo@openerp.com-20110915084626-9rxv8jv65uxtq9ga
This commit is contained in:
Xavier Morel 2011-09-15 10:46:26 +02:00
parent 6af24261ba
commit 81e6707b91
1 changed files with 48 additions and 30 deletions

View File

@ -463,30 +463,6 @@ openerp.web.search.Widget = openerp.web.Widget.extend( /** @lends openerp.web.se
}));
}
});
openerp.web.search.FilterGroup = openerp.web.search.Widget.extend(/** @lends openerp.web.search.FilterGroup# */{
template: 'SearchView.filters',
/**
* Inclusive group of filters, creates a continuous "button" with clickable
* sections (the normal display for filters is to be a self-contained button)
*
* @constructs openerp.web.search.FilterGroup
* @extends openerp.web.search.Widget
*
* @param {Array<openerp.web.search.Filter>} filters elements of the group
* @param {openerp.web.SearchView} view view in which the filters are contained
*/
init: function (filters, view) {
this._super(view);
this.filters = filters;
this.length = filters.length;
},
start: function () {
this._super();
_.each(this.filters, function (filter) {
filter.start();
});
}
});
openerp.web.search.add_expand_listener = function($root) {
$root.find('a.searchview_group_string').click(function (e) {
$root.toggleClass('folded expanded');
@ -533,6 +509,49 @@ openerp.web.search.Input = openerp.web.search.Widget.extend( /** @lends openerp.
"get_domain not implemented for widget " + this.attrs.type);
}
});
openerp.web.search.FilterGroup = openerp.web.search.Input.extend(/** @lends openerp.web.search.FilterGroup# */{
template: 'SearchView.filters',
/**
* Inclusive group of filters, creates a continuous "button" with clickable
* sections (the normal display for filters is to be a self-contained button)
*
* @constructs openerp.web.search.FilterGroup
* @extends openerp.web.search.Input
*
* @param {Array<openerp.web.search.Filter>} filters elements of the group
* @param {openerp.web.SearchView} view view in which the filters are contained
*/
init: function (filters, view) {
this._super(view);
this.filters = filters;
this.length = filters.length;
},
start: function () {
this._super();
_.each(this.filters, function (filter) {
filter.start();
});
},
get_context: function () { },
/**
* Handles domains-fetching for all the filters within it: groups them.
*/
get_domain: function () {
var domains = _(this.filters).chain()
.filter(function (filter) { return filter.is_enabled(); })
.map(function (filter) { return filter.attrs.domain; })
.value();
if (!domains.length) { return; }
if (domains.length === 1) { return domains[0]; }
for (var i=domains.length; --i;) {
domains.unshift(['|']);
}
return _.extend(new openerp.web.CompoundDomain(), {
__domains: domains
});
}
});
openerp.web.search.Filter = openerp.web.search.Input.extend(/** @lends openerp.web.search.Filter# */{
template: 'SearchView.filter',
/**
@ -586,12 +605,11 @@ openerp.web.search.Filter = openerp.web.search.Input.extend(/** @lends openerp.w
}
return this.attrs.context;
},
get_domain: function () {
if (!this.is_enabled()) {
return;
}
return this.attrs.domain;
}
/**
* Does not return anything: filter domain is handled at the FilterGroup
* level
*/
get_domain: function () { }
});
openerp.web.search.Field = openerp.web.search.Input.extend( /** @lends openerp.web.search.Field# */ {
template: 'SearchView.field',