summaryrefslogtreecommitdiffstats
path: root/client/lib
diff options
context:
space:
mode:
authorMario Orlicky <orlickymario@gmail.com>2016-11-13 20:38:14 +0100
committerMario Orlicky <orlickymario@gmail.com>2016-11-13 20:38:14 +0100
commit5a23c962d2d2c8a4ef3f30a3b0965039808924e8 (patch)
tree8d44263c463fdd2ede4d6ec04f94de340c0135c8 /client/lib
parent300b40ed87fd3603a00888f83f19c588d2868273 (diff)
downloadwekan-5a23c962d2d2c8a4ef3f30a3b0965039808924e8.tar.gz
wekan-5a23c962d2d2c8a4ef3f30a3b0965039808924e8.tar.bz2
wekan-5a23c962d2d2c8a4ef3f30a3b0965039808924e8.zip
Filtering logic by empty labels/members
Diffstat (limited to 'client/lib')
-rw-r--r--client/lib/filter.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/client/lib/filter.js b/client/lib/filter.js
index 74305284..656f5fe2 100644
--- a/client/lib/filter.js
+++ b/client/lib/filter.js
@@ -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) {