Skip to content

Commit

Permalink
Merge pull request #979 from atmire/680-recent-submision-pagination-r…
Browse files Browse the repository at this point in the history
…eload

680 Fix change event reference for recent submission
  • Loading branch information
tdonohue committed Jan 27, 2021
2 parents ac9b97d + b143ea7 commit a64cb63
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/app/+collection-page/collection-page.component.ts
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
@@ -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 {
/**
* 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;
}

0 comments on commit a64cb63

Please sign in to comment.