Filter on custom fields presence

This commit is contained in:
IgnatzHome 2018-05-19 14:51:01 +02:00
parent 1ab4f5b913
commit 78317ef792
3 changed files with 18 additions and 3 deletions

View file

@ -40,12 +40,15 @@ template(name="filterSidebar")
| (<span class="username">{{ username }}</span>)
if Filter.members.isSelected _id
i.fa.fa-check
hr
ul.sidebar-list
each currentBoard.customFields
li
a.name.js-toggle-label-filter
a.name.js-toggle-custom-fields-filter
span.sidebar-list-item-description
{{ name }}
if Filter.customFields.isSelected _id
i.fa.fa-check
if Filter.isActive
hr
a.sidebar-btn.js-clear-all

View file

@ -11,6 +11,11 @@ BlazeComponent.extendComponent({
Filter.members.toggle(this.currentData()._id);
Filter.resetExceptions();
},
'click .js-toggle-custom-fields-filter'(evt) {
evt.preventDefault();
Filter.customFields.toggle(this.currentData()._id);
Filter.resetExceptions();
},
'click .js-clear-all'(evt) {
evt.preventDefault();
Filter.reset();

View file

@ -86,8 +86,9 @@ Filter = {
// before changing the schema.
labelIds: new SetFilter(),
members: new SetFilter(),
customFields: new SetFilter(),
_fields: ['labelIds', 'members'],
_fields: ['labelIds', 'members', 'customFields'],
// We don't filter cards that have been added after the last filter change. To
// implement this we keep the id of these cards in this `_exceptions` fields
@ -111,7 +112,13 @@ Filter = {
this._fields.forEach((fieldName) => {
const filter = this[fieldName];
if (filter._isActive()) {
filterSelector[fieldName] = filter._getMongoSelector();
if (fieldName === 'customFields'){
filterSelector[fieldName] = {_id: filter._getMongoSelector()};
}
else
{
filterSelector[fieldName] = filter._getMongoSelector();
}
emptySelector[fieldName] = filter._getEmptySelector();
if (emptySelector[fieldName] !== null) {
includeEmptySelectors = true;