From db3e2ef238fa29e06cec3cb3f5b11fb407b161ce Mon Sep 17 00:00:00 2001 From: imamSidero Date: Wed, 21 Dec 2022 17:51:43 +0000 Subject: Provide tosca function to custom datatypes of list and map Providing the capability to add tosca function as the custom datatypes of list and map Issue-ID: SDC-4311 Signed-off-by: Imam hussain Change-Id: I7ec8943d8008440b091fc4eaa2aba49cdadcda8d --- .../services/properties.utils.ts | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts') 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 876fc8e5fa..0b984ac2a4 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 @@ -108,9 +108,21 @@ export class PropertiesUtils { newProps.push(parentProp); if (!property.schema.property.isSimpleType) { - let additionalChildren:Array = this.createFlattenedChildren(property.schema.property.type, parentProp.propertiesName); + let additionalChildren:Array = this.createFlattenedChildren(property.schema.property.type, parentProp.propertiesName, key); this.assignFlattenedChildrenValues(parentProp.valueObj, additionalChildren, parentProp.propertiesName); - additionalChildren.forEach(prop => prop.canBeDeclared = false); + additionalChildren.forEach(prop => { + prop.canBeDeclared = false; + if (property.subPropertyToscaFunctions != null) { + const subToscaFunctArray : SubPropertyToscaFunction[] = property.subPropertyToscaFunctions; + subToscaFunctArray.forEach(subToscaFunct => { + const keyArray : string[] = subToscaFunct.subPropertyPath; + if (keyArray.length > 1 && prop.mapKey == keyArray[0] && prop.name == keyArray[1]) { + prop.toscaFunction = subToscaFunct.toscaFunction; + } + }); + + } + }); newProps.push(...additionalChildren); } return newProps; @@ -119,10 +131,13 @@ export class PropertiesUtils { /** * Creates derivedFEProperties of a specified type and returns them. */ - private createFlattenedChildren = (type: string, parentName: string):Array => { + private createFlattenedChildren = (type: string, parentName: string, key: string):Array => { let tempProps: Array = []; let dataTypeObj: DataTypeModel = this.dataTypeService.getDataTypeByTypeName(type); this.dataTypeService.getDerivedDataTypeProperties(dataTypeObj, tempProps, parentName); + tempProps.forEach(tempDervObj => { + tempDervObj.mapKey = key; + }); return _.sortBy(tempProps, ['propertiesName']); } @@ -151,7 +166,7 @@ export class PropertiesUtils { } }); } else if (property.derivedDataType === DerivedPropertyType.COMPLEX) { - property.flattenedChildren = this.createFlattenedChildren(property.type, property.name); + 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) => { -- cgit 1.2.3-korg