From aed1d282e717fd4d387d9eda63bfdd7c6d4ecee7 Mon Sep 17 00:00:00 2001
From: cramakri <cramakri>
Date: Thu, 14 Nov 2013 14:27:55 +0000
Subject: [PATCH] BIS-549 SP-1006 : Swapped the order of the flowlane and
 flowcell

SVN: 30147
---
 .../1/as/webapps/sample-graph/html/webapp.js  | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/sample-graph/html/webapp.js b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/sample-graph/html/webapp.js
index 1120a17bc86..585e1d75b29 100644
--- a/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/sample-graph/html/webapp.js
+++ b/deep_sequencing_unit/source/core-plugins/ngs-sample-overview-graph/1/as/webapps/sample-graph/html/webapp.js
@@ -17,8 +17,8 @@ var FLOWLANE_SAMPLE_TYPE = "FLOWLANE";
 // The view is organized in columns that correspond to a sample type. The columns are defined here.
 // The order of the sample types here matches the bottom-up order of the sample types.
 var COLUMNS = [
-	{ type : FLOWLANE_SAMPLE_TYPE, label : "Flowlane", width : 200 },
 	{ type : FLOWCELL_SAMPLE_TYPE, label : "Flowcell", width : 200 },
+	{ type : FLOWLANE_SAMPLE_TYPE, label : "Flowlane", width : 200 },
 	{ type : "MULTIPLEX", label : "Multiplex", width : 300 },
 	{ type : "LIBRARY", label : "Library", width : 240 },
 	{ type : "ALIQUOT", label : "Aliquot", width : 400 },
@@ -50,6 +50,8 @@ openbisServer.useSession(webappContext.getSessionId());
 
 function parseJson(jsonString) { return eval('(' + jsonString + ')'); }
 
+function flowcellIdFromFlowlaneId(flowlaneId) { return flowlaneId.split(":")[0]; }
+
 /**
  * The node stores the information necessary for presenting the sample data in the graph.
  */
@@ -158,7 +160,7 @@ SampleGraphModel.prototype.requestFlowcellData = function(callback) {
 	// Collect the Flowcell code and spaces
 	var flowlaneIds = [];
 	this.samplesByType[FLOWLANE_SAMPLE_TYPE].forEach(function(flowlane) {
-		var flowcellId = flowlane.identifier.split(":")[0];
+		var flowcellId = flowcellIdFromFlowlaneId(flowlane.identifier);
 		var codeAndSpace = codeAndSpaceFromIdentifier(flowcellId);
 		flowlaneIds.push(codeAndSpace);
 	});
@@ -253,18 +255,11 @@ SampleGraphModel.prototype.coalesceGraphData = function(data, callback) {
 	// flowcell should become the parent of the flowlanes.
 	var flowcellsByIdentifier = this.flowcellsByIdentifier;
 	this.samplesByType[FLOWLANE_SAMPLE_TYPE].forEach(function(flowlane) {
-		var flowcellId = flowlane.identifier.split(":")[0];
+		var flowcellId = flowcellIdFromFlowlaneId(flowlane.identifier);
 		var flowcell = flowcellsByIdentifier[flowcellId];
 		if (flowcell) {
-			var parents = flowcell.parents;
-			parents = parents.concat(flowlane.parents);
-			flowcell.parents = parents;
-			flowcell.children.push(flowlane);
-			flowlane.parents.forEach(function(parent) {
-				var children = parent.children;
-				children.splice(children.indexOf(flowlane), 1, flowcell);
-			})
-			flowlane.parents = [flowcell];
+			flowcell.parents.push(flowlane);
+			flowlane.children.push(flowcell);
 		}
 	});
 }
-- 
GitLab