mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
Fix pageSize value fetch for infinite pagination (#4073)
- uses pageSize defined on the component or by the UserPreferencesService if not defined
This commit is contained in:
parent
bdef2642e7
commit
411166605e
@ -139,7 +139,17 @@ describe('InfinitePaginationComponent', () => {
|
||||
|
||||
component.onLoadMore();
|
||||
|
||||
expect(testTarget.updatePagination).toHaveBeenCalledWith({ maxItems: 469, skipCount: 0, totalItems: 888, hasMoreItems: true, merge: true });
|
||||
expect(testTarget.updatePagination).toHaveBeenCalledWith({ maxItems: 444 + 25, skipCount: 0, totalItems: 888, hasMoreItems: true, merge: true });
|
||||
});
|
||||
|
||||
it('should call the target\'s updatePagination on invoking the onLoadMore with a specific pageSize', () => {
|
||||
component.target = testTarget;
|
||||
component.pageSize = 7;
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onLoadMore();
|
||||
|
||||
expect(testTarget.updatePagination).toHaveBeenCalledWith({ maxItems: 444 + component.pageSize, skipCount: 0, totalItems: 888, hasMoreItems: true, merge: true });
|
||||
});
|
||||
|
||||
it('should unsubscribe from the target\'s pagination on onDestroy', () => {
|
||||
|
@ -40,6 +40,9 @@ import { UserPreferencesService } from '../services/user-preferences.service';
|
||||
})
|
||||
export class InfinitePaginationComponent implements OnInit, OnDestroy, PaginationComponentInterface {
|
||||
|
||||
/**
|
||||
* @deprecated 3.0.0 - uses paginationSize's default in UserPreferencesService
|
||||
*/
|
||||
static DEFAULT_PAGE_SIZE: number = 25;
|
||||
|
||||
static DEFAULT_PAGINATION: PaginationModel = {
|
||||
@ -61,7 +64,7 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
|
||||
|
||||
/** Number of items that are added with each "load more" event. */
|
||||
@Input()
|
||||
pageSize: number = InfinitePaginationComponent.DEFAULT_PAGE_SIZE;
|
||||
pageSize: number;
|
||||
|
||||
/** Is a new page loading? */
|
||||
@Input('loading')
|
||||
@ -81,7 +84,7 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
|
||||
this.paginationSubscription = this.target.pagination.subscribe((pagination) => {
|
||||
this.isLoading = false;
|
||||
this.pagination = pagination;
|
||||
this.pageSize = this.userPreferencesService.paginationSize || this.pageSize;
|
||||
this.pageSize = this.pageSize || this.userPreferencesService.paginationSize;
|
||||
this.cdr.detectChanges();
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user