mirror of
https://github.com/wekan/wekan.git
synced 2025-12-19 17:00:13 +01: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() {
|
_getMongoSelector() {
|
||||||
this._dep.depend();
|
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 {};
|
return {};
|
||||||
|
|
||||||
const filterSelector = {};
|
const filterSelector = {};
|
||||||
|
const emptySelector = {};
|
||||||
|
let includeEmptySelectors = false;
|
||||||
this._fields.forEach((fieldName) => {
|
this._fields.forEach((fieldName) => {
|
||||||
const filter = this[fieldName];
|
const filter = this[fieldName];
|
||||||
if (filter._isActive())
|
if (filter._isActive()) {
|
||||||
filterSelector[fieldName] = filter._getMongoSelector();
|
filterSelector[fieldName] = filter._getMongoSelector();
|
||||||
|
emptySelector[fieldName] = filter._getEmptySelector();
|
||||||
|
if (emptySelector[fieldName] != null) {
|
||||||
|
includeEmptySelectors = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const exceptionsSelector = {_id: {$in: this._exceptions}};
|
const exceptionsSelector = {_id: {$in: this._exceptions}};
|
||||||
this._exceptionsDep.depend();
|
this._exceptionsDep.depend();
|
||||||
|
|
||||||
return {$or: [filterSelector, exceptionsSelector]};
|
if (includeEmptySelectors)
|
||||||
|
return {$or: [filterSelector, exceptionsSelector, emptySelector]};
|
||||||
|
else
|
||||||
|
return {$or: [filterSelector, exceptionsSelector]};
|
||||||
},
|
},
|
||||||
|
|
||||||
mongoSelector(additionalSelector) {
|
mongoSelector(additionalSelector) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue