mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #3652 from node-red-hitachi/fix-junction-to-subflow
Fix conversion of junction to subflow
This commit is contained in:
@@ -604,6 +604,14 @@ RED.subflow = (function() {
|
||||
return x;
|
||||
}
|
||||
|
||||
function nodeOrJunction(id) {
|
||||
var node = RED.nodes.node(id);
|
||||
if (node) {
|
||||
return node;
|
||||
}
|
||||
return RED.nodes.junction(id);
|
||||
}
|
||||
|
||||
function convertToSubflow() {
|
||||
var selection = RED.view.selection();
|
||||
if (!selection.nodes) {
|
||||
@@ -792,14 +800,15 @@ RED.subflow = (function() {
|
||||
|
||||
subflow.in.forEach(function(input) {
|
||||
input.wires.forEach(function(wire) {
|
||||
var link = {source: input, sourcePort: 0, target: RED.nodes.node(wire.id) }
|
||||
var link = {source: input, sourcePort: 0, target: nodeOrJunction(wire.id) }
|
||||
new_links.push(link);
|
||||
RED.nodes.addLink(link);
|
||||
});
|
||||
});
|
||||
|
||||
subflow.out.forEach(function(output,i) {
|
||||
output.wires.forEach(function(wire) {
|
||||
var link = {source: RED.nodes.node(wire.id), sourcePort: wire.port , target: output }
|
||||
var link = {source: nodeOrJunction(wire.id), sourcePort: wire.port , target: output }
|
||||
new_links.push(link);
|
||||
RED.nodes.addLink(link);
|
||||
});
|
||||
@@ -815,7 +824,7 @@ RED.subflow = (function() {
|
||||
n.links = n.links.filter(function(id) {
|
||||
var isLocalLink = nodes.hasOwnProperty(id);
|
||||
if (!isLocalLink) {
|
||||
var otherNode = RED.nodes.node(id);
|
||||
var otherNode = nodeOrJunction(id);
|
||||
if (otherNode && otherNode.links) {
|
||||
var i = otherNode.links.indexOf(n.id);
|
||||
if (i > -1) {
|
||||
@@ -831,7 +840,6 @@ RED.subflow = (function() {
|
||||
RED.nodes.moveNodeToTab(n, subflow.id);
|
||||
}
|
||||
|
||||
|
||||
var historyEvent = {
|
||||
t:'createSubflow',
|
||||
nodes:[subflowInstance.id],
|
||||
|
Reference in New Issue
Block a user