Skip to content

Commit

Permalink
Merge branch 'dev' into g3w-admin/PR#601
Browse files Browse the repository at this point in the history
  • Loading branch information
volterra79 committed Nov 16, 2023
2 parents 1beb3d3 + e843822 commit c5c1c2f
Show file tree
Hide file tree
Showing 55 changed files with 1,221 additions and 852 deletions.
19 changes: 9 additions & 10 deletions src/app/core/layers/filter/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ function Expression(options={}) {
const proto = Expression.prototype;

proto.and = function(field, value) {
this._expression = this._expression ? this._expression + ' AND ': this._expression;
if (field && value) {
this.eq(field, value);
}
return this;
this._expression = this._expression ? this._expression + ' AND ': this._expression;
if (field && value) {
this.eq(field, value);
}
return this;
};

proto.or = function() {
Expand Down Expand Up @@ -89,9 +89,9 @@ proto.createSingleExpressionElement = function({value, attribute, operator, logi
const filterValue = `( ${_value.map(value => `'${value}'`).join(',').replace(/,/g, ' , ')} )`;
filterElement = `"${attribute}" ${filterOp} ${filterValue}${filterLogicOperator}`;
} else if (
(value !== null && value !== undefined)
&& !(Number.isNaN(value) || !value.toString().trim()) //check if a valid number (not a NaN and not an empty string)
) {
(value !== null && value !== undefined)
&& !(Number.isNaN(value) || !value.toString().trim()) //check if a valid number (not a NaN and not an empty string)
) {
const singolequote = Array.isArray(value) ? value :
typeof value !== 'number' ? value.split("'") : [];
if (singolequote.length > 1) {
Expand All @@ -100,12 +100,11 @@ proto.createSingleExpressionElement = function({value, attribute, operator, logi
const value = singolequote[i];
if (!value)
continue;
const filterOp = 'ILIKE';
const filterValue = `%${value}%`.trim();
const filterElement = `"${attribute}" ${filterOp} '${filterValue}'`;
_filterElements.push(filterElement)
}
filterElement = `${_filterElements.join(' AND ')}${filterLogicOperator}`;
filterElement = `${_filterElements.join(` ${logicop} `)}${filterLogicOperator}`;
} else filterElement = `"${attribute}" ${filterOp} '${valueExtra}${value}${valueExtra}'${filterLogicOperator}`;
}
return filterElement;
Expand Down
Loading

0 comments on commit c5c1c2f

Please sign in to comment.