From 2e46eb97154da909b82d5efe1d336a3412594ff0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 3 May 2021 14:33:34 +0200 Subject: Refactor search filters --- client/src/app/core/rest/rest-table.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'client/src/app/core/rest/rest-table.ts') diff --git a/client/src/app/core/rest/rest-table.ts b/client/src/app/core/rest/rest-table.ts index 9baab8a39..a5b48f10c 100644 --- a/client/src/app/core/rest/rest-table.ts +++ b/client/src/app/core/rest/rest-table.ts @@ -1,25 +1,22 @@ import * as debug from 'debug' import { LazyLoadEvent, SortMeta } from 'primeng/api' -import { Subject } from 'rxjs' import { ActivatedRoute, Router } from '@angular/router' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' -import { RouteFilter } from '../routing' import { RestPagination } from './rest-pagination' const logger = debug('peertube:tables:RestTable') -export abstract class RestTable extends RouteFilter { +export abstract class RestTable { abstract totalRecords: number abstract sort: SortMeta abstract pagination: RestPagination - search: string rowsPerPageOptions = [ 10, 20, 50, 100 ] rowsPerPage = this.rowsPerPageOptions[0] expandedRows = {} - protected searchStream: Subject + search: string protected route: ActivatedRoute protected router: Router @@ -28,7 +25,6 @@ export abstract class RestTable extends RouteFilter { initialize () { this.loadSort() - this.initSearch() } loadSort () { @@ -56,7 +52,7 @@ export abstract class RestTable extends RouteFilter { count: this.rowsPerPage } - this.loadData() + this.reloadData() this.saveSort() } @@ -74,13 +70,18 @@ export abstract class RestTable extends RouteFilter { count: this.rowsPerPage } - this.loadData() + this.reloadData() } this.expandedRows = {} } - protected abstract loadData (): void + onSearch (search: string) { + this.search = search + this.reloadData() + } + + protected abstract reloadData (): void private getSortLocalStorageKey () { return 'rest-table-sort-' + this.getIdentifier() -- cgit v1.2.3