mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Ensure importing link nodes to a subflow doesn't add outbound links
Fixes #921
This commit is contained in:
parent
8608d010b8
commit
12e46deea2
@ -904,8 +904,14 @@ RED.nodes = (function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If importing into a subflow, ensure an outbound-link doesn't
|
||||
// get added
|
||||
if (activeSubflow && /^link /.test(n.type) && n.links) {
|
||||
n.links = n.links.filter(function(id) {
|
||||
var otherNode = RED.nodes.node(id);
|
||||
return (otherNode && otherNode.z === activeWorkspace)
|
||||
});
|
||||
}
|
||||
}
|
||||
for (i=0;i<new_subflows.length;i++) {
|
||||
n = new_subflows[i];
|
||||
|
@ -420,7 +420,7 @@ RED.subflow = (function() {
|
||||
RED.notify(RED._("subflow.errors.noNodesSelected"),"error");
|
||||
return;
|
||||
}
|
||||
var i;
|
||||
var i,n;
|
||||
var nodes = {};
|
||||
var new_links = [];
|
||||
var removedLinks = [];
|
||||
@ -436,7 +436,7 @@ RED.subflow = (function() {
|
||||
selection.nodes[0].y];
|
||||
|
||||
for (i=0;i<selection.nodes.length;i++) {
|
||||
var n = selection.nodes[i];
|
||||
n = selection.nodes[i];
|
||||
nodes[n.id] = {n:n,outputs:{}};
|
||||
boundingBox = [
|
||||
Math.min(boundingBox[0],n.x),
|
||||
@ -573,7 +573,23 @@ RED.subflow = (function() {
|
||||
}
|
||||
|
||||
for (i=0;i<selection.nodes.length;i++) {
|
||||
selection.nodes[i].z = subflow.id;
|
||||
n = selection.nodes[i];
|
||||
if (/^link /.test(n.type)) {
|
||||
n.links = n.links.filter(function(id) {
|
||||
var isLocalLink = nodes.hasOwnProperty(id);
|
||||
if (!isLocalLink) {
|
||||
var otherNode = RED.nodes.node(id);
|
||||
if (otherNode && otherNode.links) {
|
||||
var i = otherNode.links.indexOf(n.id);
|
||||
if (i > -1) {
|
||||
otherNode.links.splice(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return isLocalLink;
|
||||
});
|
||||
}
|
||||
n.z = subflow.id;
|
||||
}
|
||||
|
||||
RED.history.push({
|
||||
@ -589,7 +605,7 @@ RED.subflow = (function() {
|
||||
|
||||
dirty:RED.nodes.dirty()
|
||||
});
|
||||
|
||||
RED.view.select(null);
|
||||
RED.editor.validateNode(subflow);
|
||||
RED.nodes.dirty(true);
|
||||
RED.view.redraw(true);
|
||||
|
Loading…
Reference in New Issue
Block a user