Commit 194782f8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

list of copy entity types in annotators and validators is unified

parent 86d7e896
......@@ -3,6 +3,8 @@ minerva (14.0.0~beta.2) unstable; urgency=low
* Bug fix: allow user to remove own comments (#931)
* Bug fix: validation of project name length is provided (#950)
* Bug fix: after reducing privileges on himself interface is refreshed (#948)
* Bug fix: list of "Copy from" elements in "Select valid annotations" dialog
is shortened to used bio entity typrd (#911)
* Bug fix: removing overlays as curator in admin panel fixed (#944)
* Bug fix: information about deprecated column is more clear about column
names (#838)
......
......@@ -51,4 +51,32 @@ AbstractAnnotatorsDialog.prototype.getAllChildrenTypesIfNeeded = function (eleme
return result;
};
/**
*
* @return {BioEntityTypeTreeNode[]}
*/
AbstractAnnotatorsDialog.prototype.getTypeNodeList = function () {
var types = [];
var treeData = this.getConfiguration().getElementTypeTree();
var queue = [treeData];
while (queue.length > 0) {
var node = queue.shift();
if (node.children !== undefined && node.children.length > 0) {
for (var i = 0; i < node.children.length; i++) {
queue.push(node.children[i]);
}
} else {
types.push(node);
}
}
types.sort(function (a, b) {
return a.text.localeCompare(b.text);
});
return types;
};
module.exports = AbstractAnnotatorsDialog;
......@@ -416,33 +416,6 @@ ChooseAnnotatorsDialog.prototype.createAnnotatorsParams = function (selectedAnno
};
/**
*
* @return {BioEntityTypeTreeNode[]}
*/
ChooseAnnotatorsDialog.prototype.getTypeNodeList = function () {
var types = [];
var treeData = this.getConfiguration().getElementTypeTree();
var queue = [treeData];
while (queue.length > 0) {
var node = queue.shift();
if (node.children !== undefined && node.children.length > 0) {
for (var i = 0; i < node.children.length; i++) {
queue.push(node.children[i]);
}
} else {
types.push(node);
}
}
types.sort(function (a, b) {
return a.text.localeCompare(b.text);
});
return types;
};
/**
*
* @returns {Promise}
......
......@@ -21,7 +21,7 @@ var logger = require('../../logger');
* @param {Object} params
* @param {HTMLElement} params.element
* @param {CustomMap} params.customMap
* @param {Configuration} [params.configuration]
* @param {Configuration} params.configuration
* @param {ServerConnector} [params.serverConnector]
*
* @constructor
......@@ -125,16 +125,13 @@ ChooseValidatorsDialog.prototype.setElementType = function (elementType) {
var copyFromSelect = Functions.createElement({type: "select", style: "margin:5px"});
element.appendChild(copyFromSelect);
var options = [], i;
for (i = 0; i < configuration.getElementTypes().length; i++) {
var type = configuration.getElementTypes()[i];
var name = type.className;
if (name.indexOf(".") > 0) {
name = name.substr(name.lastIndexOf(".") + 1);
}
var nodeList = self.getTypeNodeList();
for (i = 0; i < nodeList.length; i++) {
var type = nodeList[i];
options.push(Functions.createElement({
type: "option",
value: type.className,
content: name
value: type.data.className,
content: type.text
}));
}
options.sort(function (a, b) {
......@@ -143,6 +140,7 @@ ChooseValidatorsDialog.prototype.setElementType = function (elementType) {
for (i = 0; i < options.length; i++) {
copyFromSelect.appendChild(options[i]);
}
element.appendChild(includeChildrenCheckbox);
element.appendChild(Functions.createElement({type: "span", content: "Apply to all in subtree"}));
......
......@@ -11,34 +11,31 @@ var Promise = require('bluebird');
var chai = require('chai');
var assert = chai.assert;
function createDialog() {
return new ChooseValidatorsDialog({
element: testDiv,
customMap: null,
serverConnector: ServerConnector,
configuration: helper.getConfiguration()
});
}
describe('ChooseValidatorsDialog', function () {
it('init', function () {
var dialog = new ChooseValidatorsDialog({
element: testDiv,
customMap: null,
serverConnector: ServerConnector
});
var dialog = createDialog();
assert.equal(0, logger.getWarnings().length);
return dialog.init();
});
it('setElementType', function () {
var dialog = new ChooseValidatorsDialog({
element: testDiv,
customMap: null,
serverConnector: ServerConnector
});
var dialog = createDialog();
return ServerConnector.getConfiguration().then(function (configuration) {
return dialog.setElementType(configuration.getReactionTypes()[0]);
})
});
it('open', function () {
var dialog = new ChooseValidatorsDialog({
element: testDiv,
customMap: null,
serverConnector: ServerConnector
});
var dialog = createDialog();
return dialog.init().then(function () {
return dialog.open();
}).then(function () {
......@@ -52,11 +49,7 @@ describe('ChooseValidatorsDialog', function () {
helper.loginAsAdmin();
var originalFunction = ServerConnector.updateUserPreferences;
var functionCalled = false;
var dialog = new ChooseValidatorsDialog({
element: testDiv,
customMap: null,
serverConnector: ServerConnector
});
var dialog = createDialog();
return dialog.init().then(function () {
return dialog.open();
}).then(function () {
......
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