aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/search/advanced-search.model.ts13
-rw-r--r--client/src/app/search/search.component.html5
-rw-r--r--client/src/app/search/search.component.ts10
3 files changed, 25 insertions, 3 deletions
diff --git a/client/src/app/search/advanced-search.model.ts b/client/src/app/search/advanced-search.model.ts
index 48616a9ae..033fa9bba 100644
--- a/client/src/app/search/advanced-search.model.ts
+++ b/client/src/app/search/advanced-search.model.ts
@@ -110,6 +110,19 @@ export class AdvancedSearch {
110 } 110 }
111 } 111 }
112 112
113 size () {
114 let acc = 0
115
116 const obj = this.toUrlObject()
117 for (const k of Object.keys(obj)) {
118 if (k === 'sort') continue // Exception
119
120 if (obj[k] !== undefined) acc++
121 }
122
123 return acc
124 }
125
113 private intoArray (value: any) { 126 private intoArray (value: any) {
114 if (!value) return undefined 127 if (!value) return undefined
115 128
diff --git a/client/src/app/search/search.component.html b/client/src/app/search/search.component.html
index 61a05895e..3a87ea1de 100644
--- a/client/src/app/search/search.component.html
+++ b/client/src/app/search/search.component.html
@@ -13,7 +13,10 @@
13 [attr.aria-expanded]="!isSearchFilterCollapsed" aria-controls="collapseBasic" 13 [attr.aria-expanded]="!isSearchFilterCollapsed" aria-controls="collapseBasic"
14 > 14 >
15 <span class="icon icon-filter"></span> 15 <span class="icon icon-filter"></span>
16 <ng-container i18n>Filters</ng-container> 16 <ng-container i18n>
17 Filters
18 <span *ngIf="numberOfFilters() > 0" class="badge badge-secondary">{{ numberOfFilters() }}</span>
19 </ng-container>
17 </div> 20 </div>
18 </div> 21 </div>
19 22
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 {
30 currentSearch: string 30 currentSearch: string
31 31
32 private subActivatedRoute: Subscription 32 private subActivatedRoute: Subscription
33 private isInitialLoad = true 33 private isInitialLoad = false // set to false to show the search filters on first arrival
34 private firstSearch = true 34 private firstSearch = true
35 35
36 private channelsPerPage = 2 36 private channelsPerPage = 2
@@ -137,6 +137,10 @@ export class SearchComponent implements OnInit, OnDestroy {
137 this.updateUrlFromAdvancedSearch() 137 this.updateUrlFromAdvancedSearch()
138 } 138 }
139 139
140 numberOfFilters () {
141 return this.advancedSearch.size()
142 }
143
140 private resetPagination () { 144 private resetPagination () {
141 this.pagination.currentPage = 1 145 this.pagination.currentPage = 1
142 this.pagination.totalItems = null 146 this.pagination.totalItems = null
@@ -150,9 +154,11 @@ export class SearchComponent implements OnInit, OnDestroy {
150 } 154 }
151 155
152 private updateUrlFromAdvancedSearch () { 156 private updateUrlFromAdvancedSearch () {
157 const search = (this.currentSearch && this.currentSearch !== '') ? this.currentSearch : undefined
158
153 this.router.navigate([], { 159 this.router.navigate([], {
154 relativeTo: this.route, 160 relativeTo: this.route,
155 queryParams: Object.assign({}, this.advancedSearch.toUrlObject(), { search: this.currentSearch }) 161 queryParams: Object.assign({}, this.advancedSearch.toUrlObject(), { search })
156 }) 162 })
157 } 163 }
158} 164}