summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2023-03-23 11:25:23 +0000
committerImam hussain <imam.hussain@est.tech>2023-04-03 11:13:18 +0000
commit7565f810f9fa50c8140843b2f81e8fb428815154 (patch)
tree5ff3ef43bd7434db7c0bd462db295a2726052c61 /catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
parent3dff1c221e58de6a81cf6bbdfb84fdf97665e484 (diff)
Provide tosca function capability to all nested levels
Tosca function capability is provided to all nested levels of list, map and custom types Issue-ID: SDC-4445 Signed-off-by: Imam hussain <imam.hussain@est.tech> Change-Id: I29907bdac83d3cadf90aa0a2ed538002132b4789
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.ts33
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;
}
- })
- })
+ });
+ });
}
/*