From 14d05d78c9ab456b2c6dea88b0724adbeba7f62f Mon Sep 17 00:00:00 2001 From: Boris Sekachev <40690378+bsekachev@users.noreply.github.com> Date: Thu, 25 Apr 2019 22:10:50 +0300 Subject: [PATCH] Fixed filter: * instead of labels and relational operators (#428) --- cvat/apps/engine/static/engine/js/shapeFilter.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cvat/apps/engine/static/engine/js/shapeFilter.js b/cvat/apps/engine/static/engine/js/shapeFilter.js index b4ce041d..b1bdd953 100644 --- a/cvat/apps/engine/static/engine/js/shapeFilter.js +++ b/cvat/apps/engine/static/engine/js/shapeFilter.js @@ -116,7 +116,7 @@ class FilterController { const labels = String.customSplit(value, '[|]').map(el => el.trim()); let result = ''; for (const label of labels) { - const labelName = label.match(/^[-,?!_0-9a-z()\s"]+/)[0]; + const labelName = label.match(/^[-,?!_0-9a-z()*\s"]+/)[0]; const labelFilters = label.substr(labelName.length).trim(); result += `${labelName.replace(this._model.regex, '_').replace(/"/g, '')}`; @@ -132,11 +132,14 @@ class FilterController { const attrPrefix = attrMatch[0]; const attrExpression = andExpression.substr(attrMatch.index + attrPrefix.length); - const [attrName, attrValue] = String.customSplit(attrExpression, '=') - .map(el => el.trim()); + const [attrName, attrValue] = String + .customSplit(attrExpression, '=|<=|>=|<|>|!='); + const condition = attrExpression + .slice(attrName.length, -attrValue.length).trim(); + formattedAndExpressions - .push(`${attrPrefix}${attrName.replace(this._model.regex, '_') - .replace(/"/g, '')}=${attrValue}`); + .push(`${attrPrefix}${attrName.trim().replace(this._model.regex, '_') + .replace(/"/g, '')}${condition}${attrValue.trim()}`); } else { formattedAndExpressions.push(andExpression); }