mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 05:27:14 -04:00
Filtering logic by empty labels/members
This commit is contained in:
parent
300b40ed87
commit
5a23c962d2
1 changed files with 24 additions and 3 deletions
|
@ -61,7 +61,18 @@ class SetFilter {
|
|||
|
||||
_getMongoSelector() {
|
||||
this._dep.depend();
|
||||
return { $in: this._selectedElements };
|
||||
return { $in: this._selectedElements }
|
||||
}
|
||||
|
||||
_getEmptySelector() {
|
||||
this._dep.depend();
|
||||
let includeEmpty = false
|
||||
this._selectedElements.forEach((el) => {
|
||||
if (el == undefined) {
|
||||
includeEmpty = true;
|
||||
}
|
||||
});
|
||||
return includeEmpty ? { $eq: [] } : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,16 +106,26 @@ Filter = {
|
|||
return {};
|
||||
|
||||
const filterSelector = {};
|
||||
const emptySelector = {};
|
||||
let includeEmptySelectors = false;
|
||||
this._fields.forEach((fieldName) => {
|
||||
const filter = this[fieldName];
|
||||
if (filter._isActive())
|
||||
if (filter._isActive()) {
|
||||
filterSelector[fieldName] = filter._getMongoSelector();
|
||||
emptySelector[fieldName] = filter._getEmptySelector();
|
||||
if (emptySelector[fieldName] != null) {
|
||||
includeEmptySelectors = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const exceptionsSelector = {_id: {$in: this._exceptions}};
|
||||
this._exceptionsDep.depend();
|
||||
|
||||
return {$or: [filterSelector, exceptionsSelector]};
|
||||
if (includeEmptySelectors)
|
||||
return {$or: [filterSelector, exceptionsSelector, emptySelector]};
|
||||
else
|
||||
return {$or: [filterSelector, exceptionsSelector]};
|
||||
},
|
||||
|
||||
mongoSelector(additionalSelector) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue