Commit 5817bd8b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

clear of drug panel fixed

parent fdf293e0
......@@ -299,7 +299,7 @@ ServerConnector.sendClearRequest = function(overlayName) {
} else {
logger.warn("Clear function for " + overlayName + " doesn't exist");
}
} else if (overlayName==="search" || overlayName==="comment"){
} else if (overlayName==="search" || overlayName==="comment" || overlayName ==="drug"){
logger.warn("Send clear request for overlay that doesn't support it: "+overlayName);
} else {
throw new Error("[Clear function] Unknown overlay: ", overlayName);
......
......@@ -15,13 +15,17 @@ DrugPanel.prototype.constructor = DrugPanel;
DrugPanel.prototype.createDrugHeader = function(drug) {
var self = this;
var result = document.createElement("div");
result.appendChild(self.createParamLine("Drug: ", drug.getName()));
result.appendChild(self.createParamLine("Description: ", drug.getDescription()));
result.appendChild(self.createArrayParamLine("Synonyms: ", drug.getSynonyms()));
result.appendChild(self.createArrayParamLine("Brand names: ", drug.getBrandNames()));
result.appendChild(self.createParamLine("Blood brain barrier: ", drug.getBloodBrainBarrier()));
result.appendChild(self.createAnnotations("Sources: ", drug.getReferences()));
result.appendChild(self.createNewLine());
if (drug === undefined || drug.getName() === undefined) {
result.appendChild(self.createLabel("NOT FOUND"));
} else {
result.appendChild(self.createParamLine("Drug: ", drug.getName()));
result.appendChild(self.createParamLine("Description: ", drug.getDescription()));
result.appendChild(self.createArrayParamLine("Synonyms: ", drug.getSynonyms()));
result.appendChild(self.createArrayParamLine("Brand names: ", drug.getBrandNames()));
result.appendChild(self.createParamLine("Blood brain barrier: ", drug.getBloodBrainBarrier()));
result.appendChild(self.createAnnotations("Sources: ", drug.getReferences()));
result.appendChild(self.createNewLine());
}
return result;
};
......@@ -39,7 +43,7 @@ DrugPanel.prototype.createTargetElement = function(target, icon) {
var checkbox = document.createElement('input');
checkbox.type = "checkbox";
checkbox.checked = target.isVisible();
checkbox.onclick = function(){
checkbox.onclick = function() {
target.setIsVisible(!target.isVisible());
self.getOverlayDb().callListeners("onTargetVisibilityChange");
};
......
......@@ -3,14 +3,16 @@
var Target = require("./Target");
function Drug(javaObject) {
this.setBrandNames(javaObject.brandNames);
this.setReferences(javaObject.references);
this.setSynonyms(javaObject.synonyms);
this.setName(javaObject.name);
this.setId(javaObject.id);
this.setDescription(javaObject.description);
this.setTargets(javaObject.targets);
this.setBloodBrainBarrier(javaObject.bloodBrainBarrier);
if (javaObject !== undefined) {
this.setBrandNames(javaObject.brandNames);
this.setReferences(javaObject.references);
this.setSynonyms(javaObject.synonyms);
this.setName(javaObject.name);
this.setId(javaObject.id);
this.setDescription(javaObject.description);
this.setTargets(javaObject.targets);
this.setBloodBrainBarrier(javaObject.bloodBrainBarrier);
}
}
Drug.prototype.setBrandNames = function(brandNames) {
......
......@@ -4,8 +4,10 @@ var Helper = require('../helper');
require("../mocha-config.js");
var Drug = require('../../../main/js/map/data/Drug');
var DrugPanel = require('../../../main/js/gui/DrugPanel');
var chai = require('chai');
var assert = chai.assert;
var logger = require('../logger');
......@@ -30,6 +32,34 @@ describe('DrugPanel', function() {
assert.equal(logger.getWarnings().length, 0);
});
it('createDrugeader for empty', function() {
var div = helper.createDrugTab();
var map = helper.createCustomMap();
helper.createDrugDbOverlay(map);
var panel = new DrugPanel({
element : div,
customMap : map
});
assert.ok(panel.createDrugHeader().innerHTML.indexOf("NOT FOUND") > 0);
});
it('createDrugeader for empty', function() {
var div = helper.createDrugTab();
var map = helper.createCustomMap();
helper.createDrugDbOverlay(map);
var panel = new DrugPanel({
element : div,
customMap : map
});
assert.ok(panel.createDrugHeader(new Drug()).innerHTML.indexOf("NOT FOUND") > 0);
});
it('on searchResults changed', function() {
var div = helper.createDrugTab();
var map = helper.createCustomMap();
......
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