From c5d04b4f3543bd1e5b07773b191f58c520edf205 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 1 Oct 2018 17:21:03 +0200 Subject: add allow advancedSearch with empty search a.k.a. filters on all videos also added a badge showing the rough number of active filters --- client/src/app/search/search.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'client/src/app/search/search.component.ts') diff --git a/client/src/app/search/search.component.ts b/client/src/app/search/search.component.ts index 475fdd277..b86b5083a 100644 --- a/client/src/app/search/search.component.ts +++ b/client/src/app/search/search.component.ts @@ -30,7 +30,7 @@ export class SearchComponent implements OnInit, OnDestroy { currentSearch: string private subActivatedRoute: Subscription - private isInitialLoad = true + private isInitialLoad = false // set to false to show the search filters on first arrival private firstSearch = true private channelsPerPage = 2 @@ -137,6 +137,10 @@ export class SearchComponent implements OnInit, OnDestroy { this.updateUrlFromAdvancedSearch() } + numberOfFilters () { + return this.advancedSearch.size() + } + private resetPagination () { this.pagination.currentPage = 1 this.pagination.totalItems = null @@ -150,9 +154,11 @@ export class SearchComponent implements OnInit, OnDestroy { } private updateUrlFromAdvancedSearch () { + const search = (this.currentSearch && this.currentSearch !== '') ? this.currentSearch : undefined + this.router.navigate([], { relativeTo: this.route, - queryParams: Object.assign({}, this.advancedSearch.toUrlObject(), { search: this.currentSearch }) + queryParams: Object.assign({}, this.advancedSearch.toUrlObject(), { search }) }) } } -- cgit v1.2.3