From d975877601ba884ab006b6a4da88b021ddb9f36b Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Tue, 18 Aug 2015 12:19:43 +0000
Subject: [PATCH] SSDM-2293 : Backwards compatible grid with multiple selected
 positions available.

SVN: 34490
---
 .../views/StorageManager/widgets/GridController.js |  4 ++--
 .../js/views/StorageManager/widgets/GridModel.js   |  6 +++++-
 .../js/views/StorageManager/widgets/GridView.js    | 14 ++++++++++++--
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridController.js
index 706a5601285..671461b0ece 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridController.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridController.js
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-function GridController() {
-	this._gridModel = new GridModel();
+function GridController(isSelectMultiple) {
+	this._gridModel = new GridModel(isSelectMultiple);
 	this._gridView = new GridView(this._gridModel);
 	
 	this.init = function($container) {
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridModel.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridModel.js
index 549d2537795..62c110c101f 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridModel.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridModel.js
@@ -14,8 +14,12 @@
  * limitations under the License.
  */
 
-function GridModel() {
+function GridModel(isSelectMultiple) {
 	this.isDisabled = false;
+	this.isSelectMultiple = false;
+	if(isSelectMultiple) {
+		this.isSelectMultiple = true;
+	}
 	this.numRows = null;
 	this.numColumns = null;
 	this.labels = null;
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridView.js
index 4955e675717..97df155da5e 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridView.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/GridView.js
@@ -105,11 +105,21 @@ function GridView(gridModel) {
 	
 	this._selectPosition = function(posX, posY, label) { //To give user feedback so he knows what he have selected
 		if(this._gridTable && posX > 0 && posY > 0) {//API only available if the table is loaded and 0 positions are labels that can't be selected
-			this._gridTable.find("td").removeClass("rackSelected");
+			if(!this._gridModel.isSelectMultiple) {
+				this._gridTable.find("td").removeClass("rackSelected");
+			}
+			
 			var rows = this._gridTable.find("tr");
 			var columns = $(rows[posX]).find("td");
 			var cell = $(columns[posY-1]); //-1 because the th tag is skipped by the selector
-			cell.addClass("rackSelected");
+			var cellClasses = cell.attr("class");
+			
+			if(this._gridModel.isSelectMultiple && cellClasses && cellClasses.indexOf("rackSelected") !== -1) {
+				cell.removeClass("rackSelected");
+			} else {
+				cell.addClass("rackSelected");
+			}
+			
 		}
 	}
 	
-- 
GitLab