diff options
author | Lauri Ojansivu <x@xet7.org> | 2016-11-15 23:46:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-15 23:46:58 +0200 |
commit | fa6267cf44c8648a828072dcf7c2138255f97bc7 (patch) | |
tree | d9060484993f469e702a21e9959614e6b62e6042 | |
parent | 0733fd64eee199633092702bb6bd330a38352f19 (diff) | |
parent | 4dc0ec07b8560d0814ed5cb72b2cac93722bb93c (diff) | |
download | wekan-fa6267cf44c8648a828072dcf7c2138255f97bc7.tar.gz wekan-fa6267cf44c8648a828072dcf7c2138255f97bc7.tar.bz2 wekan-fa6267cf44c8648a828072dcf7c2138255f97bc7.zip |
Merge pull request #6 from mario-orlicky/filter-by-empty
Filter by empty
-rw-r--r-- | client/components/sidebar/sidebarFilters.jade | 12 | ||||
-rw-r--r-- | client/lib/filter.js | 25 | ||||
-rwxr-xr-x | i18n/en.i18n.json | 2 |
3 files changed, 37 insertions, 2 deletions
diff --git a/client/components/sidebar/sidebarFilters.jade b/client/components/sidebar/sidebarFilters.jade index 2b326493..deefde82 100644 --- a/client/components/sidebar/sidebarFilters.jade +++ b/client/components/sidebar/sidebarFilters.jade @@ -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}}") diff --git a/client/lib/filter.js b/client/lib/filter.js index 74305284..afa992ab 100644 --- a/client/lib/filter.js +++ b/client/lib/filter.js @@ -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) { diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index f9cf7e82..c92d6a71 100755 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -173,6 +173,8 @@ "filter": "Filter", "filter-cards": "Filter Cards", "filter-clear": "Clear filter", + "filter-no-label": "No label", + "filter-no-member": "No member", "filter-on": "Filter is on", "filter-on-desc": "You are filtering cards on this board. Click here to edit filter.", "filter-to-selection": "Filter to selection", |