mirror of
https://github.com/wekan/wekan.git
synced 2026-02-04 07:31:47 +01:00
Merge pull request #6 from mario-orlicky/filter-by-empty
Filter by empty
This commit is contained in:
commit
fa6267cf44
3 changed files with 37 additions and 2 deletions
|
|
@ -5,6 +5,12 @@
|
|||
|
||||
template(name="filterSidebar")
|
||||
ul.sidebar-list
|
||||
li(class="{{#if Filter.labelIds.isSelected undefined}}active{{/if}}")
|
||||
a.name.js-toggle-label-filter
|
||||
span.sidebar-list-item-description
|
||||
{{_ 'filter-no-label'}}
|
||||
if Filter.labelIds.isSelected undefined
|
||||
i.fa.fa-check
|
||||
each currentBoard.labels
|
||||
li
|
||||
a.name.js-toggle-label-filter
|
||||
|
|
@ -18,6 +24,12 @@ template(name="filterSidebar")
|
|||
i.fa.fa-check
|
||||
hr
|
||||
ul.sidebar-list
|
||||
li(class="{{#if Filter.members.isSelected undefined}}active{{/if}}")
|
||||
a.name.js-toggle-member-filter
|
||||
span.sidebar-list-item-description
|
||||
{{_ 'filter-no-member'}}
|
||||
if Filter.members.isSelected undefined
|
||||
i.fa.fa-check
|
||||
each currentBoard.activeMembers
|
||||
with getUser userId
|
||||
li(class="{{#if Filter.members.isSelected _id}}active{{/if}}")
|
||||
|
|
|
|||
|
|
@ -63,6 +63,17 @@ class SetFilter {
|
|||
this._dep.depend();
|
||||
return { $in: this._selectedElements };
|
||||
}
|
||||
|
||||
_getEmptySelector() {
|
||||
this._dep.depend();
|
||||
let includeEmpty = false
|
||||
this._selectedElements.forEach((el) => {
|
||||
if (el == undefined) {
|
||||
includeEmpty = true;
|
||||
}
|
||||
});
|
||||
return includeEmpty ? { $eq: [] } : null;
|
||||
}
|
||||
}
|
||||
|
||||
// The global Filter object.
|
||||
|
|
@ -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