Commit 880f878b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

chemical panel disabled when disease is not defined for panel

parent 99ea49b2
......@@ -56,6 +56,21 @@ function AbstractPanel(params) {
AbstractPanel.prototype = Object.create(ObjectWithListeners.prototype);
AbstractPanel.prototype.constructor = AbstractPanel;
AbstractPanel.prototype.disablePanel = function(message){
this.getSearchQueryElement().style.visibility ="hidden";
this.getSearchResultsElement().style.visibility ="hidden";
var hideReasonDiv = document.createElement("div");
hideReasonDiv.className="searchPanel";
var center = document.createElement("center");
var messageDiv = document.createElement("h4");
messageDiv .innerHTML=message;
center.appendChild(messageDiv);
hideReasonDiv.appendChild(center);
this.getElement().insertBefore(hideReasonDiv, this.getSearchQueryElement());
};
AbstractPanel.prototype.setOverlayDb = function(overlayDb){
if (overlayDb === undefined) {
throw new Error("Undefined overlayDb");
......
......@@ -8,6 +8,10 @@ var AbstractPanel = require('./AbstractPanel');
function ChemicalPanel(params) {
params.panelName = "chemical";
AbstractPanel.call(this, params);
if (params.disease===undefined) {
this.disablePanel("DISEASE NOT DEFINED FOR PROJECT. PLEASE, DEFINE IT IN THE ADMIN SECTION.");
}
}
ChemicalPanel.prototype = Object.create(AbstractPanel.prototype);
ChemicalPanel.prototype.constructor = ChemicalPanel;
......
......@@ -31,6 +31,8 @@ Project.prototype.loadFromData = function(data) {
this.setDescription(data.description);
this.setOverviewImages(data.overviewImageViews);
this.setTopOverviewImage(data.topOverviewImage);
this.setDisease(data.disease);
this.setOrganism(data.organism);
this.setModel(new Model(data.map));
......@@ -94,4 +96,18 @@ Project.prototype.setDescription = function(description) {
this._description = description;
};
Project.prototype.getDisease = function() {
return this._disease;
};
Project.prototype.setDisease = function(disease) {
this._disease = disease;
};
Project.prototype.getOrganism = function() {
return this._organism;
};
Project.prototype.setOrganism = function(organism) {
this._organism = organism;
};
module.exports = Project;
......@@ -66,6 +66,11 @@ function restoreDrugQuery(customMap) {
};
function create(params) {
var project = params.project;
if (project===undefined) {
project = params.getProject();
}
if (global.GuiConnector === undefined) {
global.GuiConnector = OriginalGuiConnector;
global.ServerConnector = OriginalServerConnector;
......@@ -126,6 +131,7 @@ function create(params) {
collection = new ChemicalDbOverlay(collectionParams);
result.registerSource(collection);
new ChemicalPanel({
disease: project.getDisease(),
element : document.getElementById("chemicalTab"),
customMap : result
});
......
......@@ -12,6 +12,7 @@ import lcsb.mapviewer.model.map.OverviewImage;
import lcsb.mapviewer.model.map.OverviewImageLink;
import lcsb.mapviewer.model.map.OverviewLink;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.services.view.AnnotationView;
import lcsb.mapviewer.services.view.OverviewImageView;
import lcsb.mapviewer.services.view.OverviewImageViewFactory;
......@@ -28,8 +29,12 @@ public class ProjectMetaData implements Serializable {
* Version of the project.
*/
private String version;
private Integer idObject;
private AnnotationView disease;
private AnnotationView organism;
private Integer idObject;
/**
* Name of the project.
......@@ -96,6 +101,7 @@ public class ProjectMetaData implements Serializable {
this.setTopOverviewImage(factory.create(model.getOverviewImages().get(0)));
}
this.setMap(new ModelMetaData(model));
}
}
......@@ -227,11 +233,46 @@ public class ProjectMetaData implements Serializable {
}
/**
* @param idObject the idObject to set
* @param idObject
* the idObject to set
* @see #idObject
*/
public void setIdObject(Integer idObject) {
this.idObject = idObject;
}
/**
* @return the disease
* @see #disease
*/
public AnnotationView getDisease() {
return disease;
}
/**
* @param disease
* the disease to set
* @see #disease
*/
public void setDisease(AnnotationView disease) {
this.disease = disease;
}
/**
* @return the organism
* @see #organism
*/
public AnnotationView getOrganism() {
return organism;
}
/**
* @param organism
* the organism to set
* @see #organism
*/
public void setOrganism(AnnotationView organism) {
this.organism = organism;
}
}
......@@ -57,6 +57,12 @@ public class ProjectRestImpl {
Project project = projectService.getProjectByProjectId(projectId, userService.getToken(token));
ProjectMetaData result = new ProjectMetaData(project);
if (project.getOrganism() != null) {
result.setOrganism(annotationViewFactory.create(project.getOrganism()));
}
if (project.getDisease() != null) {
result.setDisease(annotationViewFactory.create(project.getDisease()));
}
return result;
}
......@@ -328,7 +334,8 @@ public class ProjectRestImpl {
this.searchService = searchService;
}
public List<Map<String, Object>> getElementsByQuery(String projectId, String token, String query, Integer maxElements, String perfectMatch) throws SecurityException {
public List<Map<String, Object>> getElementsByQuery(String projectId, String token, String query, Integer maxElements, String perfectMatch)
throws SecurityException {
List<Map<String, Object>> resultMap = new ArrayList<>();
Model model = modelService.getLastModelByProjectId(projectId, userService.getToken(token));
......
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