From f13f58eb867c763e6ed1c3b674fd99b1081a0664 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Wed, 9 Feb 2022 19:00:35 +0000 Subject: Support complex types in interface operation inputs Issue-ID: SDC-3897 Change-Id: Ieac2d74ad340de1d9f6e4cd3ac830e2ec8c35d5b Signed-off-by: andre.schmid Signed-off-by: vasraz Signed-off-by: MichaelMorris --- catalog-ui/src/app/models/interfaceOperation.ts | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'catalog-ui/src/app/models/interfaceOperation.ts') diff --git a/catalog-ui/src/app/models/interfaceOperation.ts b/catalog-ui/src/app/models/interfaceOperation.ts index 109babb068..9d8ab366a2 100644 --- a/catalog-ui/src/app/models/interfaceOperation.ts +++ b/catalog-ui/src/app/models/interfaceOperation.ts @@ -20,21 +20,47 @@ 'use strict'; import {ArtifactModel} from "./artifacts"; +import {SchemaPropertyGroupModel} from "./schema-property"; +import {PROPERTY_DATA, PROPERTY_TYPES} from "../utils/constants"; export class InputOperationParameter { name: string; type: string; + schema: SchemaPropertyGroupModel; inputId: string; toscaDefaultValue?: string; + value?: any; constructor(param?: any) { if (param) { this.name = param.name; this.type = param.type; + this.schema = param.schema; this.inputId = param.inputId; this.toscaDefaultValue = param.toscaDefaultValue; + this.value = param.value; + } + } + + public getDefaultValue(): any { + if (this.isTypeNotSimple()) { + if (this.toscaDefaultValue) { + this.toscaDefaultValue = JSON.parse(this.toscaDefaultValue); + return JSON.parse(this.toscaDefaultValue); + } + switch (this.type) { + case PROPERTY_TYPES.LIST: + return []; + default: + return {}; + } } - console.info("InputOperationParameter Constructor: ", param) + + return this.toscaDefaultValue; + } + + private isTypeNotSimple() { + return PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) == -1; } } -- cgit 1.2.3-korg