1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

[groups] Show group info when selected in sidebar

This commit is contained in:
Nick O'Leary 2020-03-16 11:16:18 +00:00
parent 266df86d98
commit a8bc753720
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 38 additions and 43 deletions

View File

@ -236,7 +236,7 @@ RED.sidebar.info = (function() {
} }
} }
var count = 0; var count = 0;
if (!m && node.type != "subflow") { if (!m && node.type != "subflow" && node.type != "group") {
var defaults; var defaults;
if (node.type === 'unknown') { if (node.type === 'unknown') {
defaults = {}; defaults = {};

View File

@ -1717,16 +1717,7 @@ if (DEBUG_EVENTS) { console.warn("clearSelection", mouse_mode); }
var workspaceSelection = RED.workspaces.selection(); var workspaceSelection = RED.workspaces.selection();
if (workspaceSelection.length === 0) { if (workspaceSelection.length === 0) {
if (moving_set.length > 0) { selection = getSelection();
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;
}
activeLinks = RED.nodes.filterLinks({ activeLinks = RED.nodes.filterLinks({
source:{z:activeWorkspace}, source:{z:activeWorkspace},
target:{z:activeWorkspace} target:{z:activeWorkspace}
@ -1810,7 +1801,7 @@ if (DEBUG_EVENTS) { console.warn("clearSelection", mouse_mode); }
selection.flows = workspaceSelection; selection.flows = workspaceSelection;
} }
var selectionJSON = activeWorkspace+":"+JSON.stringify(selection,function(key,value) { 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 }) return value.map(function(n) { return n.id })
} else if (key === 'link') { } else if (key === 'link') {
return value.source.id+":"+value.sourcePort+":"+value.target.id; 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[0] += d.x-d.w/2;
mouse[1] += d.y-d.h/2; mouse[1] += d.y-d.h/2;
prepareDrag(mouse); prepareDrag(mouse);
updateSelection();
return; 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 { return {
init: init, init: init,
state:function(state) { state:function(state) {
@ -4486,38 +4511,8 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
updateSelection(); updateSelection();
redraw(true); redraw(true);
}, },
selection: function() { selection: 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;
},
scale: function() { scale: function() {
return scaleFactor; return scaleFactor;
}, },