Commit d2c901d4 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '815-sort-list-of-annotators' into 'devel_13.1.x'

Resolve "Sort the lists of annotators in Select annotators and Select valid annotators"

See merge request minerva/core!791
parents f9e84a14 503d2b67
......@@ -4,6 +4,9 @@ minerva (12.3.1~beta.1) unstable; urgency=low
* Bug fix: plugin tab header wasn't properly resized after adding plugins
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);
}
}
}
......
......@@ -197,6 +197,15 @@ ChooseAnnotatorsDialog.prototype.setElementType = function (elementType) {
}
entries.push(entry);
}
entries.sort(function (entryA, entryB) {
if (entryA.name < entryB.name) {
return -1;
}
if (entryA.name > entryB.name) {
return 1;
}
return 0;
});
var checkboxList = new MultiCheckboxList(selectElement, {
entries: entries,
listTitle: "Available annotators",
......
......@@ -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);
})
});
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment