Bug fix for list of map values in properties 66/132866/2
authorimamSidero <imam.hussain@est.tech>
Wed, 4 Jan 2023 15:16:31 +0000 (15:16 +0000)
committerMichael Morris <michael.morris@est.tech>
Thu, 5 Jan 2023 09:54:53 +0000 (09:54 +0000)
Fixed list of map values in properties assignment page

Issue-ID: SDC-4315
Signed-off-by: Imam hussain <imam.hussain@est.tech>
Change-Id: I3d4fcc11327bbc38d1ec24a06ca45aedcfb47ce1

catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
catalog-ui/src/app/ng2/components/logic/properties-table/dynamic-property/dynamic-property.component.ts

index 60d2726..3985b98 100644 (file)
@@ -69,16 +69,18 @@ export class DerivedFEProperty extends PropertyBEModel {
             this.propertiesName = parentName + '#' + this.name;
             
             if (property.type == PROPERTY_TYPES.LIST) {
-                if(property.value != null) {
-                    const valueJson = JSON.parse(property.value);
-                    if (key != '') {
-                        this.mapKey = key;
-                    }else{
-                        let indexNumber = Number(Object.keys(valueJson).sort().reverse()[0]) + 1;
-                        this.mapKey = indexNumber.toString();
+                if (property.schemaType != PROPERTY_TYPES.MAP) {
+                    if(property.value != null) {
+                        const valueJson = JSON.parse(property.value);
+                        if (key != '') {
+                            this.mapKey = key;
+                        }else{
+                            let indexNumber = Number(Object.keys(valueJson).sort().reverse()[0]) + 1;
+                            this.mapKey = indexNumber.toString();
+                        }
+                    }else {
+                        this.mapKey = "0";
                     }
-                }else {
-                    this.mapKey = "0";
                 }
                 this.mapKeyError = null;
                 this.type = property.schema.property.type;
index b1ceb93..548c676 100644 (file)
@@ -155,16 +155,18 @@ export class DynamicPropertyComponent {
 
         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];
+            if (this.property.schemaType != PROPERTY_TYPES.MAP) {
+                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";
                 }
-            }else {
-                mapKeyValue = "0";
             }
         }
         let newProps: Array<DerivedFEProperty> = this.propertiesUtils.createListOrMapChildren(this.property, mapKeyValue, null);
@@ -286,7 +288,7 @@ export class DynamicPropertyComponent {
     }
 
     preventInsertItem = (property:DerivedFEProperty):boolean => {
-        if(property.type == PROPERTY_TYPES.MAP && Object.keys(property.valueObj).indexOf('') > -1 ){
+        if(property.type == PROPERTY_TYPES.MAP && property.valueObj != null && Object.keys(property.valueObj).indexOf('') > -1 ){
             return true;
         }
         return false;