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

Show link targets for link call in subflow

fixes #3248
This commit is contained in:
Steve-Mcl 2022-04-12 22:11:34 +01:00
parent a7932da207
commit b9919b0a9c

View File

@ -48,7 +48,7 @@
<script type="text/javascript"> <script type="text/javascript">
(function() { (function() {
var treeList; let treeList;
function onEditPrepare(node,targetType) { function onEditPrepare(node,targetType) {
if (!node.links) { if (!node.links) {
@ -56,7 +56,7 @@
} }
node.oldLinks = []; node.oldLinks = [];
var activeSubflow = RED.nodes.subflow(node.z); const activeSubflow = RED.nodes.subflow(node.z);
treeList = $("<div>") treeList = $("<div>")
.css({width: "100%", height: "100%"}) .css({width: "100%", height: "100%"})
@ -76,10 +76,10 @@
RED.view.redraw(); RED.view.redraw();
} }
}); });
var candidateNodes = RED.nodes.filterNodes({type:targetType}); const candidateNodes = RED.nodes.filterNodes({type:targetType});
var candidateNodesCount = 0; let candidateNodesCount = 0;
var search = $("#node-input-link-target-filter").searchBox({ const search = $("#node-input-link-target-filter").searchBox({
style: "compact", style: "compact",
delay: 300, delay: 300,
change: function() { change: function() {
@ -88,7 +88,7 @@
treeList.treeList("filter", null); treeList.treeList("filter", null);
search.searchBox("count",""); search.searchBox("count","");
} else { } else {
var count = treeList.treeList("filter", function(item) { const count = treeList.treeList("filter", function(item) {
return item.label.toLowerCase().indexOf(val) > -1 || (item.node && item.node.type.toLowerCase().indexOf(val) > -1) return item.label.toLowerCase().indexOf(val) > -1 || (item.node && item.node.type.toLowerCase().indexOf(val) > -1)
}); });
search.searchBox("count",count+" / "+candidateNodesCount); search.searchBox("count",count+" / "+candidateNodesCount);
@ -96,9 +96,8 @@
} }
}); });
const flows = [];
var flows = []; const flowMap = {};
var flowMap = {};
if (activeSubflow) { if (activeSubflow) {
flowMap[activeSubflow.id] = { flowMap[activeSubflow.id] = {
@ -109,7 +108,10 @@
children: [] children: []
}; };
flows.push(flowMap[activeSubflow.id]) flows.push(flowMap[activeSubflow.id])
} else { }
if (!activeSubflow || node.type === "link call") {
// Only "Link Call" can look outside of its own subflow
// Link In and Link Out nodes outside of a subflow should be ignored
RED.nodes.eachWorkspace(function (ws) { RED.nodes.eachWorkspace(function (ws) {
flowMap[ws.id] = { flowMap[ws.id] = {
id: ws.id, id: ws.id,
@ -127,10 +129,9 @@
if (targetType === "link out" && n.mode === 'return') { if (targetType === "link out" && n.mode === 'return') {
// Link In nodes looking for Link Out nodes should not // Link In nodes looking for Link Out nodes should not
// include return-mode nodes. // include return-mode nodes.
return return;
} }
var isChecked = false; const isChecked = (node.links.indexOf(n.id) !== -1) || (n.links || []).indexOf(node.id) !== -1;
isChecked = (node.links.indexOf(n.id) !== -1) || (n.links||[]).indexOf(node.id) !== -1;
if (isChecked) { if (isChecked) {
node.oldLinks.push(n.id); node.oldLinks.push(n.id);
} }
@ -145,8 +146,8 @@
candidateNodesCount++; candidateNodesCount++;
} }
}); });
flows = flows.filter(function(f) { return f.children.length > 0 }) const flowsFiltered = flows.filter(function(f) { return f.children.length > 0 })
treeList.treeList('data',flows); treeList.treeList('data',flowsFiltered);
setTimeout(function() { setTimeout(function() {
treeList.treeList('show',node.z); treeList.treeList('show',node.z);
},100); },100);
@ -218,8 +219,6 @@
} }
function onAdd() { function onAdd() {
RED.actions.invoke("core:generate-node-names",this)
for (var i=0;i<this.links.length;i++) { for (var i=0;i<this.links.length;i++) {
var n = RED.nodes.node(this.links[i]); var n = RED.nodes.node(this.links[i]);
if (n && n.links.indexOf(this.id) === -1) { if (n && n.links.indexOf(this.id) === -1) {
@ -316,10 +315,7 @@
oneditsave: function() { oneditsave: function() {
onEditSave(this); onEditSave(this);
}, },
oneditresize: resizeNodeList, oneditresize: resizeNodeList
onadd: function() {
RED.actions.invoke("core:generate-node-names",this)
}
}); });
RED.nodes.registerType('link out',{ RED.nodes.registerType('link out',{