From 6749e654034428c66734c687ddf7e2a39a26f509 Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Fri, 7 Jul 2017 13:39:56 +0000
Subject: [PATCH] SSDM-5304 : Show Storage names instead of codes

SVN: 38508
---
 .../dist/core-plugins/eln-lims/1/as/elnTypes.py       |  2 +-
 .../views/SampleForm/widgets/StorageListController.js | 11 ++++++++++-
 .../js/views/SampleForm/widgets/StorageListView.js    | 11 +++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py
index 0eb88dc5f62..d3a9d699785 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py
@@ -932,7 +932,7 @@ STORAGE_RACK = [MANDATORY_ITEM_VERSION, False, "STORAGE", "", [
 ]];
 
 STORAGE_POSITION = [MANDATORY_ITEM_VERSION, False, "STORAGE_POSITION", "", [
-    [FIRST_TIME_VERSIONED, "STORAGE_CODE",                  "Physical Storage",        "Storage Object Code",       DataType.VARCHAR,                    None,                "Storage Object Code",     None, None, False, False],
+    [FIRST_TIME_VERSIONED, "STORAGE_CODE",                  "Physical Storage",        "Storage Code",              DataType.VARCHAR,                    None,                "Storage Code",            None, None, False, False],
     [FIRST_TIME_VERSIONED, "STORAGE_RACK_ROW",              "Physical Storage",        "Storage Rack Row",          DataType.INTEGER,                    None,                "Storage Rack Row",        None, None, False, False],
     [FIRST_TIME_VERSIONED, "STORAGE_RACK_COLUMN",           "Physical Storage",        "Storage Rack Column",       DataType.INTEGER,                    None,                "Storage Rack Column",     None, None, False, False],
     [FIRST_TIME_VERSIONED, "STORAGE_BOX_NAME",              "Physical Storage",        "Storage Box Name",          DataType.VARCHAR,                    None,                "Storage Box Name",        None, None, False, False],
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListController.js
index 96e8f229940..6dddae85b54 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListController.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListController.js
@@ -19,7 +19,16 @@ function StorageListController(sample, isDisabled) {
 	this._storageListView = new StorageListView(this, this._storageListModel);
 	
 	this.init = function($container) {
-		this._storageListView.repaint($container);
+		var _this = this;
+		profile.getStoragesConfiguation(function(configurations) {
+			_this._storageListModel.storageLabels = {};
+			if(configurations) {
+				for(var idx = 0; idx < configurations.length; idx++) {
+					_this._storageListModel.storageLabels[configurations[idx].code] = configurations[idx].label;
+				}
+			}
+			_this._storageListView.repaint($container);
+		});
 	}
 	
 	this._saveState = function(sampleChild, storagePropGroup){
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListView.js
index 700e5f8ed2f..aebf593dc91 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListView.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListView.js
@@ -67,6 +67,13 @@ function StorageListView(storageListController, storageListModel) {
 				return sortDirection * naturalSort(value1, value2);
 			}
 		});
+		columns.push({
+			label : 'Storage Name',
+			property : 'storageName',
+			isExportable: false,
+			sortable : true,
+			showByDefault: true
+		});
 		
 		var storagePropertyCodes = profile.getAllPropertiCodesForTypeCode("STORAGE_POSITION");
 		var storagePropertyCodesAsMap = {};
@@ -115,6 +122,10 @@ function StorageListView(storageListController, storageListModel) {
 						object[propertyCode] = sample.properties[propertyCode];
 					}
 				}
+				
+				if(sample && sample.properties && sample.properties[profile.getStoragePropertyGroup().nameProperty]) {
+					object.storageName = _this._storageListModel.storageLabels[sample.properties[profile.getStoragePropertyGroup().nameProperty]];
+				}
 				dataList.push(object);
 			}
 			callback(dataList);
-- 
GitLab