mirror of https://github.com/Chocobozzz/PeerTube
add allow advancedSearch with empty search
a.k.a. filters on all videos also added a badge showing the rough number of active filterspull/1162/head
parent
99cc653f47
commit
c5d04b4f35
|
@ -110,6 +110,19 @@ export class AdvancedSearch {
|
|||
}
|
||||
}
|
||||
|
||||
size () {
|
||||
let acc = 0
|
||||
|
||||
const obj = this.toUrlObject()
|
||||
for (const k of Object.keys(obj)) {
|
||||
if (k === 'sort') continue // Exception
|
||||
|
||||
if (obj[k] !== undefined) acc++
|
||||
}
|
||||
|
||||
return acc
|
||||
}
|
||||
|
||||
private intoArray (value: any) {
|
||||
if (!value) return undefined
|
||||
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
[attr.aria-expanded]="!isSearchFilterCollapsed" aria-controls="collapseBasic"
|
||||
>
|
||||
<span class="icon icon-filter"></span>
|
||||
<ng-container i18n>Filters</ng-container>
|
||||
<ng-container i18n>
|
||||
Filters
|
||||
<span *ngIf="numberOfFilters() > 0" class="badge badge-secondary">{{ numberOfFilters() }}</span>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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 })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
//@import '~bootstrap/scss/card';
|
||||
//@import '~bootstrap/scss/breadcrumb';
|
||||
//@import '~bootstrap/scss/pagination';
|
||||
//@import '~bootstrap/scss/badge';
|
||||
@import '~bootstrap/scss/badge';
|
||||
//@import '~bootstrap/scss/jumbotron';
|
||||
@import '~bootstrap/scss/alert';
|
||||
//@import '~bootstrap/scss/progress';
|
||||
|
|
Loading…
Reference in New Issue