MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / handleAddItem

Function handleAddItem

packages/ui/src/ui-component/array/ArrayRenderer.jsx:133–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131
132 // Handler for adding new array items
133 const handleAddItem = () => {
134 // Initialize new item with default values
135 let newItem = {}
136
137 for (const fieldDef of inputParam.array) {
138 newItem[fieldDef.name] = fieldDef.default || ''
139 }
140
141 /*if (inputParam.default?.length) {
142 newItem = inputParam.default[0]
143 }*/
144
145 // Update array items
146 const updatedArrayItems = [...arrayItems, newItem]
147 setArrayItems(updatedArrayItems)
148 data.inputs[inputParam.name] = updatedArrayItems
149
150 // Calculate display parameters for all items including new one
151 const updatedItemParameters = []
152 for (let i = 0; i < updatedArrayItems.length; i += 1) {
153 const itemParams = showHideInputs(data, 'inputParams', cloneDeep(inputParam.array), i)
154 if (itemParams.length) {
155 updatedItemParameters.push(itemParams)
156 }
157 }
158 setItemParameters(updatedItemParameters)
159
160 updateOutputAnchors(updatedArrayItems, 'ADD')
161 }
162
163 // Handler for deleting array items
164 const handleDeleteItem = (indexToDelete) => {

Callers

nothing calls this directly

Calls 2

showHideInputsFunction · 0.90
updateOutputAnchorsFunction · 0.85

Tested by

no test coverage detected