From f09e97426d30c6b6c9e293c225d30d10ddee3b3b Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Mon, 8 Jan 2018 13:24:24 +0000
Subject: [PATCH] SSDM-6003 : ELN Storage positions UI, hidden from children,
 shown on their own column as links.

SVN: 39082
---
 .../eln-lims/html/js/server/ServerFacade.js   |  8 ++--
 .../js/views/DataGrid/SampleDataGridUtil.js   | 45 ++++++++++++++++++-
 2 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
index 1539bec628d..25f6fef0271 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
@@ -897,12 +897,14 @@ function ServerFacade(openbisServer) {
 						fetchOptions.withParents();
 					}
 					if(fetchOptions.withChildren) {
-						fetchOptions.withChildren();
+						var childrenFetchOptions = fetchOptions.withChildren();
+						if(advancedFetchOptions.withChildrenInfo) {
+							childrenFetchOptions.withType();
+							childrenFetchOptions.withProperties();
+						}
 					}
 				}
 				
-				
-				
 				if(advancedFetchOptions && advancedFetchOptions.cache) {
 					fetchOptions.cacheMode(advancedFetchOptions.cache);
 				}
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
index 52b50aab9f5..b1d67f24a1f 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
@@ -96,6 +96,40 @@ var SampleDataGridUtil = new function() {
 			isExportable: false,
 			sortable : false
 		});
+		
+		columnsFirst.push({
+			label : 'Storage',
+			property : 'storage',
+			isExportable: false,
+			sortable : false,
+			render : function(data) {
+				var storage = $("<span>");
+				if(data["$object"].children) {
+					var isFirst = true;
+					for (var cIdx = 0; cIdx < data['$object'].children.length; cIdx++) {
+						if(data['$object'].children[cIdx].sampleTypeCode == "STORAGE_POSITION") {
+							storageData = data['$object'].children[cIdx].properties;
+							var storagePropertyGroup = profile.getStoragePropertyGroup();
+							var boxProperty = storageData[storagePropertyGroup.boxProperty];
+							if(!boxProperty) {
+								boxProperty = "NoBox";
+							}
+							var positionProperty = storageData[storagePropertyGroup.positionProperty];
+							if(!positionProperty) {
+								positionProperty = "NoPos";
+							}
+							var displayName = boxProperty + " : " + positionProperty;
+							if(!isFirst) {
+								storage.append("<br>");
+							}
+							storage.append(FormUtil.getFormLink(displayName, "Sample", data['$object'].children[cIdx].permId));
+							isFirst = false;
+						}
+					}
+				}
+				return storage;
+			}
+		});
 
 		if(withExperiment) {
 			columnsFirst.push({
@@ -342,11 +376,17 @@ var SampleDataGridUtil = new function() {
 					
 					var children = "";
 					if(sample.children) {
+						var isFirst = true;
 						for (var caIdx = 0; caIdx < sample.children.length; caIdx++) {
-							if(caIdx !== 0) {
+							if(sample.children[caIdx].sampleTypeCode === "STORAGE_POSITION") {
+								continue;
+							}
+							
+							if(!isFirst) {
 								children += ", ";
 							}
 							children += sample.children[caIdx].identifier;
+							isFirst = false;
 						}
 					}
 					
@@ -363,7 +403,8 @@ var SampleDataGridUtil = new function() {
 			
 			var fetchOptions = {
 					minTableInfo : true,
-					withExperiment : withExperiment
+					withExperiment : withExperiment,
+					withChildrenInfo : true
 			};
 			
 			if(options) {
-- 
GitLab