From 1ff833ed8a208adce35d28b916a670e98fc97d1e Mon Sep 17 00:00:00 2001 From: argirok Date: Mon, 13 Nov 2023 13:46:42 +0200 Subject: [PATCH] [angular-16-irish-monitor | DONE | CHANGED ] Search pages (projects, organizations, datasources ) Custom Filter accept single or an array of Custom filters --- searchPages/searchDataProviders.component.ts | 13 ++++++++++--- searchPages/searchOrganizations.component.ts | 13 ++++++++++--- searchPages/searchProjects.component.ts | 13 ++++++++++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/searchPages/searchDataProviders.component.ts b/searchPages/searchDataProviders.component.ts index fcec42c9..f7e39178 100644 --- a/searchPages/searchDataProviders.component.ts +++ b/searchPages/searchDataProviders.component.ts @@ -49,8 +49,15 @@ import {properties} from "../../../environments/environment"; export class SearchDataProvidersComponent { private errorCodes: ErrorCodes; private errorMessages: ErrorMessagesComponent; - @Input() customFilter:SearchCustomFilter= null; - @Input() tableViewLink; + @Input() customFilters: SearchCustomFilter[] = null; + @Input() + set customFilter(customFilter: SearchCustomFilter | SearchCustomFilter[]) { + if(!Array.isArray(customFilter)) { + this.customFilters = [customFilter]; + }else{ + this.customFilters = customFilter; + } + } @Input() tableViewLink; @Input() searchForm: SearchForm = {class: 'search-form', dark: true}; public results =[]; public filters =[]; @@ -143,7 +150,7 @@ export class SearchDataProvidersComponent { this.searchPage.keywordFields = this.searchFields.DEPOSIT_DATASOURCE_KEYWORD_FIELDS; this.searchPage.usedBy = "deposit"; } - this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, this.entityType); + this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilters,params, this.entityType); if(refine) { this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(params), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); } else { diff --git a/searchPages/searchOrganizations.component.ts b/searchPages/searchOrganizations.component.ts index 54eeff07..78130564 100644 --- a/searchPages/searchOrganizations.component.ts +++ b/searchPages/searchOrganizations.component.ts @@ -61,8 +61,15 @@ export class SearchOrganizationsComponent { public loadPaging: boolean = true; public oldTotalResults: number = 0; public pagingLimit: number = 0; - @Input() customFilter:SearchCustomFilter= null; - public refineFields: string[] = this.searchFields.ORGANIZATION_REFINE_FIELDS; + @Input() customFilters: SearchCustomFilter[] = null; + @Input() + set customFilter(customFilter: SearchCustomFilter | SearchCustomFilter[]) { + if(!Array.isArray(customFilter)) { + this.customFilters = [customFilter]; + }else{ + this.customFilters = customFilter; + } + } public refineFields: string[] = this.searchFields.ORGANIZATION_REFINE_FIELDS; @ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent; @Input() simpleView: boolean = true; @Input() simpleSearchLink: string = ""; @@ -127,7 +134,7 @@ export class SearchOrganizationsComponent { // this.searchPage.fieldIdsMap = this.fieldIdsMap; // this.searchPage.customFilter = this.customFilter; // this.searchPage.getSelectedFiltersFromUrl(params); - this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "organization"); + this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilters,params, "organization"); if(refine) { this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, true, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); } else { diff --git a/searchPages/searchProjects.component.ts b/searchPages/searchProjects.component.ts index 1ebae061..5d9009a6 100644 --- a/searchPages/searchProjects.component.ts +++ b/searchPages/searchProjects.component.ts @@ -45,8 +45,15 @@ import {properties} from "../../../environments/environment"; export class SearchProjectsComponent { private errorCodes: ErrorCodes; private errorMessages: ErrorMessagesComponent; - @Input() customFilter: SearchCustomFilter = null; - @Input() searchForm: SearchForm = {class: 'search-form', dark: true}; + @Input() customFilters: SearchCustomFilter[] = null; + @Input() + set customFilter(customFilter: SearchCustomFilter | SearchCustomFilter[]) { + if(!Array.isArray(customFilter)) { + this.customFilters = [customFilter]; + }else{ + this.customFilters = customFilter; + } + } @Input() searchForm: SearchForm = {class: 'search-form', dark: true}; public results = []; public filters = []; public rangeFilters: RangeFilter[] = []; @@ -128,7 +135,7 @@ export class SearchProjectsComponent { this.searchPage.fieldIds = this.fieldIds; this.selectedFields = []; - this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap, this.customFilter, params, "project"); + this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap, this.customFilters, params, "project"); if (refine) { this._getFilters(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, 0, "", true, this.searchPage.getSearchAPIQueryForRangeFields(params) + this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); } else {