diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-06-14 22:51:43 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2018-06-14 22:51:43 +0300 |
commit | 3e686e4379eece4e4e429cb9e9cc587f9a12459c (patch) | |
tree | 1a2b869894404825de12c13e9db30bd6994713bc | |
parent | 1214af04a9bdaad4390d6f3eb157f5dd430ab48a (diff) | |
parent | 8509dad58f14817fc2b0bcb6b19623673de4ff16 (diff) | |
download | wekan-3e686e4379eece4e4e429cb9e9cc587f9a12459c.tar.gz wekan-3e686e4379eece4e4e429cb9e9cc587f9a12459c.tar.bz2 wekan-3e686e4379eece4e4e429cb9e9cc587f9a12459c.zip |
Merge branch 'feature-custom-fields' of https://github.com/feuerball11/wekan into feuerball11-feature-custom-fields
-rw-r--r-- | client/lib/filter.js | 44 | ||||
-rw-r--r-- | i18n/en.i18n.json | 2 |
2 files changed, 40 insertions, 6 deletions
diff --git a/client/lib/filter.js b/client/lib/filter.js index e3658e1e..a4e58692 100644 --- a/client/lib/filter.js +++ b/client/lib/filter.js @@ -109,12 +109,20 @@ class AdvancedFilter { const commands = []; let current = ''; let string = false; + let regex = false; let wasString = false; let ignore = false; for (let i = 0; i < this._filter.length; i++) { const char = this._filter.charAt(i); if (ignore) { ignore = false; + current += char; + continue; + } + if (char === '/'){ + string = !string; + if (string) regex = true; + current += char; continue; } if (char === '\'') { @@ -122,12 +130,12 @@ class AdvancedFilter { if (string) wasString = true; continue; } - if (char === '\\') { + if (char === '\\' && !string) { ignore = true; continue; } if (char === ' ' && !string) { - commands.push({ 'cmd': current, 'string': wasString }); + commands.push({ 'cmd': current, 'string': wasString, regex}); wasString = false; current = ''; continue; @@ -135,7 +143,7 @@ class AdvancedFilter { current += char; } if (current !== '') { - commands.push({ 'cmd': current, 'string': wasString }); + commands.push({ 'cmd': current, 'string': wasString, regex}); } return commands; } @@ -224,7 +232,20 @@ class AdvancedFilter { { const field = commands[i - 1].cmd; const str = commands[i + 1].cmd; - commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} }; + if (commands[i + 1].regex) + { + const match = str.match(new RegExp('^/(.*?)/([gimy]*)$')); + let regex = null; + if (match.length > 2) + regex = new RegExp(match[1], match[2]); + else + regex = new RegExp(match[1]); + commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': regex }; + } + else + { + commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} }; + } commands.splice(i - 1, 1); commands.splice(i, 1); //changed = true; @@ -236,7 +257,20 @@ class AdvancedFilter { { const field = commands[i - 1].cmd; const str = commands[i + 1].cmd; - commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} } }; + if (commands[i + 1].regex) + { + const match = str.match(new RegExp('^/(.*?)/([gimy]*)$')); + let regex = null; + if (match.length > 2) + regex = new RegExp(match[1], match[2]); + else + regex = new RegExp(match[1]); + commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: regex } }; + } + else + { + commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} } }; + } commands.splice(i - 1, 1); commands.splice(i, 1); //changed = true; diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index cd74b6ac..49a66fee 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -247,7 +247,7 @@ "filter-on-desc": "You are filtering cards on this board. Click here to edit filter.", "filter-to-selection": "Filter to selection", "advanced-filter-label": "Advanced Filter", - "advanced-filter-description": "Advanced Filter allows to write a string containing following operators: == != <= >= && || ( ) A space is used as a separator between the Operators. You can filter for all Custom Fields by typing their names and values. For Example: Field1 == Value1. Note: If fields or values contains spaces, you need to encapsulate them into single quotes. For Example: 'Field 1' == 'Value 1'. Also you can combine multiple conditions. For Example: F1 == V1 || F1 = V2. Normally all operators are interpreted from left to right. You can change the order by placing brackets. For Example: F1 == V1 and ( F2 == V2 || F2 == V3 )", + "advanced-filter-description": "Advanced Filter allows to write a string containing following operators: == != <= >= && || ( ) A space is used as a separator between the Operators. You can filter for all Custom Fields by typing their names and values. For Example: Field1 == Value1. Note: If fields or values contains spaces, you need to encapsulate them into single quotes. For Example: 'Field 1' == 'Value 1'. For single controll characters (' \\/) to be skipped, you can use \\. For example: Field1 = I\\'m. Also you can combine multiple conditions. For Example: F1 == V1 || F1 = V2. Normally all operators are interpreted from left to right. You can change the order by placing brackets. For Example: F1 == V1 and ( F2 == V2 || F2 == V3 ). Also you can search text fields using regex: F1 == /Tes.*/i ", "fullname": "Full Name", "header-logo-title": "Go back to your boards page.", "hide-system-messages": "Hide system messages", |