summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
diff options
context:
space:
mode:
authorimamSidero <imam.hussain@est.tech>2022-12-21 17:51:43 +0000
committerimamSidero <imam.hussain@est.tech>2023-01-03 15:03:15 +0000
commitdb3e2ef238fa29e06cec3cb3f5b11fb407b161ce (patch)
tree1dbca1372aa87c881a4ed93a8788e3eff0d38e9d /catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
parent5b1a92cea1fb437c236a77468f3e8e351e25a990 (diff)
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 <imam.hussain@est.tech> Change-Id: I7ec8943d8008440b091fc4eaa2aba49cdadcda8d
Diffstat (limited to 'catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts')
-rw-r--r--catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts23
1 files changed, 21 insertions, 2 deletions
diff --git a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
index edcbd43e27..b1ceb9328e 100644
--- a/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
+++ b/catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts
@@ -152,8 +152,22 @@ export class DynamicPropertyComponent {
};
createNewChildProperty = (): void => {
-
- let newProps: Array<DerivedFEProperty> = 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<DerivedFEProperty> = 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){