Fix lint errors.

This commit is contained in:
Lauri Ojansivu 2018-06-14 20:14:43 +03:00
parent 94bd63c8a7
commit c46817f23a

View file

@ -149,11 +149,11 @@ class AdvancedFilter {
{ {
const found = CustomFields.findOne({ 'name': field }); const found = CustomFields.findOne({ 'name': field });
if (found.settings.dropdownItems && found.settings.dropdownItems.length > 0) if (found.settings.dropdownItems && found.settings.dropdownItems.length > 0)
{ {
for (let i = 0; i < found.settings.dropdownItems.length; i++) for (let i = 0; i < found.settings.dropdownItems.length; i++)
{ {
if (found.settings.dropdownItems[i].name === value) if (found.settings.dropdownItems[i].name === value)
{ {
return found.settings.dropdownItems[i]._id; return found.settings.dropdownItems[i]._id;
} }
} }
@ -179,27 +179,27 @@ class AdvancedFilter {
if (commands[i].cmd) { if (commands[i].cmd) {
switch (commands[i].cmd) { switch (commands[i].cmd) {
case '(': case '(':
{ {
level++; level++;
if (start === -1) start = i; if (start === -1) start = i;
continue; continue;
} }
case ')': case ')':
{ {
level--; level--;
commands.splice(i, 1);
i--;
continue;
}
default:
{
if (level > 0) {
subcommands.push(commands[i]);
commands.splice(i, 1); commands.splice(i, 1);
i--; i--;
continue; continue;
} }
default: }
{
if (level > 0) {
subcommands.push(commands[i]);
commands.splice(i, 1);
i--;
continue;
}
}
} }
} }
} }
@ -221,86 +221,86 @@ class AdvancedFilter {
case '=': case '=':
case '==': case '==':
case '===': case '===':
{ {
const field = commands[i - 1].cmd; const field = commands[i - 1].cmd;
const str = 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)]} }; 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, 1);
commands.splice(i, 1); commands.splice(i, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
case '!=': case '!=':
case '!==': case '!==':
{ {
const field = commands[i - 1].cmd; const field = commands[i - 1].cmd;
const str = 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)]} } }; 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, 1);
commands.splice(i, 1); commands.splice(i, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
case '>': case '>':
case 'gt': case 'gt':
case 'Gt': case 'Gt':
case 'GT': case 'GT':
{ {
const field = commands[i - 1].cmd; const field = commands[i - 1].cmd;
const str = commands[i + 1].cmd; const str = commands[i + 1].cmd;
commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gt: parseInt(str, 10) } }; commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gt: parseInt(str, 10) } };
commands.splice(i - 1, 1); commands.splice(i - 1, 1);
commands.splice(i, 1); commands.splice(i, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
case '>=': case '>=':
case '>==': case '>==':
case 'gte': case 'gte':
case 'Gte': case 'Gte':
case 'GTE': case 'GTE':
{ {
const field = commands[i - 1].cmd; const field = commands[i - 1].cmd;
const str = commands[i + 1].cmd; const str = commands[i + 1].cmd;
commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gte: parseInt(str, 10) } }; commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gte: parseInt(str, 10) } };
commands.splice(i - 1, 1); commands.splice(i - 1, 1);
commands.splice(i, 1); commands.splice(i, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
case '<': case '<':
case 'lt': case 'lt':
case 'Lt': case 'Lt':
case 'LT': case 'LT':
{ {
const field = commands[i - 1].cmd; const field = commands[i - 1].cmd;
const str = commands[i + 1].cmd; const str = commands[i + 1].cmd;
commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lt: parseInt(str, 10) } }; commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lt: parseInt(str, 10) } };
commands.splice(i - 1, 1); commands.splice(i - 1, 1);
commands.splice(i, 1); commands.splice(i, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
case '<=': case '<=':
case '<==': case '<==':
case 'lte': case 'lte':
case 'Lte': case 'Lte':
case 'LTE': case 'LTE':
{ {
const field = commands[i - 1].cmd; const field = commands[i - 1].cmd;
const str = commands[i + 1].cmd; const str = commands[i + 1].cmd;
commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lte: parseInt(str, 10) } }; commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lte: parseInt(str, 10) } };
commands.splice(i - 1, 1); commands.splice(i - 1, 1);
commands.splice(i, 1); commands.splice(i, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
} }
} }
@ -316,44 +316,44 @@ class AdvancedFilter {
case 'OR': case 'OR':
case '|': case '|':
case '||': case '||':
{ {
const op1 = commands[i - 1]; const op1 = commands[i - 1];
const op2 = commands[i + 1]; const op2 = commands[i + 1];
commands[i] = { $or: [op1, op2] }; commands[i] = { $or: [op1, op2] };
commands.splice(i - 1, 1); commands.splice(i - 1, 1);
commands.splice(i, 1); commands.splice(i, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
case 'and': case 'and':
case 'And': case 'And':
case 'AND': case 'AND':
case '&': case '&':
case '&&': case '&&':
{ {
const op1 = commands[i - 1]; const op1 = commands[i - 1];
const op2 = commands[i + 1]; const op2 = commands[i + 1];
commands[i] = { $and: [op1, op2] }; commands[i] = { $and: [op1, op2] };
commands.splice(i - 1, 1); commands.splice(i - 1, 1);
commands.splice(i, 1); commands.splice(i, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
case 'not': case 'not':
case 'Not': case 'Not':
case 'NOT': case 'NOT':
case '!': case '!':
{ {
const op1 = commands[i + 1]; const op1 = commands[i + 1];
commands[i] = { $not: op1 }; commands[i] = { $not: op1 };
commands.splice(i + 1, 1); commands.splice(i + 1, 1);
//changed = true; //changed = true;
i--; i--;
break; break;
} }
} }
} }