lint corrections

This commit is contained in:
Ignatz 2018-05-23 11:04:12 +02:00
parent 0195044ba1
commit 3d1f004e90

View file

@ -89,8 +89,7 @@ class AdvancedFilter {
this._lastValide = {};
}
set(str)
{
set(str) {
this._filter = str;
this._dep.changed();
}
@ -112,27 +111,22 @@ class AdvancedFilter {
let string = false;
let wasString = false;
let ignore = false;
for (let i = 0; i < this._filter.length; i++)
{
for (let i = 0; i < this._filter.length; i++) {
const char = this._filter.charAt(i);
if (ignore)
{
if (ignore) {
ignore = false;
continue;
}
if (char === '\'')
{
if (char === '\'') {
string = !string;
if (string) wasString = true;
continue;
}
if (char === '\\')
{
if (char === '\\') {
ignore = true;
continue;
}
if (char === ' ' && !string)
{
if (char === ' ' && !string) {
commands.push({ 'cmd': current, 'string': wasString });
wasString = false;
current = '';
@ -140,21 +134,18 @@ class AdvancedFilter {
}
current += char;
}
if (current !== '')
{
if (current !== '') {
commands.push({ 'cmd': current, 'string': wasString });
}
return commands;
}
_fieldNameToId(field)
{
_fieldNameToId(field) {
const found = CustomFields.findOne({ 'name': field });
return found._id;
}
_arrayToSelector(commands)
{
_arrayToSelector(commands) {
try {
//let changed = false;
this._processSubCommands(commands);
@ -164,17 +155,13 @@ class AdvancedFilter {
return { $or: commands };
}
_processSubCommands(commands)
{
_processSubCommands(commands) {
const subcommands = [];
let level = 0;
let start = -1;
for (let i = 0; i < commands.length; i++)
{
if (commands[i].cmd)
{
switch (commands[i].cmd)
{
for (let i = 0; i < commands.length; i++) {
if (commands[i].cmd) {
switch (commands[i].cmd) {
case '(':
{
level++;
@ -190,8 +177,7 @@ class AdvancedFilter {
}
default:
{
if (level > 0)
{
if (level > 0) {
subcommands.push(commands[i]);
commands.splice(i, 1);
i--;
@ -201,8 +187,7 @@ class AdvancedFilter {
}
}
}
if (start !== -1)
{
if (start !== -1) {
this._processSubCommands(subcommands);
if (subcommands.length === 1)
commands.splice(start, 0, subcommands[0]);
@ -213,14 +198,10 @@ class AdvancedFilter {
this._processLogicalOperators(commands);
}
_processConditions(commands)
{
for (let i = 0; i < commands.length; i++)
{
if (!commands[i].string && commands[i].cmd)
{
switch (commands[i].cmd)
{
_processConditions(commands) {
for (let i = 0; i < commands.length; i++) {
if (!commands[i].string && commands[i].cmd) {
switch (commands[i].cmd) {
case '=':
case '==':
case '===':
@ -310,14 +291,10 @@ class AdvancedFilter {
}
}
_processLogicalOperators(commands)
{
for (let i = 0; i < commands.length; i++)
{
if (!commands[i].string && commands[i].cmd)
{
switch (commands[i].cmd)
{
_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':
@ -412,12 +389,10 @@ Filter = {
this._fields.forEach((fieldName) => {
const filter = this[fieldName];
if (filter._isActive()) {
if (filter.subField !== '')
{
if (filter.subField !== '') {
filterSelector[`${fieldName}.${filter.subField}`] = filter._getMongoSelector();
}
else
{
else {
filterSelector[fieldName] = filter._getMongoSelector();
}
emptySelector[fieldName] = filter._getEmptySelector();