summaryrefslogtreecommitdiffstats
path: root/client/lib
diff options
context:
space:
mode:
authorIgnatz <computer-freak94@gmx.de>2018-06-14 12:41:16 +0200
committerIgnatz <computer-freak94@gmx.de>2018-06-14 12:41:16 +0200
commit571f55f904a9d37dec5895472439dbeadc5b82b2 (patch)
treee09285fcf5517d2b8a7d3d8673e3a2b94f099905 /client/lib
parent259614b647c72773675541d3de8d0ff73006c299 (diff)
downloadwekan-571f55f904a9d37dec5895472439dbeadc5b82b2.tar.gz
wekan-571f55f904a9d37dec5895472439dbeadc5b82b2.tar.bz2
wekan-571f55f904a9d37dec5895472439dbeadc5b82b2.zip
fixing search for dropdown fields, and error on loading board
Diffstat (limited to 'client/lib')
-rw-r--r--client/lib/filter.js206
1 files changed, 111 insertions, 95 deletions
diff --git a/client/lib/filter.js b/client/lib/filter.js
index fa139cfe..db353ee6 100644
--- a/client/lib/filter.js
+++ b/client/lib/filter.js
@@ -145,6 +145,22 @@ class AdvancedFilter {
return found._id;
}
+ _fieldValueToId(field, value)
+ {
+ const found = CustomFields.findOne({ 'name': field });
+ if (found.settings.dropdownItems && found.settings.dropdownItems.length > 0)
+ {
+ for (let i = 0; i < found.settings.dropdownItems.length; i++)
+ {
+ if (found.settings.dropdownItems[i].name === value)
+ {
+ return found.settings.dropdownItems[i]._id;
+ }
+ }
+ }
+ return value;
+ }
+
_arrayToSelector(commands) {
try {
//let changed = false;
@@ -163,27 +179,27 @@ class AdvancedFilter {
if (commands[i].cmd) {
switch (commands[i].cmd) {
case '(':
- {
- level++;
- if (start === -1) start = i;
- continue;
- }
+ {
+ level++;
+ if (start === -1) start = i;
+ continue;
+ }
case ')':
- {
- level--;
- commands.splice(i, 1);
- i--;
- continue;
- }
- default:
- {
- if (level > 0) {
- subcommands.push(commands[i]);
+ {
+ level--;
commands.splice(i, 1);
i--;
continue;
}
- }
+ default:
+ {
+ if (level > 0) {
+ subcommands.push(commands[i]);
+ commands.splice(i, 1);
+ i--;
+ continue;
+ }
+ }
}
}
}
@@ -205,86 +221,86 @@ class AdvancedFilter {
case '=':
case '==':
case '===':
- {
- const field = commands[i - 1].cmd;
- const str = commands[i + 1].cmd;
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': str };
- commands.splice(i - 1, 1);
- commands.splice(i, 1);
+ {
+ const field = commands[i - 1].cmd;
+ const str = commands[i + 1].cmd;
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': this._fieldValueToId(str) };
+ commands.splice(i - 1, 1);
+ commands.splice(i, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
case '!=':
case '!==':
- {
- const field = commands[i - 1].cmd;
- const str = commands[i + 1].cmd;
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: str } };
- commands.splice(i - 1, 1);
- commands.splice(i, 1);
+ {
+ const field = commands[i - 1].cmd;
+ const str = commands[i + 1].cmd;
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: this._fieldValueToId(str) } };
+ commands.splice(i - 1, 1);
+ commands.splice(i, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
case '>':
case 'gt':
case 'Gt':
case 'GT':
- {
- const field = commands[i - 1].cmd;
- const str = commands[i + 1].cmd;
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gt: str } };
- commands.splice(i - 1, 1);
- commands.splice(i, 1);
+ {
+ const field = commands[i - 1].cmd;
+ const str = commands[i + 1].cmd;
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gt: str } };
+ commands.splice(i - 1, 1);
+ commands.splice(i, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
case '>=':
case '>==':
case 'gte':
case 'Gte':
case 'GTE':
- {
- const field = commands[i - 1].cmd;
- const str = commands[i + 1].cmd;
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gte: str } };
- commands.splice(i - 1, 1);
- commands.splice(i, 1);
+ {
+ const field = commands[i - 1].cmd;
+ const str = commands[i + 1].cmd;
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gte: str } };
+ commands.splice(i - 1, 1);
+ commands.splice(i, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
case '<':
case 'lt':
case 'Lt':
case 'LT':
- {
- const field = commands[i - 1].cmd;
- const str = commands[i + 1].cmd;
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lt: str } };
- commands.splice(i - 1, 1);
- commands.splice(i, 1);
+ {
+ const field = commands[i - 1].cmd;
+ const str = commands[i + 1].cmd;
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lt: str } };
+ commands.splice(i - 1, 1);
+ commands.splice(i, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
case '<=':
case '<==':
case 'lte':
case 'Lte':
case 'LTE':
- {
- const field = commands[i - 1].cmd;
- const str = commands[i + 1].cmd;
- commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lte: str } };
- commands.splice(i - 1, 1);
- commands.splice(i, 1);
+ {
+ const field = commands[i - 1].cmd;
+ const str = commands[i + 1].cmd;
+ commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lte: str } };
+ commands.splice(i - 1, 1);
+ commands.splice(i, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
}
}
@@ -300,44 +316,44 @@ class AdvancedFilter {
case 'OR':
case '|':
case '||':
- {
- const op1 = commands[i - 1];
- const op2 = commands[i + 1];
- commands[i] = { $or: [op1, op2] };
- commands.splice(i - 1, 1);
- commands.splice(i, 1);
+ {
+ const op1 = commands[i - 1];
+ const op2 = commands[i + 1];
+ commands[i] = { $or: [op1, op2] };
+ commands.splice(i - 1, 1);
+ commands.splice(i, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
case 'and':
case 'And':
case 'AND':
case '&':
case '&&':
- {
- const op1 = commands[i - 1];
- const op2 = commands[i + 1];
- commands[i] = { $and: [op1, op2] };
- commands.splice(i - 1, 1);
- commands.splice(i, 1);
+ {
+ const op1 = commands[i - 1];
+ const op2 = commands[i + 1];
+ commands[i] = { $and: [op1, op2] };
+ commands.splice(i - 1, 1);
+ commands.splice(i, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
case 'not':
case 'Not':
case 'NOT':
case '!':
- {
- const op1 = commands[i + 1];
- commands[i] = { $not: op1 };
- commands.splice(i + 1, 1);
+ {
+ const op1 = commands[i + 1];
+ commands[i] = { $not: op1 };
+ commands.splice(i + 1, 1);
//changed = true;
- i--;
- break;
- }
+ i--;
+ break;
+ }
}
}