Support TOSCA functions in operation inputs
[sdc.git] / catalog-ui / src / app / models / tosca-get-function.ts
index 67d9b0a..784c7ea 100644 (file)
@@ -71,22 +71,34 @@ export class ToscaGetFunction implements ToscaFunction, ToscaFunctionParameter {
 
     private buildGetInputFunctionValue(): Object {
         if (this.propertyPathFromSource.length === 1) {
-            return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0], this.toscaIndexList]};
+            if (this.toscaIndexList) {
+                return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0], this.toscaIndexList]};
+            }
+            return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource[0]]};
         }
         return {[this.functionType.toLowerCase()]: [this.propertyPathFromSource, this.toscaIndexList]};
     }
 
     private buildFunctionValueWithPropertySource(): Object {
         if (this.propertySource == PropertySource.SELF) {
+            if (this.toscaIndexList) {
+                return {
+                    [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource, this.toscaIndexList]
+                };
+            }
             return {
-                [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource, this.toscaIndexList]
+                [this.functionType.toLowerCase()]: [PropertySource.SELF, ...this.propertyPathFromSource]
             };
         }
         if (this.propertySource == PropertySource.INSTANCE) {
+            if (this.toscaIndexList) {
+                return {
+                    [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource, this.toscaIndexList]
+                };
+            }
             return {
-                [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource,this.toscaIndexList]
+                [this.functionType.toLowerCase()]: [this.sourceName, ...this.propertyPathFromSource]
             };
         }
     }
-
 }
\ No newline at end of file