From ee2e3be057a33744d439c1fab2172181114c08de Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Wed, 20 Jan 2021 14:05:22 -0500 Subject: [PATCH] 680 Add paginationChangeEvent interface and move to PaginationComponent impl for event handling --- src/app/+collection-page/collection-page.component.ts | 6 +++--- .../shared/pagination/paginationChangeEvent.interface.ts | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 src/app/shared/pagination/paginationChangeEvent.interface.ts diff --git a/src/app/+collection-page/collection-page.component.ts b/src/app/+collection-page/collection-page.component.ts index 0ac45384e0..50444cf27f 100644 --- a/src/app/+collection-page/collection-page.component.ts +++ b/src/app/+collection-page/collection-page.component.ts @@ -21,6 +21,7 @@ import { fadeIn, fadeInOut } from '../shared/animations/fade'; import { hasValue, isNotEmpty } from '../shared/empty.util'; import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model'; import { AuthService } from '../core/auth/auth.service'; +import {PaginationChangeEvent} from '../shared/pagination/paginationChangeEvent.interface'; @Component({ selector: 'ds-collection-page', @@ -93,9 +94,8 @@ export class CollectionPageComponent implements OnInit { ) ); - this.route.queryParams.pipe(take(1)).subscribe((params) => { + this.route.queryParams.pipe(take(1)).subscribe((params: PaginationChangeEvent) => { this.metadata.processRemoteData(this.collectionRD$); - this.onPaginationChange(params); }); } @@ -103,7 +103,7 @@ export class CollectionPageComponent implements OnInit { return isNotEmpty(object); } - onPaginationChange(event) { + onPaginationChange(event: PaginationChangeEvent) { this.paginationConfig = Object.assign(new PaginationComponentOptions(), { currentPage: event.pagination.currentPage || this.paginationConfig.currentPage, pageSize: event.pagination.pageSize || this.paginationConfig.pageSize, diff --git a/src/app/shared/pagination/paginationChangeEvent.interface.ts b/src/app/shared/pagination/paginationChangeEvent.interface.ts new file mode 100644 index 0000000000..35be7117f6 --- /dev/null +++ b/src/app/shared/pagination/paginationChangeEvent.interface.ts @@ -0,0 +1,7 @@ +import {PaginationComponentOptions} from './pagination-component-options.model'; +import {SortOptions} from '../../core/cache/models/sort-options.model'; + +export interface PaginationChangeEvent { + pagination: PaginationComponentOptions; + sort: SortOptions; +}