From 19f2eb75aa7bd2bb6b98a664cb445b567295854b Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Thu, 10 Mar 2016 09:18:51 +0000
Subject: [PATCH] SSDM-3292 : Fixing problems on side menu widget.

SVN: 35860
---
 .../js/views/SideMenu/SideMenuWidgetView.js   | 32 ++++++++++---------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
index 2ec32c085a1..1889681ad64 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js
@@ -294,27 +294,29 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) {
         while(todo.length > 0) {
         	var modelNode = todo.shift();
         	
+			//Add Root Source if not found
+			var treeModelRoot = null;
+			if(!sourceByKey[modelNode.uniqueId]) {
+				treeModelRoot = {title : modelNode.displayName, key : modelNode.uniqueId, menuData : modelNode};
+				treeModel.push(treeModelRoot);
+				sourceByKey[modelNode.uniqueId] = treeModelRoot;
+			} else {
+				treeModelRoot = sourceByKey[modelNode.uniqueId];
+			}
+			
+			//Create children if new
+    		if(modelNode.newMenuIfSelected && !treeModelRoot.children) {
+    			treeModelRoot.folder = true;
+    			treeModelRoot.children = [];
+    		}
+    		
         	if(modelNode.newMenuIfSelected && modelNode.newMenuIfSelected.children.length !== 0) {
         		for(var cIdx = 0; cIdx < modelNode.newMenuIfSelected.children.length; cIdx++) {
         			var modelNodeChild = modelNode.newMenuIfSelected.children[cIdx];
         			var $titleWithLink = this._getDisplayNameLinkForNode(modelNodeChild, true);
         			var treeModelChild = {title : $titleWithLink.outerHTML, key : modelNodeChild.uniqueId, menuData : modelNodeChild};
         			
-        			//Add Source if not found
-        			var treeModelRoot = null;
-        			if(!sourceByKey[modelNode.uniqueId]) {
-        				treeModelRoot = {title : modelNode.displayName, key : modelNode.uniqueId, menuData : modelNode};
-        				treeModel.push(treeModelRoot);
-        				sourceByKey[modelNode.uniqueId] = treeModelRoot;
-        			} else {
-        				treeModelRoot = sourceByKey[modelNode.uniqueId];
-        			}
-        			
-        			//Create children if new
-        			treeModelRoot.folder = true;
-            		if(!treeModelRoot.children) {
-            			treeModelRoot.children = [];
-            		}
+        			//Add Child
             		treeModelRoot.children.push(treeModelChild);
             		
             		//Push child for next
-- 
GitLab