From 38f534f4c7c425f49925dd2d3615729eba703130 Mon Sep 17 00:00:00 2001 From: davsad Date: Mon, 23 Aug 2021 05:54:13 +0100 Subject: Filter catalog in UI based on model Issue-ID: SDC-3679 Signed-off-by: davsad Change-Id: Icd0eeb13dbfb1cc27745c7adf6a3212210e00a4a --- catalog-ui/src/app/ng2/pipes/entity-filter.pipe.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'catalog-ui/src/app/ng2/pipes') diff --git a/catalog-ui/src/app/ng2/pipes/entity-filter.pipe.ts b/catalog-ui/src/app/ng2/pipes/entity-filter.pipe.ts index af107ed006..b67f42d4df 100644 --- a/catalog-ui/src/app/ng2/pipes/entity-filter.pipe.ts +++ b/catalog-ui/src/app/ng2/pipes/entity-filter.pipe.ts @@ -20,7 +20,7 @@ import {Pipe, PipeTransform} from "@angular/core"; import {Component, Resource} from "app/models"; -import {ComponentType} from "app/utils/constants"; +import {ComponentType, DEFAULT_MODEL_NAME} from "app/utils/constants"; export interface ISearchFilter { [key:string]: string; @@ -34,6 +34,8 @@ export interface IEntityFilterObject { selectedCategoriesModel?:Array; // Statuses selectedStatuses?:Array; + // Models + selectedModels?:Array; // distributed distributed?:Array; // search @@ -129,6 +131,21 @@ export class EntityFilterPipe implements PipeTransform{ filteredComponents = filteredDistributed; } + // filter by model + // -------------------------------------------------------------------------- + if (filter.selectedModels && filter.selectedModels.length > 0) { + let filteredModels = []; + let defaultModelPresent = filter.selectedModels.indexOf(DEFAULT_MODEL_NAME) > -1; + angular.forEach(filteredComponents, (component:Component):void => { + if (filter.selectedModels.indexOf(component.model) > -1) { + filteredModels.push(component); + } else if (!component.model && defaultModelPresent) { + filteredModels.push(component); + } + }); + filteredComponents = filteredModels; + } + // filter by search // -------------------------------------------------------------------------- if (filter.search != undefined) { -- cgit 1.2.3-korg