summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorIgnatzHome <ignatz@maschath.de>2018-05-19 15:21:12 +0200
committerIgnatzHome <ignatz@maschath.de>2018-05-19 15:21:12 +0200
commitcbdb7b4f64f0b620cfa924a1f80a8f1f0191f997 (patch)
tree20fd346df01549f59cca1278c276f749fce82bfc /client
parent78317ef792c0de7435bbb8a0d3f6b413b2af9ab1 (diff)
downloadwekan-cbdb7b4f64f0b620cfa924a1f80a8f1f0191f997.tar.gz
wekan-cbdb7b4f64f0b620cfa924a1f80a8f1f0191f997.tar.bz2
wekan-cbdb7b4f64f0b620cfa924a1f80a8f1f0191f997.zip
Correcting constructed mongoSelector
Diffstat (limited to 'client')
-rw-r--r--client/lib/filter.js31
1 files changed, 21 insertions, 10 deletions
diff --git a/client/lib/filter.js b/client/lib/filter.js
index 27492125..d57f3e78 100644
--- a/client/lib/filter.js
+++ b/client/lib/filter.js
@@ -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'}]} (subField would be: _id)
class SetFilter {
- constructor() {
+ constructor(subField = '') {
this._dep = new Tracker.Dependency();
this._selectedElements = [];
+ this.subField = subField;
}
isSelected(val) {
@@ -61,7 +64,21 @@ class SetFilter {
_getMongoSelector() {
this._dep.depend();
- return { $in: this._selectedElements };
+ if (this.subField !== '')
+ {
+
+ const selector = [];
+ this._selectedElements.forEach((element) => {
+ const item = [];
+ item[this.subField] = element;
+ selector.push(item);
+ });
+ return {$in: selector};
+ }
+ else
+ {
+ return { $in: this._selectedElements };
+ }
}
_getEmptySelector() {
@@ -86,7 +103,7 @@ Filter = {
// before changing the schema.
labelIds: new SetFilter(),
members: new SetFilter(),
- customFields: new SetFilter(),
+ customFields: new SetFilter('_id'),
_fields: ['labelIds', 'members', 'customFields'],
@@ -112,13 +129,7 @@ Filter = {
this._fields.forEach((fieldName) => {
const filter = this[fieldName];
if (filter._isActive()) {
- if (fieldName === 'customFields'){
- filterSelector[fieldName] = {_id: filter._getMongoSelector()};
- }
- else
- {
- filterSelector[fieldName] = filter._getMongoSelector();
- }
+ filterSelector[fieldName] = filter._getMongoSelector();
emptySelector[fieldName] = filter._getEmptySelector();
if (emptySelector[fieldName] !== null) {
includeEmptySelectors = true;