Bug has been fixed: Defiant doesn't support dash (-) in xpath nodes (#53)

main
Boris Sekachev 8 years ago committed by azhavoro
parent 89cb5eb169
commit 5a369a9e52

@ -26,10 +26,11 @@ class FilterModel {
lock: shape.model.lock lock: shape.model.lock
}; };
// We replace all dashes due to defiant.js can't work with it
function convertAttributes(attributes) { function convertAttributes(attributes) {
let converted = {}; let converted = {};
for (let attrId in attributes) { 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; return converted;
} }
@ -38,11 +39,11 @@ class FilterModel {
_convertCollection(collection) { _convertCollection(collection) {
let converted = {}; let converted = {};
for (let labelId in this._labels) { for (let labelId in this._labels) {
converted[this._labels[labelId]] = []; converted[this._labels[labelId].replace(/-/g, "_")] = [];
} }
for (let shape of collection) { 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; return converted;
} }
@ -109,7 +110,7 @@ class FilterView {
this._filterString.on('change', (e) => { this._filterString.on('change', (e) => {
let value = $.trim(e.target.value); let value = $.trim(e.target.value);
if (value.length) { 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)) { if (this._controller.updateFilter(value)) {
this._filterString.css('color', 'green'); this._filterString.css('color', 'green');

Loading…
Cancel
Save