Fix formatting error for operation input of complex type
[sdc.git] / catalog-ui / src / app / ng2 / pages / composition / interface-operatons / operation-creator / input-list / input-list-item / input-list-item.component.ts
index 103fc5c..61708ab 100644 (file)
@@ -25,6 +25,7 @@ import {SchemaProperty, SchemaPropertyGroupModel} from '../../../../../../../mod
 import {PropertyBEModel} from '../../../../../../../models/properties-inputs/property-be-model';
 import {PROPERTY_DATA, PROPERTY_TYPES} from '../../../../../../../utils/constants';
 import {ToscaFunction} from '../../../../../../../models/tosca-function';
+import {ToscaFunctionType} from "../../../../../../../models/tosca-function-type.enum";
 import {ToscaFunctionValidationEvent} from "../../../../../properties-assignment/tosca-function/tosca-function.component";
 import {InstanceFeDetails} from "../../../../../../../models/instance-fe-details";
 import {ToscaTypeHelper} from "app/utils/tosca-type-helper";
@@ -48,6 +49,7 @@ export class InputListItemComponent implements OnInit {
   @Input() isMapChild: boolean = false;
   @Input() showToscaFunctionOption: boolean = false;
   @Input() listIndex: number;
+  @Input() subPropertyToscaFunctions: SubPropertyToscaFunctions[];
   @Input() isViewOnly: boolean;
   @Input() allowDeletion: boolean = false;
   @Input() toscaFunction: ToscaFunction;
@@ -96,6 +98,24 @@ export class InputListItemComponent implements OnInit {
     }
   }
 
+  getToscaFunction(key: any): any {
+    if (this.subPropertyToscaFunctions) {
+      for (let subPropertyToscaFunction of this.subPropertyToscaFunctions) {
+        let found = subPropertyToscaFunction.subPropertyPath.find(value => value === key);
+        if (found) {
+          return subPropertyToscaFunction.toscaFunction;
+        }
+      }
+    }
+    if ((key && this.valueObjRef[key] && this.valueObjRef[key].type)) {
+      const type = this.valueObjRef[key].type;
+      if (type in ToscaFunctionType) {
+        return <ToscaFunction> this.valueObjRef[key];
+      }
+    }
+    return undefined;
+  }
+
   isTypeSimple(typeName: string): boolean {
     return ToscaTypeHelper.isTypeSimple(typeName) || this.isTypeDerivedFromSimple(typeName) && (this.isTypeWithoutProperties(typeName));
   }
@@ -327,3 +347,8 @@ export class InputListItemComponent implements OnInit {
   }
 
 }
+
+export interface SubPropertyToscaFunctions {
+  subPropertyPath: string[];
+  toscaFunction: ToscaFunction;
+}