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:
parent
7bc3b662e4
commit
7c91c4ae5a
@ -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];
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user