From bfd727385b9c55d079a5c213b425e88b88a67b7f Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Tue, 30 May 2023 14:57:47 +0100 Subject: Fix formatting error for operation input of complex type Issue-ID: SDC-4523 Signed-off-by: JvD_Ericsson Change-Id: I3dff94cee1d1dbcb26099d02505a679249a6b46e --- .../input-list-item/input-list-item.component.html | 3 +++ .../input-list-item/input-list-item.component.ts | 25 ++++++++++++++++++++++ .../input-list/input-list.component.html | 1 + .../input-list/input-list.component.spec.ts | 2 ++ .../interface-operation-handler.component.ts | 3 +++ .../tosca-get-function.component.ts | 2 +- 6 files changed, 35 insertions(+), 1 deletion(-) (limited to 'catalog-ui/src/app/ng2/pages') diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html index 3824d75055..88a4d6b437 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html @@ -104,6 +104,7 @@ [dataTypeMap]="dataTypeMap" [valueObjRef]="valueObjRef ? valueObjRef[property.name] : undefined" [schema]="property.schema" + [toscaFunction]="getToscaFunction(property.name)" [nestingLevel]="nestingLevel + 1" [isViewOnly]="isViewOnly" [showToscaFunctionOption]="showToscaFunctionOption" @@ -130,6 +131,7 @@ [dataTypeMap]="dataTypeMap" [valueObjRef]="valueObjRef[i]" [schema]="buildSchemaGroupProperty()" + [toscaFunction]="getToscaFunction(i)" [nestingLevel]="nestingLevel + 1" [listIndex]="i" [isListChild]="true" @@ -162,6 +164,7 @@ [dataTypeMap]="dataTypeMap" [valueObjRef]="valueObjRef[key]" [schema]="buildSchemaGroupProperty()" + [toscaFunction]="getToscaFunction(key)" [isMapChild]="true" [nestingLevel]="nestingLevel + 1" [isViewOnly]="isViewOnly" diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts index 103fc5c4f1..61708ab948 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts @@ -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 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; +} diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.html b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.html index d4b70f9be5..64726f1268 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.html @@ -32,6 +32,7 @@ [valueObjRef]="input.value" [schema]="input.schema" [toscaFunction]="input.toscaFunction" + [subPropertyToscaFunctions]="input.subPropertyToscaFunctions" [showToscaFunctionOption]="showToscaFunctionOption" [isViewOnly]="isViewOnly" [allowDeletion]="allowDeletion" diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts index 3230306e68..824592f58f 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list.component.spec.ts @@ -29,6 +29,7 @@ import {TranslateService} from '../../../../../shared/translator/translate.servi import {ToscaFunction} from '../../../../../../models/tosca-function'; import {InstanceFeDetails} from "../../../../../../models/instance-fe-details"; import {CustomToscaFunction} from "../../../../../../models/default-custom-functions"; +import {SubPropertyToscaFunctions} from "./input-list-item/input-list-item.component"; @Component({selector: 'app-input-list-item', template: ''}) class InputListItemStubComponent { @@ -36,6 +37,7 @@ class InputListItemStubComponent { @Input() type: DataTypeModel; @Input() dataTypeMap: any; @Input() valueObjRef: any; + @Input() subPropertyToscaFunctions: SubPropertyToscaFunctions[]; @Input() schema: any; @Input() allowDeletion: any; @Input() isViewOnly: boolean; diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts index 4ceaa78148..812490c12a 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/interface-operation-handler.component.ts @@ -303,6 +303,9 @@ export class InterfaceOperationHandlerComponent { const inputOperationParameter = this.inputs.find(value => value.name == changedInput.name); inputOperationParameter.toscaFunction = null; inputOperationParameter.value = changedInput.value; + if (inputOperationParameter.subPropertyToscaFunctions) { + inputOperationParameter.subPropertyToscaFunctions = undefined; + } if (changedInput.isToscaFunction()) { inputOperationParameter.toscaFunction = changedInput.toscaFunction; inputOperationParameter.value = changedInput.toscaFunction.buildValueString(); 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 cbbc2d98c0..07058ea069 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 @@ -125,7 +125,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { this.loadPropertyDropdown(() => { this.selectedProperty .setValue(this.propertyDropdownList.find(property => property.propertyName === this.toscaGetFunction.propertyName)); - if (this.toscaGetFunction.toscaIndexList.length > 0) { + if (this.toscaGetFunction.toscaIndexList && this.toscaGetFunction.toscaIndexList.length > 0) { let tempSelectedProperty : PropertyDropdownValue = this.selectedProperty.value; this.toscaGetFunction.toscaIndexList.forEach((indexValue: string, index) => { let tempIndexFlag = false; -- cgit 1.2.3-korg