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

Merge branch '179-chemicals-not-available' into 'master'

when project contains info about disease chemical panel is active

Closes #179

See merge request !77
parents 2e7b8b06 f6660d73
......@@ -99,6 +99,11 @@ Panel.prototype.disablePanel = function(message) {
self.getElement().insertBefore(hideReasonDiv, searchQueryElement);
};
Panel.prototype.isDisbaled = function() {
var self = this;
var searchQueryElement = self.getControlElement(PanelControlElementType.SEARCH_DIV);
return searchQueryElement.style.visibility === "hidden";
};
Panel.prototype.setMap = function(map) {
this._map = map;
};
......
......@@ -18,7 +18,7 @@ function ChemicalPanel(params) {
AbstractDbPanel.call(this, params);
if (params.disease === undefined) {
if (this.getMap().getProject().getDisease() === undefined) {
this.disablePanel("DISEASE NOT DEFINED FOR PROJECT. PLEASE, DEFINE IT IN THE ADMIN SECTION.");
}
}
......
......@@ -2,6 +2,7 @@
require('../../mocha-config.js');
var Annotation = require('../../../../main/js/map/data/Annotation');
var Chemical = require('../../../../main/js/map/data/Chemical');
var ChemicalPanel = require('../../../../main/js/gui/leftPanel/ChemicalPanel');
var PanelControlElementType = require('../../../../main/js/gui/PanelControlElementType');
......@@ -12,39 +13,63 @@ var logger = require('../../logger');
describe('ChemicalPanel', function() {
it('contructor', function() {
var map = helper.createCustomMap();
helper.createChemicalDbOverlay(map);
describe('contructor', function() {
it('default', function() {
var map = helper.createCustomMap();
helper.createChemicalDbOverlay(map);
new ChemicalPanel({
element : testDiv,
customMap : map
var panel = new ChemicalPanel({
element : testDiv,
customMap : map
});
assert.equal(logger.getWarnings().length, 0);
assert.ok(panel.isDisbaled());
});
it('map with disease', function() {
return ServerConnector.getProject().then(function(project) {
project.setDisease(new Annotation({
link : "http://bioportal.bioontology.org/ontologies/1351?p=terms&conceptid=D010300",
type: "MESH_2012",
resource : "D010300",
}));
var map = helper.createCustomMap(project);
helper.createChemicalDbOverlay(map);
var panel = new ChemicalPanel({
element : testDiv,
customMap : map
});
assert.equal(logger.getWarnings().length, 0);
assert.notOk(panel.isDisbaled());
});
});
assert.equal(logger.getWarnings().length, 0);
});
it('createChemicaleader for empty', function() {
var map = helper.createCustomMap();
helper.createChemicalDbOverlay(map);
describe('createPreamble', function() {
it('default', function() {
var map = helper.createCustomMap();
helper.createChemicalDbOverlay(map);
var panel = new ChemicalPanel({
element : testDiv,
customMap : map
var panel = new ChemicalPanel({
element : testDiv,
customMap : map
});
assert.ok(panel.createPreamble().innerHTML.indexOf("NOT FOUND") > 0);
});
assert.ok(panel.createPreamble().innerHTML.indexOf("NOT FOUND") > 0);
});
it('for empty', function() {
var map = helper.createCustomMap();
helper.createChemicalDbOverlay(map);
it('createChemicaleader for empty', function() {
var map = helper.createCustomMap();
helper.createChemicalDbOverlay(map);
var panel = new ChemicalPanel({
element : testDiv,
customMap : map
});
var panel = new ChemicalPanel({
element : testDiv,
customMap : map
assert.ok(panel.createPreamble(new Chemical()).innerHTML.indexOf("NOT FOUND") > 0);
});
assert.ok(panel.createPreamble(new Chemical()).innerHTML.indexOf("NOT FOUND") > 0);
});
it('on searchResults changed', 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