mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Do not assume subflows exist when deleting nodes
This commit is contained in:
parent
b4c92b457a
commit
9c8d9550a7
@ -835,35 +835,36 @@ RED.view = (function() {
|
|||||||
node.dirty = true;
|
node.dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
removedSubflowOutputs.sort(function(a,b) { return b.i-a.i});
|
if (removedSubflowOutputs.length > 0) {
|
||||||
for (i=0;i<removedSubflowOutputs.length;i++) {
|
removedSubflowOutputs.sort(function(a,b) { return b.i-a.i});
|
||||||
var output = removedSubflowOutputs[i];
|
for (i=0;i<removedSubflowOutputs.length;i++) {
|
||||||
activeSubflow.out.splice(output.i,1);
|
var output = removedSubflowOutputs[i];
|
||||||
var subflowRemovedLinks = [];
|
activeSubflow.out.splice(output.i,1);
|
||||||
var subflowMovedLinks = [];
|
var subflowRemovedLinks = [];
|
||||||
RED.nodes.eachLink(function(l) {
|
var subflowMovedLinks = [];
|
||||||
if (l.target.type == "subflow" && l.target.z == activeSubflow.id && l.target.i == output.i) {
|
RED.nodes.eachLink(function(l) {
|
||||||
subflowRemovedLinks.push(l);
|
if (l.target.type == "subflow" && l.target.z == activeSubflow.id && l.target.i == output.i) {
|
||||||
}
|
|
||||||
if (l.source.type == "subflow:"+activeSubflow.id) {
|
|
||||||
if (l.sourcePort == output.i) {
|
|
||||||
subflowRemovedLinks.push(l);
|
subflowRemovedLinks.push(l);
|
||||||
} else if (l.sourcePort > output.i) {
|
|
||||||
subflowMovedLinks.push(l);
|
|
||||||
}
|
}
|
||||||
|
if (l.source.type == "subflow:"+activeSubflow.id) {
|
||||||
|
if (l.sourcePort == output.i) {
|
||||||
|
subflowRemovedLinks.push(l);
|
||||||
|
} else if (l.sourcePort > output.i) {
|
||||||
|
subflowMovedLinks.push(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
subflowRemovedLinks.forEach(function(l) { RED.nodes.removeLink(l)});
|
||||||
|
subflowMovedLinks.forEach(function(l) { l.sourcePort--; });
|
||||||
|
|
||||||
|
removedLinks = removedLinks.concat(subflowRemovedLinks);
|
||||||
|
for (var j=output.i;j<activeSubflow.out.length;j++) {
|
||||||
|
activeSubflow.out[j].i--;
|
||||||
|
activeSubflow.out[j].dirty = true;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
subflowRemovedLinks.forEach(function(l) { RED.nodes.removeLink(l)});
|
|
||||||
subflowMovedLinks.forEach(function(l) { l.sourcePort--; });
|
|
||||||
|
|
||||||
removedLinks = removedLinks.concat(subflowRemovedLinks);
|
|
||||||
for (var j=output.i;j<activeSubflow.out.length;j++) {
|
|
||||||
activeSubflow.out[j].i--;
|
|
||||||
activeSubflow.out[j].dirty = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Assume 0/1 inputs
|
// Assume 0/1 inputs
|
||||||
|
|
||||||
if (removedSubflowInputs.length == 1) {
|
if (removedSubflowInputs.length == 1) {
|
||||||
var input = removedSubflowInputs[0];
|
var input = removedSubflowInputs[0];
|
||||||
var subflowRemovedInputLinks = [];
|
var subflowRemovedInputLinks = [];
|
||||||
@ -880,18 +881,20 @@ RED.view = (function() {
|
|||||||
$("#workspace-subflow-add-input").toggleClass("disabled",false);
|
$("#workspace-subflow-add-input").toggleClass("disabled",false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.eachNode(function(n) {
|
if (activeSubflow) {
|
||||||
if (n.type == "subflow:"+activeSubflow.id) {
|
RED.nodes.eachNode(function(n) {
|
||||||
n.changed = true;
|
if (n.type == "subflow:"+activeSubflow.id) {
|
||||||
n.inputs = activeSubflow.in.length;
|
n.changed = true;
|
||||||
n.outputs = activeSubflow.out.length;
|
n.inputs = activeSubflow.in.length;
|
||||||
while (n.outputs < n.ports.length) {
|
n.outputs = activeSubflow.out.length;
|
||||||
n.ports.pop();
|
while (n.outputs < n.ports.length) {
|
||||||
|
n.ports.pop();
|
||||||
|
}
|
||||||
|
n.resize = true;
|
||||||
|
n.dirty = true;
|
||||||
}
|
}
|
||||||
n.resize = true;
|
});
|
||||||
n.dirty = true;
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
moving_set = [];
|
moving_set = [];
|
||||||
if (removedNodes.length > 0) {
|
if (removedNodes.length > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user