Skip to content
Snippets Groups Projects
Commit 503d2b67 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

sort of protein type fixed

parent 99910708
No related branches found
No related tags found
2 merge requests!805Merge 13.1.0 beta.1,!791Resolve "Sort the lists of annotators in Select annotators and Select valid annotators"
Pipeline #10505 failed
......@@ -5,6 +5,8 @@ minerva (12.3.1~beta.1) unstable; urgency=low
that introduced second line for tab selection (#758)
* Bug fix: invisible layer shouldn't be shown in the on th map (#813)
* Bug fix: list of availbale annotators is sorted alphabetically (#815)
* Bug fix: protein types are sorted properly in "Select valid annotations"
dialog (#815)
minerva (13.1.0~beta.0) unstable; urgency=low
* Feature: annotators are more flexible - you can define set of input and
......
......@@ -704,6 +704,16 @@ Configuration.prototype.getElementTypeTree = function () {
};
}
var sortFunction = function (entryA, entryB) {
if (entryA.text < entryB.text) {
return -1;
}
if (entryA.text > entryB.text) {
return 1;
}
return 0;
};
for (var treeNodeName in treeNodes) {
if (treeNodes.hasOwnProperty(treeNodeName)) {
var treeNode = treeNodes[treeNodeName];
......@@ -712,6 +722,7 @@ Configuration.prototype.getElementTypeTree = function () {
//prevent compartment subclass specific nodes and reaction subclass specific nodes
if (parentNode.data === undefined || (parentNode.data.name !== "Compartment" && parentNode.data.name !== "Generic Reaction")) {
parentNode.children.push(treeNode);
parentNode.children.sort(sortFunction);
}
}
}
......
......@@ -155,16 +155,40 @@ describe('Configuration', function () {
});
});
it('getElementTypeTree', function () {
describe('getElementTypeTree', function () {
it('default', function () {
return ServerConnector.getConfiguration().then(function (configuration) {
var treeData = configuration.getElementTypeTree();
return ServerConnector.getConfiguration().then(function (configuration) {
var treeData = configuration.getElementTypeTree();
assert.ok(treeData);
assert.ok(treeData.text);
assert.ok(treeData.children);
assert.equal(2, treeData.children.length);
})
assert.ok(treeData);
assert.ok(treeData.text);
assert.ok(treeData.children);
assert.equal(2, treeData.children.length);
})
});
it('check sorting', function () {
/**
*
* @param {BioEntityTypeTreeNode[]} children
*/
function checkChildrenSorted(children) {
var i;
for (i = 1; i < children.length; i++) {
assert.ok(children[i - 1].text < children[i].text, "children are not sorted: " + children[i - 1].text + " ; " + children[i].text);
}
for (i = 0; i < children.length; i++) {
if (children[i].children != null) {
checkChildrenSorted(children[i].children);
}
}
}
return ServerConnector.getConfiguration().then(function (configuration) {
var treeData = configuration.getElementTypeTree();
checkChildrenSorted(treeData.children);
})
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment