summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorIgnatzHome <ignatz@maschath.de>2018-05-20 09:47:20 +0200
committerIgnatzHome <ignatz@maschath.de>2018-05-20 09:47:20 +0200
commit9ac1164440b70de6480d55a0814198aad5e6d779 (patch)
tree059ace20ffae4e0db1ac021df81a13a5a12507f8 /client
parent39974c953247190fe373a583830d1ec3bc6899f7 (diff)
downloadwekan-9ac1164440b70de6480d55a0814198aad5e6d779.tar.gz
wekan-9ac1164440b70de6480d55a0814198aad5e6d779.tar.bz2
wekan-9ac1164440b70de6480d55a0814198aad5e6d779.zip
Testing 'or' condition for advanced Filter
Diffstat (limited to 'client')
-rw-r--r--client/lib/filter.js79
1 files changed, 57 insertions, 22 deletions
diff --git a/client/lib/filter.js b/client/lib/filter.js
index 790e4f49..84b10648 100644
--- a/client/lib/filter.js
+++ b/client/lib/filter.js
@@ -147,7 +147,7 @@ class AdvancedFilter {
_fieldNameToId(field)
{
- console.log("searching: "+field);
+ console.log(`searching: ${field}`);
const found = CustomFields.findOne({'name':field});
console.log(found);
return found._id;
@@ -158,32 +158,67 @@ class AdvancedFilter {
console.log(commands);
try {
//let changed = false;
- for (let i = 0; i < commands.length; i++)
+ this._processConditions(commands);
+ this._processLogicalOperators(commands);
+ }
+ catch (e){return { $in: [] };}
+ return {$or: commands};
+ }
+
+ _processConditions(commands)
+ {
+ for (let i = 0; i < commands.length; i++)
+ {
+ if (!commands[i].string && commands[i].cmd)
{
- if (!commands[i].string && commands[i].cmd)
+ switch (commands[i].cmd)
+ {
+ case '=':
+ case '==':
+ case '===':
{
- switch (commands[i].cmd)
- {
- 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);
- //changed = true;
- i--;
- break;
- }
-
- }
+ 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);
+ //changed = true;
+ i--;
+ break;
+ }
+
+ }
+ }
+ }
+ }
+
+ _processLogicalOperators(commands)
+ {
+ for (let i = 0; i < commands.length; i++)
+ {
+ if (!commands[i].string && commands[i].cmd)
+ {
+ switch (commands[i].cmd)
+ {
+ case 'or':
+ case 'Or':
+ case 'OR':
+ case '|':
+ case '||':
+ {
+ const op1 = commands[i-1].cmd;
+ const op2 = commands[i+1].cmd;
+ commands[i] = {$or: [op1, op2]};
+ commands.splice(i-1, 1);
+ commands.splice(i, 1);
+ //changed = true;
+ i--;
+ break;
+ }
+
}
}
}
- catch (e){return { $in: [] };}
- return {$or: commands};
}
_getMongoSelector() {