From dd85204c7b0432ca5ce4437104cab2dd6cb483c0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Dec 2019 11:04:35 +0100 Subject: [PATCH] Auto Add for children working --- .../FunctionLibraries/UiObjectsFromNodes.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 4814a8993..f4af73d5a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -144,6 +144,35 @@ function newUiObjectsFromNodes () { } } } + + /* Auto Add more Children */ + if (nodeDefinition.properties !== undefined) { + let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (property.name !== previousPropertyName) { + if (property.autoAdd === true) { + addUIObject(object, property.childType) + previousPropertyName = property.name + } + } + } + break + case 'array': { + if (property.autoAdd === true) { + if (object[property.name] === undefined) { + object[property.name] = [] + } + addUIObject(object, property.childType) + } + } + break + } + } + } } return object }