From ee6e389e64b55615800a81ce43a41fa3e7ff93ce Mon Sep 17 00:00:00 2001 From: franciscovila Date: Tue, 19 Sep 2023 08:58:36 +0100 Subject: Fail to import service with node filter using 'in_range' Issue-ID: SDC-4628 Signed-off-by: franciscovila Change-Id: Ibf6edbdfbb51c32256a707acd17a0def217e1bb9 --- .../service-dependencies.component.ts | 1 + .../service-dependencies-editor.component.ts | 24 ++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'catalog-ui/src/app') diff --git a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts index a0588c0daa..e5f1f6f918 100644 --- a/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts +++ b/catalog-ui/src/app/ng2/components/logic/service-dependencies/service-dependencies.component.ts @@ -34,6 +34,7 @@ import {CustomToscaFunction} from "../../../../models/default-custom-functions"; export enum SourceType { STATIC = 'static', + SEVERAL = 'several', TOSCA_FUNCTION = 'tosca_function', TOSCA_FUNCTION_LIST = 'tosca_function_list' } diff --git a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts index fdaf2f3573..26fd59e794 100644 --- a/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts +++ b/catalog-ui/src/app/ng2/pages/service-dependencies-editor/service-dependencies-editor.component.ts @@ -223,7 +223,8 @@ export class ServiceDependenciesEditorComponent implements OnInit { } private initSelectedSourceType(): void { - if (!this.currentRule.sourceType || this.currentRule.sourceType === SourceType.STATIC) { + if (!this.currentRule.sourceType || this.currentRule.sourceType === SourceType.STATIC + || (this.currentRule.sourceType === SourceType.SEVERAL && !ToscaFunctionHelper.convertObjectToToscaFunction(this.currentRule.value[0]))) { this.selectedSourceType = SourceType.STATIC; } else { if (!this.isValidValuesOperator() && !this.isRangeType() && !this.isInRangeOperator()) { @@ -309,11 +310,22 @@ export class ServiceDependenciesEditorComponent implements OnInit { } else if (ToscaFunctionHelper.isValueToscaFunction(this.currentRule.value)) { newProperty.toscaFunction = ToscaFunctionHelper.convertObjectToToscaFunction(this.currentRule.value); newProperty.value = newProperty.toscaFunction.buildValueString(); - } else if (Array.isArray(this.currentRule.value) && - typeof this.currentRule.value[0] === "object") { - this.validValuesToscaFunctionList = this.currentRule.value; - this.rangeToscaFunctionList = this.currentRule.value; - newProperty.toscaFunction = this.currentRule.value; + } else if (Array.isArray(this.currentRule.value)) { + if (typeof this.currentRule.value[0] === 'object') { + this.rangeToscaFunctionList = []; + this.validValuesToscaFunctionList = []; + this.currentRule.value.forEach(val => { + this.rangeToscaFunctionList.push(ToscaFunctionHelper.convertObjectToToscaFunction(val)); + this.validValuesToscaFunctionList.push(ToscaFunctionHelper.convertObjectToToscaFunction(val)); + }); + newProperty.toscaFunction = this.currentRule.value; + newProperty.value = this.currentRule.value; + } + else { + this.validValuesToscaFunctionList = this.currentRule.value; + this.rangeToscaFunctionList = this.currentRule.value; + newProperty.toscaFunction = this.currentRule.value; + } } else { newProperty.value = JSON.stringify(this.currentRule.value); this.propertiesUtils.initValueObjectRef(newProperty); -- cgit 1.2.3-korg