From 3d79660270cc259688e0ba20150286c1680c7559 Mon Sep 17 00:00:00 2001 From: imamSidero Date: Mon, 24 Oct 2022 17:20:46 +0100 Subject: Add default baseType to the substitution type Enabling default baseType in substitution type to be selected Issue-ID: SDC-4229 Signed-off-by: Imam hussain Change-Id: I869ede4c4e030adc3c4418c28ed787b4c10248dd --- catalog-ui/src/app/models/base-types.ts | 1 + .../workspace/tabs/general/general-view-model.ts | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'catalog-ui/src/app') diff --git a/catalog-ui/src/app/models/base-types.ts b/catalog-ui/src/app/models/base-types.ts index 526355e0f8..69aafa357c 100644 --- a/catalog-ui/src/app/models/base-types.ts +++ b/catalog-ui/src/app/models/base-types.ts @@ -21,6 +21,7 @@ interface ListBaseTypesResponse { baseTypes: BaseTypeResponse[]; required: boolean; + defaultBaseType: string; } interface BaseTypeResponse { diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts index 77c93301b2..2d029cd332 100644 --- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts +++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts @@ -910,13 +910,19 @@ export class GeneralViewModel { this.$scope.isBaseTypeRequired = baseTypeResponseList.required; this.$scope.baseTypes = []; this.$scope.baseTypeVersions = []; + let defaultBaseType = baseTypeResponseList.defaultBaseType; baseTypeResponseList.baseTypes.forEach(baseType => this.$scope.baseTypes.push(baseType.toscaResourceName)); - if (this.$scope.isBaseTypeRequired) { - const baseType = baseTypeResponseList.baseTypes[0]; - baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version)); - if(!this.$scope.component.derivedFromGenericType) { - this.$scope.component.derivedFromGenericType = baseType.toscaResourceName; + if (this.$scope.isBaseTypeRequired || defaultBaseType != null) { + let baseType = baseTypeResponseList.baseTypes[0]; + if(defaultBaseType != null){ + baseTypeResponseList.baseTypes.forEach(baseTypeObj => { + if(baseTypeObj.toscaResourceName == defaultBaseType) { + baseType = baseTypeObj; + } + }); } + baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version)); + this.$scope.component.derivedFromGenericType = baseType.toscaResourceName; this.$scope.component.derivedFromGenericVersion = this.$scope.baseTypeVersions[0]; this.$scope.showBaseTypeVersions = true; return -- cgit 1.2.3-korg