Skip to content
Snippets Groups Projects
Commit 0ee863b9 authored by juanf's avatar juanf
Browse files

SSDM-2738 : Refactoring, all wells can have tooltip now (ongoing work).

SVN: 35123
parent be922c90
No related branches found
No related tags found
No related merge requests found
......@@ -84,56 +84,59 @@ var PrintUtil = new function() {
$newInspector.append($newInspectorTable);
//Show Properties following the order given on openBIS
var sampleTypePropertiesCode = profile.getAllPropertiCodesForTypeCode(entity.sampleTypeCode);
var sampleTypePropertiesDisplayName = profile.getPropertiesDisplayNamesForTypeCode(entity.sampleTypeCode, sampleTypePropertiesCode);
for(var i = 0; i < sampleTypePropertiesCode.length; i++) {
var propertyCode = sampleTypePropertiesCode[i];
var propertyLabel = sampleTypePropertiesDisplayName[i];
var propertyContent = null;
var propertyType = profile.getPropertyType(propertyCode);
if(propertyType.dataType === "CONTROLLEDVOCABULARY") {
propertyContent = FormUtil.getVocabularyLabelForTermCode(propertyType, entity.properties[propertyCode]);
} else if(propertyType.dataType === "MATERIAL") {
var materialValue = entity.properties[propertyCode];
if(materialValue) {
var materialType = this._getMaterialTypeFromPropertyValue(materialValue);
if(materialType === "GENE" && entity.cachedMaterials) { //Specially supported materials from openBIS
var gene = this._getMaterialFromCode(entity.cachedMaterials, this._getMaterialCodeFromPropertyValue(materialValue));
propertyContent = $("<span>").append(gene.properties["GENE_SYMBOLS"]);
} else {
propertyContent = $("<span>").append(materialValue);
if(entity.sampleTypeCode) {
var sampleTypePropertiesCode = profile.getAllPropertiCodesForTypeCode(entity.sampleTypeCode);
var sampleTypePropertiesDisplayName = profile.getPropertiesDisplayNamesForTypeCode(entity.sampleTypeCode, sampleTypePropertiesCode);
for(var i = 0; i < sampleTypePropertiesCode.length; i++) {
var propertyCode = sampleTypePropertiesCode[i];
var propertyLabel = sampleTypePropertiesDisplayName[i];
var propertyContent = null;
var propertyType = profile.getPropertyType(propertyCode);
if(propertyType.dataType === "CONTROLLEDVOCABULARY") {
propertyContent = FormUtil.getVocabularyLabelForTermCode(propertyType, entity.properties[propertyCode]);
} else if(propertyType.dataType === "MATERIAL") {
var materialValue = entity.properties[propertyCode];
if(materialValue) {
var materialType = this._getMaterialTypeFromPropertyValue(materialValue);
if(materialType === "GENE" && entity.cachedMaterials) { //Specially supported materials from openBIS
var gene = this._getMaterialFromCode(entity.cachedMaterials, this._getMaterialCodeFromPropertyValue(materialValue));
propertyContent = $("<span>").append(gene.properties["GENE_SYMBOLS"]);
} else {
propertyContent = $("<span>").append(materialValue);
}
}
}
} else {
propertyContent = entity.properties[propertyCode];
propertyContent = Util.getEmptyIfNull(propertyContent);
propertyContent = Util.replaceURLWithHTMLLinks(propertyContent);
}
var isSingleColumn = false;
if(((propertyContent instanceof String) || (typeof propertyContent === "string"))) {
var transformerResult = profile.inspectorContentTransformer(entity, propertyCode, propertyContent);
isSingleColumn = transformerResult["isSingleColumn"];
propertyContent = transformerResult["content"];
propertyContent = propertyContent.replace(/\n/g, "<br />");
}
if(propertyContent !== "") {
if(isSingleColumn) {
$newInspectorTable
.append($("<tr>")
.append($("<td>", { "class" : "property", "colspan" : "2" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(propertyLabel + ":").append("<br>").append(propertyContent)))
);
} else {
$newInspectorTable
.append($("<tr>")
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append(propertyLabel + ":")))
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(propertyContent)))
);
propertyContent = entity.properties[propertyCode];
propertyContent = Util.getEmptyIfNull(propertyContent);
propertyContent = Util.replaceURLWithHTMLLinks(propertyContent);
}
var isSingleColumn = false;
if(((propertyContent instanceof String) || (typeof propertyContent === "string"))) {
var transformerResult = profile.inspectorContentTransformer(entity, propertyCode, propertyContent);
isSingleColumn = transformerResult["isSingleColumn"];
propertyContent = transformerResult["content"];
propertyContent = propertyContent.replace(/\n/g, "<br />");
}
if(propertyContent !== "") {
if(isSingleColumn) {
$newInspectorTable
.append($("<tr>")
.append($("<td>", { "class" : "property", "colspan" : "2" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(propertyLabel + ":").append("<br>").append(propertyContent)))
);
} else {
$newInspectorTable
.append($("<tr>")
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append(propertyLabel + ":")))
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(propertyContent)))
);
}
}
}
}
if(entity["@type"] === "Sample") {
//Show Parent Codes
var allParentCodesAsText = this._getCodesFromSamples(entity.parents);
......@@ -157,18 +160,20 @@ var PrintUtil = new function() {
}
//Show Modification Date
$newInspectorTable
.append($("<tr>")
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append("Modification Date:")))
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(new Date(entity.registrationDetails["modificationDate"]))))
);
//Show Creation Date
$newInspectorTable
.append($("<tr>")
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append("Registration Date:")))
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(new Date(entity.registrationDetails["registrationDate"]))))
);
if(entity.registrationDetails) {
$newInspectorTable
.append($("<tr>")
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append("Modification Date:")))
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(new Date(entity.registrationDetails["modificationDate"]))))
);
//Show Creation Date
$newInspectorTable
.append($("<tr>")
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append("Registration Date:")))
.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(new Date(entity.registrationDetails["registrationDate"]))))
);
}
if(extraCustomId && extraContent) {
$newInspector.append($("<div>", { "class" : "inspectorExtra", "id" : extraCustomId}).append(extraContent));
......
......@@ -47,26 +47,31 @@ function PlateModel(sample, isDisabled) {
this.getWell = function(rowNum, colNum) {
//NOTE: We are currently handling two naming conventions ":A01" and ":A1"
var wellIdentifier = this.sample.identifier + ":" + this.getAlphabetLabel(rowNum) + ((colNum < 10)?"0":"") + colNum;
var wellIdentifier2 = this.sample.identifier + ":" + this.getAlphabetLabel(rowNum) + colNum;
var wellIdentifier = this.sample.identifier + ":" + Util.getLetterForNumber(rowNum) + ((colNum < 10)?"0":"") + colNum;
var wellIdentifier2 = this.sample.identifier + ":" + Util.getLetterForNumber(rowNum) + colNum;
var toReturn = null;
for(var wellIdx = 0; wellIdx < this.sample.contained.length; wellIdx++) {
if( this.sample.contained[wellIdx].identifier === wellIdentifier ||
this.sample.contained[wellIdx].identifier === wellIdentifier2) {
var toReturn = this.sample.contained[wellIdx];
return toReturn;
toReturn = this.sample.contained[wellIdx];
}
}
return null;
if(!toReturn) {
toReturn = {};
toReturn.isEmpty = true;
toReturn.permId = null;
toReturn.code = this.sample.code + ":"+ Util.getLetterForNumber(rowNum) + colNum
toReturn.sampleTypeCode = null;
toReturn.properties = {};
}
return toReturn;
}
this.getPlaceHolderId = function() {
return "PLATE_TEMPLATE_"+this.sample.permId;
}
this.getAlphabetLabel = function(number) {
var alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
return alphabet[number];
}
}
\ No newline at end of file
......@@ -153,32 +153,31 @@ function PlateView(plateController, plateModel) {
} else if (i === 0 && j !== 0){ //header with column numbers
$cell = $("<th>").append(j);
} else if (j === 0){ //header with row letter
$cell = $("<th>").append(this._plateModel.getAlphabetLabel(i-1));
$cell = $("<th>").append(Util.getLetterForNumber(i));
} else {
$cell = $("<td>").append("&nbsp;");
$cell.addClass('well');
if(withWells) {
var well = this._plateModel.getWell(i-1,j);
if(well) {
var well = this._plateModel.getWell(i,j);
var colorEncodedWellAnnotationsSelector = "";
if(!well.isEmpty) {
$cell.attr("id", "well-" + well.permId);
//Color Annotations only enabled for wells with a type having COLOR_ENCODED_ANNOTATION property
var isAnnotableWell = jQuery.inArray("COLOR_ENCODED_ANNOTATION", profile.getAllPropertiCodesForTypeCode(well.sampleTypeCode) ) !== -1;
var colorEncodedWellAnnotationsSelector = "";
if(isAnnotableWell) {
colorEncodedWellAnnotationsSelector = this._getWellColorAnnotationGroups(well);
}
var tooltip = PrintUtil.getTable(well, false, null, 'inspectorWhiteFont',
'colorEncodedWellAnnotations-holder-' + well.permId,
colorEncodedWellAnnotationsSelector);
$cell.tooltipster({
content: $(tooltip),
interactive: true
});
}
}
var tooltip = PrintUtil.getTable(well, false, null, 'inspectorWhiteFont',
'colorEncodedWellAnnotations-holder-' + well.permId,
colorEncodedWellAnnotationsSelector);
$cell.tooltipster({
content: $(tooltip),
interactive: true
});
}
}
......@@ -310,8 +309,8 @@ function PlateView(plateController, plateModel) {
}
this._repaintWellToColorAnnotation = function(row, column) {
var well = this._plateModel.getWell(row-1,column);
if(well) {
var well = this._plateModel.getWell(row,column);
if(!well.isEmpty) {
var isAnnotableWell = jQuery.inArray("COLOR_ENCODED_ANNOTATION", profile.getAllPropertiCodesForTypeCode(well.sampleTypeCode) ) !== -1;
if(isAnnotableWell) {
var selectedColorEncodedAnnotation = well.properties["COLOR_ENCODED_ANNOTATION"];
......
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