From a8d208b231237fc9f05f83c2b33fa207d58f1480 Mon Sep 17 00:00:00 2001 From: imamSidero Date: Wed, 11 Jan 2023 18:13:25 +0000 Subject: Provide tosca function as map primitive type entry values in composition view Providing the capability to add tosca function as the primitive type entry values of map in composition view Issue-ID: SDC-4319 Signed-off-by: Imam hussain Change-Id: I5cf67bc94ac5c72be6a962e07160329cd07d302c --- .../tosca-function/tosca-function.component.html | 2 ++ .../tosca-function/tosca-function.component.ts | 13 +++++++++++++ .../tosca-get-function/tosca-get-function.component.html | 2 +- .../tosca-get-function/tosca-get-function.component.ts | 16 +++++++++------- 4 files changed, 25 insertions(+), 8 deletions(-) (limited to 'catalog-ui/src/app/ng2') diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html index 8ee253e5dc..74a06baa53 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.html @@ -34,6 +34,8 @@
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 6b43cb014d..f697eed027 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 @@ -44,6 +44,8 @@ export class ToscaFunctionComponent implements OnInit, OnChanges { @Input() property: PropertyBEModel; @Input() componentInstanceMap: Map = new Map(); @Input() allowClear: boolean = true; + @Input() compositionMap: boolean = false; + @Input() compositionMapKey: string = ""; @Output() onValidFunction: EventEmitter = new EventEmitter(); @Output() onValidityChange: EventEmitter = new EventEmitter(); @@ -98,6 +100,17 @@ export class ToscaFunctionComponent implements OnInit, OnChanges { } private initToscaFunction(): void { + if (this.compositionMap && this.property.subPropertyToscaFunctions) { + let keyToFind = [this.compositionMapKey]; + let subPropertyToscaFunction = this.property.subPropertyToscaFunctions.find(subPropertyToscaFunction => this.areEqual(subPropertyToscaFunction.subPropertyPath, keyToFind)); + + if (subPropertyToscaFunction){ + this.toscaFunction = subPropertyToscaFunction.toscaFunction; + this.toscaFunctionForm.setValue(this.toscaFunction); + this.toscaFunctionTypeForm.setValue(this.toscaFunction.type); + } + return; + } if (this.property instanceof PropertyDeclareAPIModel && this.property.subPropertyToscaFunctions && ( this.property).propertiesName){ let propertiesPath = ( this.property).propertiesName.split("#"); if (propertiesPath.length > 1){ diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html index 6f19d5eff4..62cd697f8c 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.html @@ -32,7 +32,7 @@
-
{{dropDownErrorMsg}}
+
{{dropDownErrorMsg}}
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts index 84018fd546..9fdc8c19aa 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts @@ -45,6 +45,8 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { @Input() toscaGetFunction: ToscaGetFunction; @Input() componentInstanceMap: Map = new Map(); @Input() functionType: ToscaGetFunctionType; + @Input() compositionMap: boolean; + @Input() compositionMapKey: string; @Output() onValidFunction: EventEmitter = new EventEmitter(); @Output() onValidityChange: EventEmitter = new EventEmitter(); @@ -262,10 +264,10 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { private propertyTypeToString() { if (this.isSubProperty()){ - if (this.typeHasSchema(this.property.type) && this.property instanceof PropertyDeclareAPIModel && - ( this.property).input instanceof DerivedFEProperty) { - if(this.isComplexType(this.property.schemaType)){ - return this.property.input.type; + if ((this.typeHasSchema(this.property.type) && this.property instanceof PropertyDeclareAPIModel && + ( this.property).input instanceof DerivedFEProperty) || this.compositionMap) { + if(this.isComplexType(this.property.schemaType) && !this.compositionMap){ + return ( this.property).input.type; }else{ return this.property.schema.property.type; } @@ -375,9 +377,9 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { private hasSameType(property: PropertyBEModel | AttributeBEModel): boolean { if (this.typeHasSchema(this.property.type)) { - if (this.property instanceof PropertyDeclareAPIModel && ( this.property).input instanceof DerivedFEProperty) { - if(this.isComplexType(this.property.schemaType)){ - return property.type === this.property.input.type; + if ((this.property instanceof PropertyDeclareAPIModel && ( this.property).input instanceof DerivedFEProperty) || this.compositionMap) { + if(this.isComplexType(this.property.schemaType) && !this.compositionMap){ + return property.type === ( this.property).input.type; }else{ return property.type === this.property.schema.property.type; } -- cgit 1.2.3-korg