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 --- .../dynamic-property.component.html | 11 ++++++----- .../dynamic-property/dynamic-property.component.ts | 23 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) (limited to 'catalog-ui/src/app/ng2/components') diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html index d79c6dbb08..a5c2b60ee3 100644 --- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html +++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.html @@ -25,6 +25,7 @@
{{property.name}}
+
{{property.name}}
@@ -41,7 +42,7 @@
- +
- +
{{property.type | contentAfterLastDot }}
{{property.schema.property.type | contentAfterLastDot }}
- +
- + Add value to list Add value to map @@ -75,7 +76,7 @@ -
+
{ - - let newProps: Array = this.propertiesUtils.createListOrMapChildren(this.property, "", null); + + let mapKeyValue = this.property instanceof DerivedFEProperty ? this.property.mapKey : ""; + if (this.property.type == PROPERTY_TYPES.LIST && mapKeyValue === "") { + if(this.property.value != null) { + const valueJson = JSON.parse(this.property.value); + if(this.property instanceof PropertyFEModel && this.property.expandedChildPropertyId != null){ + let indexNumber = Number(Object.keys(valueJson).sort().reverse()[0]) + 1; + mapKeyValue = indexNumber.toString(); + }else{ + mapKeyValue = Object.keys(valueJson).sort().reverse()[0]; + } + }else { + mapKeyValue = "0"; + } + } + let newProps: Array = this.propertiesUtils.createListOrMapChildren(this.property, mapKeyValue, null); this.propertiesUtils.assignFlattenedChildrenValues(this.property.valueObj, [newProps[0]], this.property.propertiesName); if (this.property instanceof PropertyFEModel) { @@ -255,6 +269,11 @@ export class DynamicPropertyComponent { if (this.property instanceof PropertyFEModel) { let oldKey = childProp.getActualMapKey(); this.property.childPropMapKeyUpdated(childProp, newMapKey); + this.property.flattenedChildren.forEach(tempDervObj => { + if (childProp.propertiesName === tempDervObj.parentName) { + tempDervObj.mapKey = newMapKey; + } + }); if (this.property.subPropertyToscaFunctions != null) { this.property.subPropertyToscaFunctions.forEach((item : SubPropertyToscaFunction) => { if(item.subPropertyPath[0] === oldKey){ -- cgit 1.2.3-korg