From 0411615fe4f55fe3463da2576de376c7478fcfb2 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Fri, 26 Aug 2022 11:00:03 +0100 Subject: Support TOSCA functions in sub properties Change-Id: Ibfd95c928bbb10089cfc9749ae4e7b05270e3d68 Issue-ID: SDC-4151 Signed-off-by: MichaelMorris --- .../tosca-function/tosca-function.component.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts') diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts index ae778006ce..70df4eaced 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts @@ -18,7 +18,7 @@ */ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {ComponentMetadata, PropertyBEModel} from 'app/models'; +import {ComponentMetadata, PropertyBEModel, PropertyDeclareAPIModel} from 'app/models'; import {TopologyTemplateService} from "../../../services/component-services/topology-template.service"; import {WorkspaceService} from "../../workspace/workspace.service"; import {ToscaGetFunctionType} from "../../../../models/tosca-get-function-type"; @@ -86,6 +86,21 @@ export class ToscaFunctionComponent implements OnInit { } private initToscaFunction() { + if (this.property instanceof PropertyDeclareAPIModel && this.property.subPropertyToscaFunctions && ( this.property).propertiesName){ + let propertiesPath = ( this.property).propertiesName.split("#"); + if (propertiesPath.length > 1){ + propertiesPath = propertiesPath.slice(1); + let subPropertyToscaFunction = this.property.subPropertyToscaFunctions.find(subPropertyToscaFunction => this.areEqual(subPropertyToscaFunction.subPropertyPath, propertiesPath)); + + if (subPropertyToscaFunction){ + this.toscaFunction = subPropertyToscaFunction.toscaFunction; + this.toscaFunctionForm.setValue(this.toscaFunction); + this.toscaFunctionTypeForm.setValue(this.toscaFunction.type); + } + return; + } + } + if (!this.property.isToscaFunction()) { return; } @@ -93,6 +108,10 @@ export class ToscaFunctionComponent implements OnInit { this.toscaFunctionTypeForm.setValue(this.property.toscaFunction.type); } + private areEqual(array1: string[], array2: string[]): boolean { + return array1.length === array2.length && array1.every(function(value, index) { return value === array2[index]}) + } + private loadToscaFunctions(): void { this.toscaFunctions.push(ToscaFunctionType.GET_ATTRIBUTE); this.toscaFunctions.push(ToscaFunctionType.GET_INPUT); -- cgit 1.2.3-korg