From 0411615fe4f55fe3463da2576de376c7478fcfb2 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Fri, 26 Aug 2022 11:00:03 +0100 Subject: Support TOSCA functions in sub properties Change-Id: Ibfd95c928bbb10089cfc9749ae4e7b05270e3d68 Issue-ID: SDC-4151 Signed-off-by: MichaelMorris --- .../services/hierarchy-nav.service.ts | 1 + .../properties-assignment/services/properties.utils.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/services') diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/services/hierarchy-nav.service.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/services/hierarchy-nav.service.ts index 1a800baac7..e3baad6cb2 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/services/hierarchy-nav.service.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/services/hierarchy-nav.service.ts @@ -44,6 +44,7 @@ export class HierarchyNavService { }); let tree = this.unflatten(flattenProperties, '', []); + return tree[0].childrens; // Return the childrens without the root. } diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts index 8e9be8b9a0..753cb6afe0 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts @@ -24,6 +24,7 @@ import { DataTypeModel, PropertyFEModel, PropertyBEModel, InstanceBePropertiesMa import { DataTypeService } from "app/ng2/services/data-type.service"; import { PropertiesService } from "app/ng2/services/properties.service"; import { PROPERTY_TYPES, PROPERTY_DATA } from "app/utils"; +import { SubPropertyToscaFunction } from "app/models/sub-property-tosca-function"; @Injectable() export class PropertiesUtils { @@ -143,14 +144,31 @@ export class PropertiesUtils { } else if (property.derivedDataType === DerivedPropertyType.COMPLEX) { property.flattenedChildren = this.createFlattenedChildren(property.type, property.name); this.assignFlattenedChildrenValues(property.valueObj, property.flattenedChildren, property.name); + this.setFlattenedChildernToscaFunction(property.subPropertyToscaFunctions, property.flattenedChildren, property.name); property.flattenedChildren.forEach((childProp) => { property.childPropUpdated(childProp); }); + } } property.updateValueObjOrig(); }; + public setFlattenedChildernToscaFunction = (subPropertyToscaFunctions: SubPropertyToscaFunction[], derivedPropArray: Array, topLevelPropertyName: string) => { + if (!subPropertyToscaFunctions || !derivedPropArray || !topLevelPropertyName){ + return; + } + derivedPropArray.forEach((prop, index) => { + const subPropertyPath = prop.propertiesName.substring(prop.propertiesName.indexOf(topLevelPropertyName) + topLevelPropertyName.length + 1); + subPropertyToscaFunctions.forEach(subPropertyToscaFunction => { + const toscaFunctionPath = subPropertyToscaFunction.subPropertyPath.join('#'); + if (subPropertyPath === toscaFunctionPath){ + prop.toscaFunction = subPropertyToscaFunction.toscaFunction; + } + }) + }) + } + /* * Loops through flattened properties array and to assign values * Then, convert any neccessary strings to objects, and vis-versa -- cgit 1.2.3-korg