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

Allow a node to change if it has an input port

Closes #2268
This commit is contained in:
Nick O'Leary 2019-08-15 13:29:08 +01:00
parent 2daedf8fd5
commit b274bafe8e
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 17 additions and 5 deletions

View File

@ -230,8 +230,12 @@ RED.editor = (function() {
} }
} }
} }
node.inputs = Math.min(1,Math.max(0,parseInt(node.inputs)));
if (isNaN(node.inputs)) {
node.inputs = 0;
}
if (node.inputs === 0) { if (node.inputs === 0) {
removedLinks.concat(RED.nodes.filterLinks({target:node})); removedLinks = removedLinks.concat(RED.nodes.filterLinks({target:node}));
} }
for (var l=0;l<removedLinks.length;l++) { for (var l=0;l<removedLinks.length;l++) {
RED.nodes.removeLink(removedLinks[l]); RED.nodes.removeLink(removedLinks[l]);
@ -594,10 +598,18 @@ RED.editor = (function() {
var outputsDiv = $("#red-ui-editor-node-label-form-outputs"); var outputsDiv = $("#red-ui-editor-node-label-form-outputs");
var inputCount; var inputCount;
if (node.type === 'subflow') { var formInputs = $("#node-input-inputs").val();
inputCount = node.in.length; if (formInputs === undefined) {
if (node.type === 'subflow') {
inputCount = node.in.length;
} else {
inputCount = node.inputs || node._def.inputs || 0;
}
} else { } else {
inputCount = node.inputs || node._def.inputs || 0; inputCount = Math.min(1,Math.max(0,parseInt(formInputs)));
if (isNaN(inputCount)) {
inputCount = 0;
}
} }
var children = inputsDiv.children(); var children = inputsDiv.children();

View File

@ -2991,7 +2991,7 @@ RED.view = (function() {
//thisNode.selectAll(".red-ui-flow-node-icon-shade-border-right").attr("d",function(d){return "M "+(d.w-30)+" 1 l 0 "+(d.h-2)}); //thisNode.selectAll(".red-ui-flow-node-icon-shade-border-right").attr("d",function(d){return "M "+(d.w-30)+" 1 l 0 "+(d.h-2)});
var inputPorts = thisNode.selectAll(".red-ui-flow-port-input"); var inputPorts = thisNode.selectAll(".red-ui-flow-port-input");
if (isLink && showAllLinkPorts === -1 && !activeLinkNodes[d.id] && d.inputs === 0 && !inputPorts.empty()) { if ((!isLink || (showAllLinkPorts === -1 && !activeLinkNodes[d.id])) && d.inputs === 0 && !inputPorts.empty()) {
inputPorts.remove(); inputPorts.remove();
} else if (((isLink && (showAllLinkPorts===PORT_TYPE_INPUT||activeLinkNodes[d.id]))|| d.inputs === 1) && inputPorts.empty()) { } else if (((isLink && (showAllLinkPorts===PORT_TYPE_INPUT||activeLinkNodes[d.id]))|| d.inputs === 1) && inputPorts.empty()) {
var inputGroup = thisNode.append("g").attr("class","red-ui-flow-port-input"); var inputGroup = thisNode.append("g").attr("class","red-ui-flow-port-input");