From dd69d6a46433c252128df82d0c9aff5dbd5fafec Mon Sep 17 00:00:00 2001 From: davsad Date: Tue, 7 Sep 2021 15:50:44 +0100 Subject: Model hierarchy not being considered while filtering Issue-ID: SDC-3718 Signed-off-by: davsad Change-Id: I4a984906aca180d470eb7bd71a09bfb0384cecb6 --- .../src/app/ng2/pages/catalog/catalog.component.ts | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'catalog-ui/src/app/ng2/pages') diff --git a/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts b/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts index 5d6526001c..5298e7e0d3 100644 --- a/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts +++ b/catalog-ui/src/app/ng2/pages/catalog/catalog.component.ts @@ -27,7 +27,6 @@ import { SdcMenuToken, IAppMenu } from "../../config/sdc-menu.config"; import { Component, ICategoryBase, IMainCategory, ISubCategory, IConfigStatuses, ICatalogSelector, CatalogSelectorTypes } from "app/models"; import { ResourceNamePipe } from "../../pipes/resource-name.pipe"; import { EntityFilterPipe, IEntityFilterObject, ISearchFilter} from "../../pipes/entity-filter.pipe"; -import { Model } from "app/models/model"; import { DEFAULT_MODEL_NAME } from "app/utils/constants"; interface Gui { @@ -78,7 +77,7 @@ export class CatalogComponent { public checkboxesFilterKeys:ICheckboxesFilterKeys; public gui:Gui; public categories:Array; - public models: Array = new Array(); + public models: Array = new Array(); public filteredCategories:Array; public confStatus:IConfigStatuses; public componentTypes:{[key:string]: Array}; @@ -157,8 +156,17 @@ export class CatalogComponent { this.numberOfItemToDisplay = 0; this.categories = this.makeSortedCategories(this.cacheService.get('serviceCategories').concat(this.cacheService.get('resourceCategories'))) .map((cat) => cat); - this.models = this.cacheService.get('models').map((model:Model) => model.name); - this.models.unshift(DEFAULT_MODEL_NAME); + + var modelList = this.cacheService.get('models'); + modelList.sort((o:any, o1:any) => new String(o.modelType).localeCompare(o1.modelType)); + modelList.forEach(m => { + if (m.derivedFrom) { + this.models[m.derivedFrom].push(m.name); + } else { + this.models[m.name] = []; + } + }); + this.models[DEFAULT_MODEL_NAME] = []; this.confStatus = this.sdcMenu.statuses; this.expandedSection = ["type", "category", "status", "model"]; this.catalogItems = []; @@ -229,14 +237,17 @@ export class CatalogComponent { private buildChecklistModelForModels() { this.modelsChecklistModel = new SdcUiCommon.ChecklistModel(this.checkboxesFilterKeys.models._main, - this.models.map((model) => new SdcUiCommon.ChecklistItemModel( - model, - false, - this.checkboxesFilterKeys.models._main.indexOf(model) !== -1, - null, - this.getTestIdForCheckboxByText(model), - model)) - ); + Object.keys(this.models).map((modelName) => { + var modelList = this.models[modelName]; + modelList.unshift(modelName); + return new SdcUiCommon.ChecklistItemModel( + modelName, + false, + this.checkboxesFilterKeys.models._main.indexOf(modelName) !== -1, + null, + this.getTestIdForCheckboxByText(modelName), + modelList); + })); } private buildChecklistModelForStatuses() { -- cgit 1.2.3-korg