diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 78b9deae6..b84304757 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -594,7 +594,9 @@ RED.nodes = (function() { } allNodes.addNode(n); if (!nodeLinks[n.id]) { - nodeLinks[n.id] = {in:[],out:[]}; + nodeLinks[n.id] = { + inCount:[],outCount:[],in:[],out:[] + }; } } RED.events.emit('nodes:add',n); @@ -604,15 +606,19 @@ RED.nodes = (function() { if (l.source) { // Possible the node hasn't been added yet if (!nodeLinks[l.source.id]) { - nodeLinks[l.source.id] = {in:[],out:[]}; + nodeLinks[l.source.id] = {inCount:[],outCount:[],in:[],out:[]}; } nodeLinks[l.source.id].out.push(l); + nodeLinks[l.source.id].outCount[l.sourcePort] = (nodeLinks[l.source.id].outCount[l.sourcePort] || 0) + 1 + l.source.dirty = true; } if (l.target) { if (!nodeLinks[l.target.id]) { - nodeLinks[l.target.id] = {in:[],out:[]}; + nodeLinks[l.target.id] = {inCount:[],outCount:[],in:[],out:[]}; } nodeLinks[l.target.id].in.push(l); + nodeLinks[l.target.id].inCount[0] = (nodeLinks[l.target.id].inCount[0] || 0) + 1 + l.target.dirty = true; } if (l.source.z === l.target.z && linkTabMap[l.source.z]) { linkTabMap[l.source.z].push(l); @@ -761,15 +767,19 @@ RED.nodes = (function() { if (index != -1) { links.splice(index,1); if (l.source && nodeLinks[l.source.id]) { + l.source.dirty = true; var sIndex = nodeLinks[l.source.id].out.indexOf(l) if (sIndex !== -1) { nodeLinks[l.source.id].out.splice(sIndex,1) + nodeLinks[l.source.id].outCount[l.sourcePort]-- } } if (l.target && nodeLinks[l.target.id]) { + l.target.dirty = true; var tIndex = nodeLinks[l.target.id].in.indexOf(l) if (tIndex !== -1) { nodeLinks[l.target.id].in.splice(tIndex,1) + nodeLinks[l.target.id].inCount[0]-- } } if (l.source.z === l.target.z && linkTabMap[l.source.z]) { @@ -2706,6 +2716,16 @@ RED.nodes = (function() { } return []; }, + getNodeLinkCount: function(id,portType,index) { + if (nodeLinks[id]) { + if (portType === 1) { + return nodeLinks[id].inCount[index] || 0 + } else { + return nodeLinks[id].outCount[index] || 0 + } + } + return 0; + }, addWorkspace: addWorkspace, removeWorkspace: removeWorkspace, getWorkspaceOrder: function() { return workspacesOrder },