Skip to content

Commit

Permalink
fix #2040 attributes with dot in prefix do not render in gui
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Sep 1, 2016
1 parent 2ad795b commit 68e280b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
11 changes: 8 additions & 3 deletions rundeckapp/grails-app/assets/javascripts/nodeFiltersKO.js
Expand Up @@ -308,10 +308,11 @@ function NodeSet(data) {
result.sort(function(a,b){return a.shortname.localeCompare(b.shortname);});
return result;
};
self.attributeNamespaceRegex=/^(.+?):.+$/;
self.attributeNamespaceNames=function(attrs){
var namespaces=[];
for(var e in attrs){
var found=e.match(/^(\w+):.+$/);
var found=e.match(self.attributeNamespaceRegex);
if(found && found.length>1){
if(namespaces.indexOf(found[1])<0){
namespaces.push(found[1]);
Expand All @@ -325,13 +326,17 @@ function NodeSet(data) {
var index={};
var names=[];
for(var e in attrs){
var found=e.match(/^(\w+):.+$/);
var found=e.match(self.attributeNamespaceRegex);
if(found && found.length>1){
if(!index[found[1]]){
index[found[1]]=[];
names.push(found[1]);
}
index[found[1]].push({name:e,value:attrs[e](),shortname: e.substring(found[1].length+1)});
index[found[1]].push({
name:e,
value:ko.utils.unwrapObservable(attrs[e]),
shortname: e.substring(found[1].length+1)
});
}
}
names.sort();
Expand Down
43 changes: 42 additions & 1 deletion rundeckapp/grails-app/assets/javascripts/nodeFiltersKOTest.js
Expand Up @@ -77,11 +77,52 @@ var NodeFiltersTest = function () {
assert(pref+'singular','singular',nf.nodesTitle());
};

self.namespacesTest = function (pref) {
var nf = new NodeSet({});
var ns = nf.attributeNamespaces({
'a:b': 'c',
'a.x:z': 'd',
'a.x:p': 'e',
'a.z-y:y:abc': 'wxy'
});
assert(pref + 'count', 3, ns.length);

assert(pref + '[0]: key', 'a', ns[0].ns);
assert(pref + '[0]: values length', 1, ns[0].values.length);
assert(pref + '[0]: value name', 'a:b', ns[0].values[0].name);
assert(pref + '[0]: value value', 'c', ns[0].values[0].value);
assert(pref + '[0]: value shortName', 'b', ns[0].values[0].shortname);


assert(pref + '[1]: key', 'a.x', ns[1].ns);
assert(pref + '[1]: values length', 2, ns[1].values.length);

assert(pref + '[1][0]: value name', 'a.x:p', ns[1].values[0].name);
assert(pref + '[1][0]: value value', 'e', ns[1].values[0].value);
assert(pref + '[1][0]: value shortName', 'p', ns[1].values[0].shortname);

assert(pref + '[1][1]: value name', 'a.x:z', ns[1].values[1].name);
assert(pref + '[1][1]: value value', 'd', ns[1].values[1].value);
assert(pref + '[1][1]: value shortName', 'z', ns[1].values[1].shortname);


assert(pref + '[2]: key', 'a.z-y', ns[2].ns);
assert(pref + '[2]: values length', 1, ns[2].values.length);
assert(pref + '[2][0]: value name', 'a.z-y:y:abc', ns[2].values[0].name);
assert(pref + '[2][0]: value value', 'wxy', ns[2].values[0].value);
assert(pref + '[2][0]: value shortName', 'y:abc', ns[2].values[0].shortname);

};

self.testAll = function () {
assert("Start: nodeFiltersKOTest.js", 1, 1);
for (var i in self) {
if (i.endsWith('Test')) {
self[i].call(self, i + ': ');
try {
self[i].call(self, i + ': ');
} catch (e) {
assert(i + ': error', null, e);
}
}
}
if(failed>0){
Expand Down

0 comments on commit 68e280b

Please sign in to comment.