aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pipes
diff options
context:
space:
mode:
authordavsad <david.sadlier@est.tech>2021-08-23 05:54:13 +0100
committerDavid Sadlier <david.sadlier@est.tech>2021-08-23 23:09:40 +0000
commit38f534f4c7c425f49925dd2d3615729eba703130 (patch)
treefcf7b3d0430e83d1ebf769fa1d85ddabcc6eb46f /catalog-ui/src/app/ng2/pipes
parente5b8482c4d2ceddf559da26e532fdbb95a593dc1 (diff)
Filter catalog in UI based on model
Issue-ID: SDC-3679 Signed-off-by: davsad <david.sadlier@est.tech> Change-Id: Icd0eeb13dbfb1cc27745c7adf6a3212210e00a4a
Diffstat (limited to 'catalog-ui/src/app/ng2/pipes')
-rw-r--r--catalog-ui/src/app/ng2/pipes/entity-filter.pipe.ts19
1 files changed, 18 insertions, 1 deletions
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<string>;
// Statuses
selectedStatuses?:Array<string>;
+ // Models
+ selectedModels?:Array<string>;
// distributed
distributed?:Array<string>;
// 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) {