From 3f3dccab8e52b83ada47e5d72f0340e6654ad0c4 Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Tue, 23 Jun 2015 15:30:41 +0000
Subject: [PATCH] SSDM-1959 : Show gene name instead of gene number in ELN
 plate hierarchy view

SVN: 34260
---
 .../eln-lims/html/js/util/PrintUtil.js        | 52 ++++++++++---------
 .../js/views/SampleForm/SampleFormView.js     |  2 +-
 2 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/PrintUtil.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/PrintUtil.js
index 76790b00c27..91688a0b1c5 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/PrintUtil.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/PrintUtil.js
@@ -17,11 +17,11 @@
 
 var PrintUtil = new function() {
 
-	this.printSample = function(sample) {
-		var newWindow = window.open(undefined,"print " + sample.permId);
+	this.printEntity = function(entity) {
+		var newWindow = window.open(undefined,"print " + entity.permId);
 		var pageToPrint = $("<html>")
 							.append($("<head>"))
-							.append($("<body>").append(this.getTable(sample)));
+							.append($("<body>").append(this.getTable(entity)));
 		$(newWindow.document.body).html(pageToPrint);
 	}
 	
@@ -89,13 +89,17 @@ var PrintUtil = new function() {
 			var propertyContent = null;
 			
 			var propertyType = profile.getPropertyType(propertyCode);
-			if(propertyType && propertyType.dataType === "CONTROLLEDVOCABULARY") {
+			if(propertyType.dataType === "CONTROLLEDVOCABULARY") {
 				propertyContent = FormUtil.getVocabularyLabelForTermCode(propertyType, entity.properties[propertyCode]);
+			} else if(propertyType.dataType === "MATERIAL") {
+				propertyContent = $("<a>").append(entity.properties[propertyCode]);
 			} else {
 				propertyContent = entity.properties[propertyCode];
+				propertyContent = Util.getEmptyIfNull(propertyContent);
+				propertyContent = Util.replaceURLWithHTMLLinks(propertyContent);
 			}
 				
-			propertyContent = Util.getEmptyIfNull(propertyContent);
+			
 			
 			var isSingleColumn = false;
 			if((propertyContent instanceof String) || (typeof propertyContent === "string")) {
@@ -106,7 +110,6 @@ var PrintUtil = new function() {
 			}
 			
 			if(propertyContent !== "") {
-				propertyContent = Util.replaceURLWithHTMLLinks(propertyContent);
 				if(isSingleColumn) {
 					$newInspectorTable
 					.append($("<tr>")
@@ -121,27 +124,28 @@ var PrintUtil = new function() {
 				}
 			}
 		}
-			
-		//Show Parent Codes
-		var allParentCodesAsText = this._getCodesFromSamples(entity.parents);
-		if(allParentCodesAsText.length > 0) {
-			$newInspectorTable
+		if(entity["@type"] === "Sample") {
+			//Show Parent Codes
+			var allParentCodesAsText = this._getCodesFromSamples(entity.parents);
+			if(allParentCodesAsText.length > 0) {
+				$newInspectorTable
+					.append($("<tr>")
+								.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append("Parents:")))
+								.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(allParentCodesAsText)))
+							);
+			}
+				
+			//Show Children Codes
+			var allChildrenCodesAsText = this._getCodesFromSamples(entity.children);
+			if(allChildrenCodesAsText.length > 0) {
+				$newInspectorTable
 				.append($("<tr>")
-							.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append("Parents:")))
-							.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(allParentCodesAsText)))
+							.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append("Children:")))
+							.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(allChildrenCodesAsText)))
 						);
+			}
 		}
-			
-		//Show Children Codes
-		var allChildrenCodesAsText = this._getCodesFromSamples(entity.children);
-		if(allChildrenCodesAsText.length > 0) {
-			$newInspectorTable
-			.append($("<tr>")
-						.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLabel"}).append("Children:")))
-						.append($("<td>", { "class" : "property", "colspan" : "1" }).append($("<p>", { "class" : "inspectorLineBreak"}).append(allChildrenCodesAsText)))
-					);
-		}
-			
+		
 		//Show Modification Date
 		$newInspectorTable
 		.append($("<tr>")
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js
index 3ae82ed15da..4d3bfb815a8 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js
@@ -143,7 +143,7 @@ function SampleFormView(sampleFormController, sampleFormModel) {
 			$formTitle.append("&nbsp;");
 			var $printButton = $("<a>", { 'class' : 'btn btn-default'} ).append($('<span>', { 'class' : 'glyphicon glyphicon-print' }));
 			$printButton.click(function() {
-				PrintUtil.printSample(_this._sampleFormModel.sample);
+				PrintUtil.printEntity(_this._sampleFormModel.sample);
 			});
 			$formTitle.append($printButton);
 			//Edit
-- 
GitLab