mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	[groups] Show group info when selected in sidebar
This commit is contained in:
		| @@ -236,7 +236,7 @@ RED.sidebar.info = (function() { | ||||
|                     } | ||||
|                 } | ||||
|                 var count = 0; | ||||
|                 if (!m && node.type != "subflow") { | ||||
|                 if (!m && node.type != "subflow" && node.type != "group") { | ||||
|                     var defaults; | ||||
|                     if (node.type === 'unknown') { | ||||
|                         defaults = {}; | ||||
|   | ||||
| @@ -1717,16 +1717,7 @@ if (DEBUG_EVENTS) { console.warn("clearSelection", mouse_mode); } | ||||
|  | ||||
|         var workspaceSelection = RED.workspaces.selection(); | ||||
|         if (workspaceSelection.length === 0) { | ||||
|             if (moving_set.length > 0) { | ||||
|                 selection.nodes = moving_set.map(function(n) { return n.n;}); | ||||
|             } | ||||
|             if (selected_link != null) { | ||||
|                 selection.link = selected_link; | ||||
|             } | ||||
|             selection.groups = activeGroups.filter(function(g) { return g.selected }) | ||||
|             if (selection.groups.length === 0) { | ||||
|                 delete selection.groups; | ||||
|             } | ||||
|             selection = getSelection(); | ||||
|             activeLinks = RED.nodes.filterLinks({ | ||||
|                 source:{z:activeWorkspace}, | ||||
|                 target:{z:activeWorkspace} | ||||
| @@ -1810,7 +1801,7 @@ if (DEBUG_EVENTS) { console.warn("clearSelection", mouse_mode); } | ||||
|             selection.flows = workspaceSelection; | ||||
|         } | ||||
|         var selectionJSON = activeWorkspace+":"+JSON.stringify(selection,function(key,value) { | ||||
|             if (key === 'nodes' || key === 'flows' || key === 'groups') { | ||||
|             if (key === 'nodes' || key === 'flows') { | ||||
|                 return value.map(function(n) { return n.id }) | ||||
|             } else if (key === 'link') { | ||||
|                 return value.source.id+":"+value.sourcePort+":"+value.target.id; | ||||
| @@ -2569,6 +2560,7 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseUp", mouse_mode,d); } | ||||
|                 mouse[0] += d.x-d.w/2; | ||||
|                 mouse[1] += d.y-d.h/2; | ||||
|                 prepareDrag(mouse); | ||||
|                 updateSelection(); | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
| @@ -4433,6 +4425,39 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); } | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
|     function getSelection() { | ||||
|         var selection = {}; | ||||
|  | ||||
|         var allNodes = new Set(); | ||||
|  | ||||
|         if (moving_set.length > 0) { | ||||
|             moving_set.forEach(function(n) { | ||||
|                 allNodes.add(n.n); | ||||
|             }); | ||||
|         } | ||||
|         var selectedGroups =  activeGroups.filter(function(g) { return g.selected && !g.active }); | ||||
|         if (selectedGroups.length > 0) { | ||||
|             if (selectedGroups.length === 1 && selectedGroups[0].active) { | ||||
|                 // Let nodes be nodes | ||||
|             } else { | ||||
|                 selectedGroups.forEach(function(g) { | ||||
|                     var groupNodes = RED.group.getNodes(g,true); | ||||
|                     groupNodes.forEach(function(n) { | ||||
|                         allNodes.delete(n); | ||||
|                     }); | ||||
|                     allNodes.add(g); | ||||
|                 }); | ||||
|             } | ||||
|         } | ||||
|         if (allNodes.size > 0) { | ||||
|             selection.nodes = Array.from(allNodes); | ||||
|         } | ||||
|         if (selected_link != null) { | ||||
|             selection.link = selected_link; | ||||
|         } | ||||
|         return selection; | ||||
|     } | ||||
|     return { | ||||
|         init: init, | ||||
|         state:function(state) { | ||||
| @@ -4486,38 +4511,8 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); } | ||||
|             updateSelection(); | ||||
|             redraw(true); | ||||
|         }, | ||||
|         selection: function() { | ||||
|             var selection = {}; | ||||
|         selection: getSelection, | ||||
|  | ||||
|             var allNodes = new Set(); | ||||
|  | ||||
|             if (moving_set.length > 0) { | ||||
|                 moving_set.forEach(function(n) { | ||||
|                     allNodes.add(n.n); | ||||
|                 }); | ||||
|             } | ||||
|             var selectedGroups =  activeGroups.filter(function(g) { return g.selected && !g.active }); | ||||
|             if (selectedGroups.length > 0) { | ||||
|                 if (selectedGroups.length === 1 && selectedGroups[0].active) { | ||||
|                     // Let nodes be nodes | ||||
|                 } else { | ||||
|                     selectedGroups.forEach(function(g) { | ||||
|                         var groupNodes = RED.group.getNodes(g,true); | ||||
|                         groupNodes.forEach(function(n) { | ||||
|                             allNodes.delete(n); | ||||
|                         }); | ||||
|                         allNodes.add(g); | ||||
|                     }); | ||||
|                 } | ||||
|             } | ||||
|             if (allNodes.size > 0) { | ||||
|                 selection.nodes = Array.from(allNodes); | ||||
|             } | ||||
|             if (selected_link != null) { | ||||
|                 selection.link = selected_link; | ||||
|             } | ||||
|             return selection; | ||||
|         }, | ||||
|         scale: function() { | ||||
|             return scaleFactor; | ||||
|         }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user