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>) | (<span class="username">{{ username }}</span>)
if Filter.members.isSelected _id if Filter.members.isSelected _id
i.fa.fa-check i.fa.fa-check
hr
ul.sidebar-list ul.sidebar-list
each currentBoard.customFields each currentBoard.customFields
li li
a.name.js-toggle-label-filter a.name.js-toggle-custom-fields-filter
span.sidebar-list-item-description span.sidebar-list-item-description
{{ name }} {{ name }}
if Filter.customFields.isSelected _id
i.fa.fa-check
if Filter.isActive if Filter.isActive
hr hr
a.sidebar-btn.js-clear-all a.sidebar-btn.js-clear-all

View file

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

View file

@ -86,8 +86,9 @@ Filter = {
// before changing the schema. // before changing the schema.
labelIds: new SetFilter(), labelIds: new SetFilter(),
members: 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 // 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 // implement this we keep the id of these cards in this `_exceptions` fields
@ -111,7 +112,13 @@ Filter = {
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(); if (fieldName === 'customFields'){
filterSelector[fieldName] = {_id: filter._getMongoSelector()};
}
else
{
filterSelector[fieldName] = filter._getMongoSelector();
}
emptySelector[fieldName] = filter._getEmptySelector(); emptySelector[fieldName] = filter._getEmptySelector();
if (emptySelector[fieldName] !== null) { if (emptySelector[fieldName] !== null) {
includeEmptySelectors = true; includeEmptySelectors = true;