From a51055cc14a0640c7484b2123f36fc6d8e9003cd Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Tue, 5 Jan 2021 12:36:03 -0500 Subject: [PATCH 1/4] 680 Fix change event reference for recent submission --- .../+collection-page/collection-page.component.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/+collection-page/collection-page.component.ts b/src/app/+collection-page/collection-page.component.ts index b3c10b12df..0ac45384e0 100644 --- a/src/app/+collection-page/collection-page.component.ts +++ b/src/app/+collection-page/collection-page.component.ts @@ -104,11 +104,15 @@ export class CollectionPageComponent implements OnInit { } onPaginationChange(event) { - this.paginationConfig.currentPage = +event.page || this.paginationConfig.currentPage; - this.paginationConfig.pageSize = +event.pageSize || this.paginationConfig.pageSize; - this.sortConfig.direction = event.sortDirection || this.sortConfig.direction; - this.sortConfig.field = event.sortField || this.sortConfig.field; - + this.paginationConfig = Object.assign(new PaginationComponentOptions(), { + currentPage: event.pagination.currentPage || this.paginationConfig.currentPage, + pageSize: event.pagination.pageSize || this.paginationConfig.pageSize, + id: 'collection-page-pagination' + }); + this.sortConfig = Object.assign(new SortOptions('dc.date.accessioned', SortDirection.DESC), { + direction: event.sort.direction || this.sortConfig.direction, + field: event.sort.field || this.sortConfig.field + }); this.paginationChanges$.next({ paginationConfig: this.paginationConfig, sortConfig: this.sortConfig From ee2e3be057a33744d439c1fab2172181114c08de Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Wed, 20 Jan 2021 14:05:22 -0500 Subject: [PATCH 2/4] 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; +} From 771183097c38faed14c0426095eb502f600ca945 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Thu, 21 Jan 2021 11:10:25 -0500 Subject: [PATCH 3/4] 680 Untype incorrectly typed params --- src/app/+collection-page/collection-page.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/+collection-page/collection-page.component.ts b/src/app/+collection-page/collection-page.component.ts index 50444cf27f..8065480604 100644 --- a/src/app/+collection-page/collection-page.component.ts +++ b/src/app/+collection-page/collection-page.component.ts @@ -94,7 +94,7 @@ export class CollectionPageComponent implements OnInit { ) ); - this.route.queryParams.pipe(take(1)).subscribe((params: PaginationChangeEvent) => { + this.route.queryParams.pipe(take(1)).subscribe((params) => { this.metadata.processRemoteData(this.collectionRD$); }); } From b143ea7e611a50a20794becd7e59216a6a7dd753 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Tue, 26 Jan 2021 11:41:28 -0500 Subject: [PATCH 4/4] 680 add typedocs to new interface --- .../pagination/paginationChangeEvent.interface.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/app/shared/pagination/paginationChangeEvent.interface.ts b/src/app/shared/pagination/paginationChangeEvent.interface.ts index 35be7117f6..ccd2f2174d 100644 --- a/src/app/shared/pagination/paginationChangeEvent.interface.ts +++ b/src/app/shared/pagination/paginationChangeEvent.interface.ts @@ -1,7 +1,19 @@ import {PaginationComponentOptions} from './pagination-component-options.model'; import {SortOptions} from '../../core/cache/models/sort-options.model'; + +/** + * The pagination event that contains updated pagination properties + * for a given view + */ export interface PaginationChangeEvent { + /** + * The pagination component object that contains id, current page, max size, page size options, and page size + */ pagination: PaginationComponentOptions; + + /** + * The sort options object that contains which field to sort by and the sorting direction + */ sort: SortOptions; }