diff options
author | andre.schmid <andre.schmid@est.tech> | 2021-09-09 16:45:25 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-09-10 09:21:40 +0000 |
commit | cb328c79d8f44374975befa52a103afcedf52680 (patch) | |
tree | 2e79263a5b0410164f38f0747c91580893fc2f0e /catalog-ui/src/app/view-models/workspace | |
parent | 10a832ed3dea1924bfa555ab3b85b1cf1b228b2f (diff) |
Fix create a service with SDC AID model
Change-Id: Ia5f0fa1304f6eab609862dd76f9b9f3485f468d1
Issue-ID: SDC-3723
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-ui/src/app/view-models/workspace')
3 files changed, 17 insertions, 30 deletions
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 dd1fa464bf..1bcf266c55 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 @@ -468,18 +468,20 @@ export class GeneralViewModel { this.$scope.initModel = ():void => { this.$scope.isModelRequired = false; - this.$scope.models = [{id: '', name: 'SDC AID'}]; + this.$scope.models = []; + this.$scope.defaultModelOption = 'SDC AID'; + this.$scope.showDefaultModelOption = true; if (this.$scope.isCreateMode() && this.$scope.isVspImport()) { if (this.$scope.component.componentMetadata.models) { this.$scope.isModelRequired = true; - const modelOptions = this.$scope.component.componentMetadata.models.map(value => { - return {id: value, name: value}; - }); + const modelOptions = this.$scope.component.componentMetadata.models; if (modelOptions.length == 1) { this.$scope.models = modelOptions; - this.$scope.component.model = modelOptions[0].id; + this.$scope.component.model = modelOptions[0]; + this.$scope.showDefaultModelOption = false; } else { - this.$scope.models = [{id: '', name: 'Select'}, ...modelOptions]; + this.$scope.models = modelOptions.sort(); + this.$scope.defaultModelOption = 'Select'; } } return; @@ -487,23 +489,13 @@ export class GeneralViewModel { if (!this.$scope.isCreateMode() && this.$scope.isVspImport()){ this.modelService.getModels().subscribe((modelsFound: Model[]) => { - modelsFound.forEach(model => {this.$scope.models.push({id: model.name, name: model.name})}); - }); + modelsFound.sort().forEach(model => {this.$scope.models.push(model.name)}); + }); } else { this.modelService.getModelsOfType("normative").subscribe((modelsFound: Model[]) => { - modelsFound.forEach(model => {this.$scope.models.push({id: model.name, name: model.name})}); + modelsFound.sort().forEach(model => {this.$scope.models.push(model.name)}); }); } - - this.$scope.models.sort(function (model1, model2) { - if (model1.id > model2.id) { - return 1; - } - if (model1.id < model2.id) { - return -1; - } - return 0; - }); }; this.$scope.isVspImport = (): boolean => { diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html index 5035ef2015..2366eea2c1 100644 --- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html @@ -80,14 +80,15 @@ <div class="i-sdc-form-item"> <label class="i-sdc-form-label required">Model</label> <select class="i-sdc-form-select" - name="modelName" data-ng-class="{'view-mode': isViewMode()}" data-ng-disabled="!isCreateMode()" - data-ng-model="component.model" data-ng-change="onModelChange()" data-tests-id="modelName" - ng-required="isModelRequired"> - <option ng-repeat="model in models" value="{{model.id}}">{{model.name}}</option> + data-ng-required="isModelRequired" + data-ng-model="component.model" + data-ng-options="model for model in models track by model" + > + <option ng-if="showDefaultModelOption" value="">{{defaultModelOption}}</option> </select> </div> <!--------------------- Model --------------------> diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts index 411ef10639..c72a5a471c 100644 --- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts +++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts @@ -55,11 +55,6 @@ import { IDependenciesServerResponse } from '../../ng2/services/responses/depend import { WorkspaceNg1BridgeService } from '../../ng2/pages/workspace/workspace-ng1-bridge-service'; import { WorkspaceService } from '../../ng2/pages/workspace/workspace.service'; -interface ModelSelectOption { - id: string; - name: string; -} - export interface IWorkspaceViewModelScope extends ng.IScope { isLoading: boolean; @@ -96,8 +91,7 @@ export interface IWorkspaceViewModelScope extends ng.IScope { unsavedChangesCallback: Function; unsavedFile: boolean; hasNoDependencies: boolean; - models: Array<ModelSelectOption>; - + models: Array<string>; startProgress(message: string): void; stopProgress(): void; |