mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3528 from Steve-Mcl/link-list-in-subflow
Display link targets of nodes in a regular flow, for Link Call nodes inside a subflow
This commit is contained in:
commit
330ddfa3ad
@ -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,25 +96,27 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const flows = [];
|
||||||
var flows = [];
|
const flowMap = {};
|
||||||
var flowMap = {};
|
|
||||||
|
|
||||||
if (activeSubflow) {
|
if (activeSubflow) {
|
||||||
flowMap[activeSubflow.id] = {
|
flowMap[activeSubflow.id] = {
|
||||||
id: activeSubflow.id,
|
id: activeSubflow.id,
|
||||||
class: 'red-ui-palette-header',
|
class: 'red-ui-palette-header',
|
||||||
label: "Subflow : "+(activeSubflow.name || activeSubflow.id),
|
label: "Subflow : " + (activeSubflow.name || activeSubflow.id),
|
||||||
expanded: true,
|
expanded: true,
|
||||||
children: []
|
children: []
|
||||||
};
|
};
|
||||||
flows.push(flowMap[activeSubflow.id])
|
flows.push(flowMap[activeSubflow.id])
|
||||||
} else {
|
}
|
||||||
RED.nodes.eachWorkspace(function(ws) {
|
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) {
|
||||||
flowMap[ws.id] = {
|
flowMap[ws.id] = {
|
||||||
id: ws.id,
|
id: ws.id,
|
||||||
class: 'red-ui-palette-header',
|
class: 'red-ui-palette-header',
|
||||||
label: (ws.label || ws.id)+(node.z===ws.id ? " *":""),
|
label: (ws.label || ws.id) + (node.z === ws.id ? " *" : ""),
|
||||||
expanded: true,
|
expanded: true,
|
||||||
children: []
|
children: []
|
||||||
}
|
}
|
||||||
@ -122,22 +124,21 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
candidateNodes.forEach(function(n) {
|
candidateNodes.forEach(function (n) {
|
||||||
if (flowMap[n.z]) {
|
if (flowMap[n.z]) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
flowMap[n.z].children.push({
|
flowMap[n.z].children.push({
|
||||||
id: n.id,
|
id: n.id,
|
||||||
node: n,
|
node: n,
|
||||||
label: n.name||n.id,
|
label: n.name || n.id,
|
||||||
selected: isChecked,
|
selected: isChecked,
|
||||||
checkbox: node.type !== "link call",
|
checkbox: node.type !== "link call",
|
||||||
radio: node.type === "link call"
|
radio: node.type === "link call"
|
||||||
@ -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',{
|
||||||
|
Loading…
Reference in New Issue
Block a user