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