diff options
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts')
-rw-r--r-- | catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts | 33 |
1 files changed, 22 insertions, 11 deletions
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 bc5345c386..8dd4ca96ec 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 @@ -105,15 +105,14 @@ export class PropertiesUtils { newProps.push(parentProp); if (!property.schema.property.isSimpleType) { - let additionalChildren:Array<DerivedFEProperty> = this.createFlattenedChildren(property.schema.property.type, parentProp.propertiesName, key); + let additionalChildren:Array<DerivedFEProperty> = this.createFlattenedChildren(property.schema.property.type, parentProp.propertiesName, key, parentProp.toscaPath); this.assignFlattenedChildrenValues(parentProp.valueObj, additionalChildren, parentProp.propertiesName); 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]) { + if (subToscaFunct.subPropertyPath.toString() === prop.toscaPath.toString()) { prop.toscaFunction = subToscaFunct.toscaFunction; } }); @@ -128,13 +127,15 @@ export class PropertiesUtils { /** * Creates derivedFEProperties of a specified type and returns them. */ - private createFlattenedChildren = (type: string, parentName: string, key: string):Array<DerivedFEProperty> => { + private createFlattenedChildren = (type: string, parentName: string, key: string, toscaPath?: string[]):Array<DerivedFEProperty> => { let tempProps: Array<DerivedFEProperty> = []; let dataTypeObj: DataTypeModel = this.dataTypeService.getDataTypeByTypeName(type); - this.dataTypeService.getDerivedDataTypeProperties(dataTypeObj, tempProps, parentName); - tempProps.forEach(tempDervObj => { - tempDervObj.mapKey = key; - }); + this.dataTypeService.getDerivedDataTypeProperties(dataTypeObj, tempProps, parentName, toscaPath); + if (key != '') { + tempProps.forEach(tempDervObj => { + tempDervObj.mapKey = key; + }); + } return _.sortBy(tempProps, ['propertiesName']); } @@ -161,6 +162,16 @@ export class PropertiesUtils { property.flattenedChildren.push(...this.createListOrMapChildren(lastCreatedChild, keyNested, nestedValue[keyNested])); }); } + if (property.flattenedChildren && property.subPropertyToscaFunctions) { + property.flattenedChildren.forEach((prop, index) => { + property.subPropertyToscaFunctions.forEach(subPropertyToscaFunction => { + const toscaFunctionPath = subPropertyToscaFunction.subPropertyPath.join('#'); + if (subPropertyToscaFunction.subPropertyPath.toString() === prop.toscaPath.toString()) { + prop.toscaFunction = subPropertyToscaFunction.toscaFunction; + } + }); + }); + } }); } else if (property.derivedDataType === DerivedPropertyType.COMPLEX) { property.flattenedChildren = this.createFlattenedChildren(property.type, property.name, ""); @@ -183,11 +194,11 @@ export class PropertiesUtils { const subPropertyPath = prop.propertiesName.substring(prop.propertiesName.indexOf(topLevelPropertyName) + topLevelPropertyName.length + 1); subPropertyToscaFunctions.forEach(subPropertyToscaFunction => { const toscaFunctionPath = subPropertyToscaFunction.subPropertyPath.join('#'); - if (subPropertyPath === toscaFunctionPath){ + if (subPropertyPath === toscaFunctionPath || subPropertyToscaFunction.subPropertyPath.toString() === prop.toscaPath.toString()) { prop.toscaFunction = subPropertyToscaFunction.toscaFunction; } - }) - }) + }); + }); } /* |