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

GuiUtils should have access to global minerva configuration

parent 926852bd
No related branches found
No related tags found
1 merge request!57References rest result improved
......@@ -13,6 +13,7 @@ function AbstractGuiElement(params) {
var self = this;
self.setElement(params.element);
self.setConfiguration(params.configuration);
self.setMap(params.customMap);
self._controlElements = [];
......@@ -44,6 +45,14 @@ AbstractGuiElement.prototype.getElement = function() {
return this._element;
};
AbstractGuiElement.prototype.setConfiguration = function(configuration) {
this._configuration = configuration;
};
AbstractGuiElement.prototype.getConfiguration = function() {
return this._configuration;
};
AbstractGuiElement.prototype.setControlElement = function(type, element) {
if (type === null || type === undefined) {
throw new Error("Unknown controle element type");
......
......@@ -8,12 +8,22 @@ var Functions = require('../../Functions');
var logger = require('../../logger');
function GuiUtils() {
function GuiUtils(configuration) {
var self = this;
self.setConfiguration(configuration);
}
GuiUtils.prototype = Object.create(AbstractGuiElement.prototype);
GuiUtils.prototype.constructor = GuiUtils;
GuiUtils.prototype.setConfiguration = function(configuration) {
this._configuration = configuration;
};
GuiUtils.prototype.getConfiguration = function() {
return this._configuration;
};
GuiUtils.prototype.createLabel = function(value) {
var result = document.createElement("span");
result.innerHTML = value;
......@@ -66,11 +76,13 @@ GuiUtils.prototype.createLink = function(url, name) {
};
GuiUtils.prototype.createAnnotationLink = function(annotation, showType) {
var self = this;
var name, type, hint;
var article = annotation.getArticle();
if (article !== undefined) {
hint = article.getTitle()+ " " + article.getAuthors().join(", ") + ", " + article.getYear()+ ", " + article.getJournal();
hint = article.getTitle() + " " + article.getAuthors().join(", ") + ", " + article.getYear() + ", "
+ article.getJournal();
type = "PUBMED";
name = article.getId();
} else {
......@@ -79,9 +91,9 @@ GuiUtils.prototype.createAnnotationLink = function(annotation, showType) {
}
var link;
if (showType) {
link = this.createLink(annotation.getLink(), type + " (" + name + ")");
link = self.createLink(annotation.getLink(), type + " (" + name + ")");
} else {
link = this.createLink(annotation.getLink(), name);
link = self.createLink(annotation.getLink(), name);
}
if (hint !== undefined) {
var div = document.createElement("div");
......
......@@ -15,7 +15,7 @@ function Panel(params) {
var self = this;
self.setGuiUtils(new GuiUtils());
self.setGuiUtils(new GuiUtils(self.getConfiguration()));
self.setPanelName(params.panelName);
this.setParent(params.parent);
......
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