Fix unable to set tosca function on complex type on input operation
[sdc.git] / catalog-ui / src / app / models / tosca-get-function.ts
index 784c7ea..2eb4747 100644 (file)
@@ -71,19 +71,19 @@ export class ToscaGetFunction implements ToscaFunction, ToscaFunctionParameter {
 
     private buildGetInputFunctionValue(): Object {
         if (this.propertyPathFromSource.length === 1) {
-            if (this.toscaIndexList) {
-                return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0], this.toscaIndexList]};
+            if (this.isToscaIndexEmpty()) {
+                return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0], ...this.toscaIndexList]};
             }
             return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0]]};
         }
-        return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource, this.toscaIndexList]};
+        return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource, ...this.toscaIndexList]};
     }
 
     private buildFunctionValueWithPropertySource(): Object {
         if (this.propertySource == PropertySource.SELF) {
-            if (this.toscaIndexList) {
+            if (this.isToscaIndexEmpty()) {
                 return {
-                    [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource, this.toscaIndexList]
+                    [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource, ...this.toscaIndexList]
                 };
             }
             return {
@@ -91,9 +91,9 @@ export class ToscaGetFunction implements ToscaFunction, ToscaFunctionParameter {
             };
         }
         if (this.propertySource == PropertySource.INSTANCE) {
-            if (this.toscaIndexList) {
+            if (this.isToscaIndexEmpty()) {
                 return {
-                    [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource, this.toscaIndexList]
+                    [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource, ...this.toscaIndexList]
                 };
             }
             return {
@@ -101,4 +101,8 @@ export class ToscaGetFunction implements ToscaFunction, ToscaFunctionParameter {
             };
         }
     }
+
+    private isToscaIndexEmpty(): boolean {
+        return this.toscaIndexList && this.toscaIndexList.length > 0;
+    }
 }
\ No newline at end of file