Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/app/+collection-page/collection-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -95,20 +96,23 @@ export class CollectionPageComponent implements OnInit {

this.route.queryParams.pipe(take(1)).subscribe((params) => {
this.metadata.processRemoteData(this.collectionRD$);
this.onPaginationChange(params);
});
}

isNotEmpty(object: any) {
return isNotEmpty(object);
}

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;

onPaginationChange(event: PaginationChangeEvent) {
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
Expand Down
19 changes: 19 additions & 0 deletions src/app/shared/pagination/paginationChangeEvent.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny thing, please add TypeDocs to describe this new interface. We require TypeDocs/comments for any public classes/interfaces/methods.

/**
* 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;
}