From 9c180a0ca635d3ba29a84ef89f48053a1c9d3a7f Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Tue, 15 Mar 2016 09:59:45 +0000
Subject: [PATCH] SSDM-3292 : Making text of grids have a max length for all
 grids.

SVN: 35898
---
 .../html/js/controllers/MainController.js     |  2 +-
 .../views/DataGrid/ExperimentDataGridUtil.js  | 17 +----------------
 .../js/views/DataGrid/SampleDataGridUtil.js   | 19 ++-----------------
 .../webapps/eln-lims/html/lib/grid/js/Grid.js |  6 +++++-
 4 files changed, 9 insertions(+), 35 deletions(-)

diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js
index 39f12f7cf98..7d6d0fb1fc8 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js
@@ -722,7 +722,7 @@ function MainController(profile) {
 										permId : sample.permId,
 										code : sample.code,
 										sampleTypeCode : sample.sampleTypeCode,
-										matched : $container
+										matched : $container[0].outerHTML
 									});
 								}
 								
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/ExperimentDataGridUtil.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/ExperimentDataGridUtil.js
index 8d0608b2116..ae53e20ad46 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/ExperimentDataGridUtil.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/ExperimentDataGridUtil.js
@@ -79,26 +79,11 @@ var ExperimentDataGridUtil = new function() {
 				var newVocabularyColumnFunc = getVocabularyColumn(propertyType);
 				propertyColumnsToSort.push(newVocabularyColumnFunc());
 			} else {
-				var maxLineLength = 300;
-				var getRenderFunction = function(propertyType) {
-					return function(data) {
-						var propValue = data[propertyType.code];
-						if(propValue) {
-							propValue = propValue.substring(0, maxLineLength);
-							if(data[propertyType.code].length > maxLineLength) {
-								propValue += "...";
-							}
-						}
-						return propValue;
-					}
-				}
-				
 				propertyColumnsToSort.push({
 					label : propertyCodesDisplayNames[idx],
 					property : propertyCodes[idx],
 					isExportable: true,
-					sortable : true,
-					render : getRenderFunction(propertyType)
+					sortable : true
 				});
 			}
 		}
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
index 8349321e516..0ddf7a25aaf 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataGrid/SampleDataGridUtil.js
@@ -135,27 +135,12 @@ var SampleDataGridUtil = new function() {
 				
 				var newVocabularyColumnFunc = getVocabularyColumn(propertyType);
 				propertyColumnsToSort.push(newVocabularyColumnFunc());
-			} else {
-				var maxLineLength = 300;
-				var getRenderFunction = function(propertyType) {
-					return function(data) {
-						var propValue = data[propertyType.code];
-						if(propValue) {
-							propValue = propValue.substring(0, maxLineLength);
-							if(data[propertyType.code].length > maxLineLength) {
-								propValue += "...";
-							}
-						}
-						return propValue;
-					}
-				}
-					
+			} else {			
 				propertyColumnsToSort.push({
 					label : propertyCodesDisplayNames[idx],
 					property : propertyCodes[idx],
 					isExportable: true,
-					sortable : true,
-					render : getRenderFunction(propertyType)
+					sortable : true
 				});
 			}
 		}
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/lib/grid/js/Grid.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/lib/grid/js/Grid.js
index a8bc475d038..c33344f1a0a 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/lib/grid/js/Grid.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/lib/grid/js/Grid.js
@@ -335,7 +335,8 @@ $.extend(Grid.prototype, {
 	renderData : function(dataList) {
 		var thisGrid = this;
 		var items = [];
-
+		var maxLineLength = 300;
+		
 		dataList.forEach(function(data) {
 			var item = {};
 			thisGrid.getVisibleColumns().forEach(function(column) {
@@ -344,6 +345,9 @@ $.extend(Grid.prototype, {
 					value = column.render(data);
 				} else {
 					value = data[column.property];
+					if(value && value.length > maxLineLength) {
+						value = value.substring(0, maxLineLength) + "...";
+					}
 				}
 				item[column.property] = FormUtil.sanitizeRichHTMLText(value);
 			});
-- 
GitLab