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) {
|
private intoArray (value: any) {
|
||||||
if (!value) return undefined
|
if (!value) return undefined
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
[attr.aria-expanded]="!isSearchFilterCollapsed" aria-controls="collapseBasic"
|
[attr.aria-expanded]="!isSearchFilterCollapsed" aria-controls="collapseBasic"
|
||||||
>
|
>
|
||||||
<span class="icon icon-filter"></span>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ export class SearchComponent implements OnInit, OnDestroy {
|
||||||
currentSearch: string
|
currentSearch: string
|
||||||
|
|
||||||
private subActivatedRoute: Subscription
|
private subActivatedRoute: Subscription
|
||||||
private isInitialLoad = true
|
private isInitialLoad = false // set to false to show the search filters on first arrival
|
||||||
private firstSearch = true
|
private firstSearch = true
|
||||||
|
|
||||||
private channelsPerPage = 2
|
private channelsPerPage = 2
|
||||||
|
@ -137,6 +137,10 @@ export class SearchComponent implements OnInit, OnDestroy {
|
||||||
this.updateUrlFromAdvancedSearch()
|
this.updateUrlFromAdvancedSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numberOfFilters () {
|
||||||
|
return this.advancedSearch.size()
|
||||||
|
}
|
||||||
|
|
||||||
private resetPagination () {
|
private resetPagination () {
|
||||||
this.pagination.currentPage = 1
|
this.pagination.currentPage = 1
|
||||||
this.pagination.totalItems = null
|
this.pagination.totalItems = null
|
||||||
|
@ -150,9 +154,11 @@ export class SearchComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateUrlFromAdvancedSearch () {
|
private updateUrlFromAdvancedSearch () {
|
||||||
|
const search = (this.currentSearch && this.currentSearch !== '') ? this.currentSearch : undefined
|
||||||
|
|
||||||
this.router.navigate([], {
|
this.router.navigate([], {
|
||||||
relativeTo: this.route,
|
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/card';
|
||||||
//@import '~bootstrap/scss/breadcrumb';
|
//@import '~bootstrap/scss/breadcrumb';
|
||||||
//@import '~bootstrap/scss/pagination';
|
//@import '~bootstrap/scss/pagination';
|
||||||
//@import '~bootstrap/scss/badge';
|
@import '~bootstrap/scss/badge';
|
||||||
//@import '~bootstrap/scss/jumbotron';
|
//@import '~bootstrap/scss/jumbotron';
|
||||||
@import '~bootstrap/scss/alert';
|
@import '~bootstrap/scss/alert';
|
||||||
//@import '~bootstrap/scss/progress';
|
//@import '~bootstrap/scss/progress';
|
||||||
|
|
Loading…
Reference in New Issue