mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
a7932da207
commit
b9919b0a9c
@ -48,7 +48,7 @@
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
|
||||
var treeList;
|
||||
let treeList;
|
||||
|
||||
function onEditPrepare(node,targetType) {
|
||||
if (!node.links) {
|
||||
@ -56,7 +56,7 @@
|
||||
}
|
||||
node.oldLinks = [];
|
||||
|
||||
var activeSubflow = RED.nodes.subflow(node.z);
|
||||
const activeSubflow = RED.nodes.subflow(node.z);
|
||||
|
||||
treeList = $("<div>")
|
||||
.css({width: "100%", height: "100%"})
|
||||
@ -76,10 +76,10 @@
|
||||
RED.view.redraw();
|
||||
}
|
||||
});
|
||||
var candidateNodes = RED.nodes.filterNodes({type:targetType});
|
||||
var candidateNodesCount = 0;
|
||||
const candidateNodes = RED.nodes.filterNodes({type:targetType});
|
||||
let candidateNodesCount = 0;
|
||||
|
||||
var search = $("#node-input-link-target-filter").searchBox({
|
||||
const search = $("#node-input-link-target-filter").searchBox({
|
||||
style: "compact",
|
||||
delay: 300,
|
||||
change: function() {
|
||||
@ -88,7 +88,7 @@
|
||||
treeList.treeList("filter", null);
|
||||
search.searchBox("count","");
|
||||
} 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)
|
||||
});
|
||||
search.searchBox("count",count+" / "+candidateNodesCount);
|
||||
@ -96,25 +96,27 @@
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var flows = [];
|
||||
var flowMap = {};
|
||||
const flows = [];
|
||||
const flowMap = {};
|
||||
|
||||
if (activeSubflow) {
|
||||
flowMap[activeSubflow.id] = {
|
||||
id: activeSubflow.id,
|
||||
class: 'red-ui-palette-header',
|
||||
label: "Subflow : "+(activeSubflow.name || activeSubflow.id),
|
||||
label: "Subflow : " + (activeSubflow.name || activeSubflow.id),
|
||||
expanded: true,
|
||||
children: []
|
||||
};
|
||||
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] = {
|
||||
id: ws.id,
|
||||
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,
|
||||
children: []
|
||||
}
|
||||
@ -122,22 +124,21 @@
|
||||
})
|
||||
}
|
||||
|
||||
candidateNodes.forEach(function(n) {
|
||||
candidateNodes.forEach(function (n) {
|
||||
if (flowMap[n.z]) {
|
||||
if (targetType === "link out" && n.mode === 'return') {
|
||||
// Link In nodes looking for Link Out nodes should not
|
||||
// include return-mode nodes.
|
||||
return
|
||||
return;
|
||||
}
|
||||
var isChecked = false;
|
||||
isChecked = (node.links.indexOf(n.id) !== -1) || (n.links||[]).indexOf(node.id) !== -1;
|
||||
const isChecked = (node.links.indexOf(n.id) !== -1) || (n.links || []).indexOf(node.id) !== -1;
|
||||
if (isChecked) {
|
||||
node.oldLinks.push(n.id);
|
||||
}
|
||||
flowMap[n.z].children.push({
|
||||
id: n.id,
|
||||
node: n,
|
||||
label: n.name||n.id,
|
||||
label: n.name || n.id,
|
||||
selected: isChecked,
|
||||
checkbox: node.type !== "link call",
|
||||
radio: node.type === "link call"
|
||||
@ -145,8 +146,8 @@
|
||||
candidateNodesCount++;
|
||||
}
|
||||
});
|
||||
flows = flows.filter(function(f) { return f.children.length > 0 })
|
||||
treeList.treeList('data',flows);
|
||||
const flowsFiltered = flows.filter(function(f) { return f.children.length > 0 })
|
||||
treeList.treeList('data',flowsFiltered);
|
||||
setTimeout(function() {
|
||||
treeList.treeList('show',node.z);
|
||||
},100);
|
||||
@ -218,8 +219,6 @@
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
RED.actions.invoke("core:generate-node-names",this)
|
||||
|
||||
for (var i=0;i<this.links.length;i++) {
|
||||
var n = RED.nodes.node(this.links[i]);
|
||||
if (n && n.links.indexOf(this.id) === -1) {
|
||||
@ -316,10 +315,7 @@
|
||||
oneditsave: function() {
|
||||
onEditSave(this);
|
||||
},
|
||||
oneditresize: resizeNodeList,
|
||||
onadd: function() {
|
||||
RED.actions.invoke("core:generate-node-names",this)
|
||||
}
|
||||
oneditresize: resizeNodeList
|
||||
});
|
||||
|
||||
RED.nodes.registerType('link out',{
|
||||
|
Loading…
Reference in New Issue
Block a user