From 5a369a9e528a0c722258c8d64b12ce66f82e8dde Mon Sep 17 00:00:00 2001 From: Boris Sekachev <40690378+bsekachev@users.noreply.github.com> Date: Wed, 12 Sep 2018 09:24:00 +0300 Subject: [PATCH] Bug has been fixed: Defiant doesn't support dash (-) in xpath nodes (#53) --- cvat/apps/engine/static/engine/js/shapeFilter.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cvat/apps/engine/static/engine/js/shapeFilter.js b/cvat/apps/engine/static/engine/js/shapeFilter.js index 564d421fa..9781812b5 100644 --- a/cvat/apps/engine/static/engine/js/shapeFilter.js +++ b/cvat/apps/engine/static/engine/js/shapeFilter.js @@ -26,10 +26,11 @@ class FilterModel { lock: shape.model.lock }; + // We replace all dashes due to defiant.js can't work with it function convertAttributes(attributes) { let converted = {}; for (let attrId in attributes) { - converted[attributes[attrId].name.toLowerCase()] = ('' + attributes[attrId].value).toLowerCase(); + converted[attributes[attrId].name.toLowerCase().replace(/-/g, "_")] = ('' + attributes[attrId].value).toLowerCase(); } return converted; } @@ -38,11 +39,11 @@ class FilterModel { _convertCollection(collection) { let converted = {}; for (let labelId in this._labels) { - converted[this._labels[labelId]] = []; + converted[this._labels[labelId].replace(/-/g, "_")] = []; } for (let shape of collection) { - converted[this._labels[shape.model.label].toLowerCase()].push(this._convertShape(shape)); + converted[this._labels[shape.model.label].toLowerCase().replace(/-/g, "_")].push(this._convertShape(shape)); } return converted; } @@ -109,7 +110,7 @@ class FilterView { this._filterString.on('change', (e) => { let value = $.trim(e.target.value); if (value.length) { - value = value.split('|').map(x => '/d:data/' + x).join('|').toLowerCase(); + value = value.split('|').map(x => '/d:data/' + x).join('|').toLowerCase().replace(/-/g, "_"); } if (this._controller.updateFilter(value)) { this._filterString.css('color', 'green'); -- GitLab