-
Notifications
You must be signed in to change notification settings - Fork 157
Open
Description
I'm trying a logical AND node type that dynamically renders the inputs so that it always creates an extra input after the last connected input:
.addNodeType({
type: "and",
label: "And Boolean Test",
description: "Performs a logical AND operation on the input boolean values",
initialWidth: 140,
inputs: ports => (inputData, connections) => {
// Determine the number of current connections
const connectedInputs = Object.keys(connections.inputs).length;
// Create an array of boolean inputs, adding one extra unconnected input
const inputPorts = [];
for (let i = 0; i < connectedInputs; i++) {
console.log(`input_${i + 1}`);
inputPorts.push(
ports.boolean({ name: `input_${i + 1}`, label: `Input ${i + 1}` })
);
}
return inputPorts;
},
outputs: ports => [
ports.boolean()
]
})
This works as expected, the only issue is that when I render the nodes to JSON it doesn't seem to name the first input input_1
as expected (instead it's named boolean
):
"4CnGWCxuXc":{
"id":"4CnGWCxuXc",
"x":277.20001220703125,
"y":77.39990234375,
"type":"and",
"width":140,
"connections":{
"inputs":{
"boolean":[
{
"nodeId":"2b3X8ISyEe",
"portName":"boolean"
}
],
"input_2":[
{
"nodeId":"Sf7YdDLyS6",
"portName":"boolean"
}
],
"input_3":[
{
"nodeId":"vMfnsOGUwS",
"portName":"boolean"
}
],
"input_1":[
{
"nodeId":"2b3X8ISyEe",
"portName":"boolean"
}
],
"input_4":[
{
"nodeId":"FIYlnukifV",
"portName":"boolean"
}
]
},
"outputs":{
}
},
"inputData":{
"input_1":{
"boolean":false
},
"input_2":{
"boolean":false
},
"input_3":{
"boolean":false
},
"input_4":{
"boolean":false
},
"input_5":{
"boolean":false
}
}
}
Metadata
Metadata
Assignees
Labels
No labels