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

[groups] Prevent subflow port nodes being added group

This commit is contained in:
Nick O'Leary 2020-03-24 14:05:35 +00:00
parent 7bc3b662e4
commit 7c91c4ae5a
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 21 additions and 12 deletions

View File

@ -345,6 +345,10 @@ RED.group = (function() {
if (nodes.length === 0) { if (nodes.length === 0) {
return; return;
} }
if (nodes.filter(function(n) { return n.type === "subflow" }).length > 0) {
RED.notify("Cannot add subflow ports to a group","error");
return;
}
// nodes is an array // nodes is an array
// each node must be on the same tab (z) // each node must be on the same tab (z)
var group = { var group = {
@ -416,22 +420,27 @@ RED.group = (function() {
// Second pass - add them to the group // Second pass - add them to the group
for (i=0;i<nodes.length;i++) { for (i=0;i<nodes.length;i++) {
n = nodes[i]; n = nodes[i];
if (g && n.g === g.id) { if (n.type !== "subflow") {
var ni = g.nodes.indexOf(n); if (g && n.g === g.id) {
if (ni > -1) { var ni = g.nodes.indexOf(n);
g.nodes.splice(ni,1) if (ni > -1) {
g.nodes.splice(ni,1)
}
} }
n.g = group.id;
n.dirty = true;
group.nodes.push(n);
group.x = Math.min(group.x,n.x-n.w/2-25-((n._def.button && n._def.align!=="right")?20:0));
group.y = Math.min(group.y,n.y-n.h/2-25);
group.w = Math.max(group.w,n.x+n.w/2+25+((n._def.button && n._def.align=="right")?20:0) - group.x);
group.h = Math.max(group.h,n.y+n.h/2+25-group.y);
} }
n.g = group.id;
n.dirty = true;
group.nodes.push(n);
group.x = Math.min(group.x,n.x-n.w/2-25-((n._def.button && n._def.align!=="right")?20:0));
group.y = Math.min(group.y,n.y-n.h/2-25);
group.w = Math.max(group.w,n.x+n.w/2+25+((n._def.button && n._def.align=="right")?20:0) - group.x);
group.h = Math.max(group.h,n.y+n.h/2+25-group.y);
} }
markDirty(group);
} }
function removeFromGroup(group, nodes, reparent) { function removeFromGroup(group, nodes, reparent) {
console.log('rfg',group,nodes);
if (!Array.isArray(nodes)) { if (!Array.isArray(nodes)) {
nodes = [nodes]; nodes = [nodes];
} }

View File

@ -1382,7 +1382,7 @@ if (DEBUG_EVENTS) { console.warn("canvasMouseDown", mouse_mode); }
},100); },100);
} }
} }
if (!node.n.g && activeGroups) { if (node.n.type !== 'subflow' && !node.n.g && activeGroups) {
if (!groupHoverTimer) { if (!groupHoverTimer) {
groupHoverTimer = setTimeout(function() { groupHoverTimer = setTimeout(function() {
activeHoverGroup = getGroupAt(node.n.x,node.n.y); activeHoverGroup = getGroupAt(node.n.x,node.n.y);