Merge branch 'feature-custom-fields-filter' of https://github.com/feuerball11/wekan into feuerball11-feature-custom-fields-filter

This commit is contained in:
Lauri Ojansivu 2018-05-19 17:39:05 +03:00
commit 7dfec58128
4 changed files with 35 additions and 3 deletions

View file

@ -40,6 +40,21 @@ template(name="filterSidebar")
| (<span class="username">{{ username }}</span>)
if Filter.members.isSelected _id
i.fa.fa-check
hr
ul.sidebar-list
li(class="{{#if Filter.customFields.isSelected undefined}}active{{/if}}")
a.name.js-toggle-custom-fields-filter
span.sidebar-list-item-description
| {{_ 'filter-no-custom-fields'}}
if Filter.customFields.isSelected undefined
i.fa.fa-check
each currentBoard.customFields
li(class="{{#if Filter.customFields.isSelected _id}}active{{/if}}")
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

@ -10,10 +10,13 @@ function showFilterSidebar() {
// Use a "set" filter for a field that is a set of documents uniquely
// identified. For instance `{ labels: ['labelA', 'labelC', 'labelD'] }`.
// use "subField" for searching inside object Fields.
// For instance '{ 'customFields._id': ['field1','field2']} (subField would be: _id)
class SetFilter {
constructor() {
constructor(subField = '') {
this._dep = new Tracker.Dependency();
this._selectedElements = [];
this.subField = subField;
}
isSelected(val) {
@ -86,8 +89,9 @@ Filter = {
// before changing the schema.
labelIds: new SetFilter(),
members: new SetFilter(),
customFields: new SetFilter('_id'),
_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 +115,14 @@ Filter = {
this._fields.forEach((fieldName) => {
const filter = this[fieldName];
if (filter._isActive()) {
filterSelector[fieldName] = filter._getMongoSelector();
if (filter.subField !== '')
{
filterSelector[`${fieldName}.${filter.subField}`] = filter._getMongoSelector();
}
else
{
filterSelector[fieldName] = filter._getMongoSelector();
}
emptySelector[fieldName] = filter._getEmptySelector();
if (emptySelector[fieldName] !== null) {
includeEmptySelectors = true;

View file

@ -242,6 +242,7 @@
"filter-clear": "Clear filter",
"filter-no-label": "No label",
"filter-no-member": "No member",
"filter-no-custom-fields": "No Custom Fields",
"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",