From b18b041ade818cb8afe681649c1ac1293f6e860d Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Thu, 26 Apr 2018 15:15:02 +0100 Subject: [PATCH] add reset pagination (#3239) --- .../app/components/files/files.component.html | 4 ++-- .../src/app/components/files/files.component.ts | 17 ++++++++++++----- .../pagination/infinite-pagination.component.ts | 5 +++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html index 9f41f36b10..11e20b0295 100644 --- a/demo-shell/src/app/components/files/files.component.html +++ b/demo-shell/src/app/components/files/files.component.html @@ -346,7 +346,7 @@ (prevPage)="onPrevPage($event)"> {{ 'ADF-DOCUMENT-LIST.LAYOUT.LOAD_MORE' | translate }} @@ -448,7 +448,7 @@
- + {{'DOCUMENT_LIST.ENABLE_INFINITE_SCROLL' | translate}}
diff --git a/demo-shell/src/app/components/files/files.component.ts b/demo-shell/src/app/components/files/files.component.ts index bc64776b12..7bda00ed4d 100644 --- a/demo-shell/src/app/components/files/files.component.ts +++ b/demo-shell/src/app/components/files/files.component.ts @@ -28,7 +28,7 @@ import { AuthenticationService, AppConfigService, ContentService, TranslationService, FileUploadEvent, FolderCreatedEvent, LogService, NotificationService, UploadService, DataColumn, DataRow, UserPreferencesService, - PaginationComponent, FormValues, DisplayMode, UserPreferenceValues + PaginationComponent, FormValues, DisplayMode, UserPreferenceValues, InfinitePaginationComponent } from '@alfresco/adf-core'; import { DocumentListComponent, PermissionStyleModel } from '@alfresco/adf-content-services'; @@ -149,6 +149,10 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { @ViewChild('standardPagination') standardPagination: PaginationComponent; + @ViewChild(InfinitePaginationComponent) + infinitePaginationComponent: InfinitePaginationComponent; + + permissionsStyle: PermissionStyleModel[] = []; infiniteScrolling: boolean; supportedPages: number[]; @@ -349,9 +353,6 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { } private reloadForInfiniteScrolling() { - if (this.infiniteScrolling) { - this.documentList.skipCount = 0; - } this.documentList.reload(); } @@ -462,7 +463,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { this.turnedNextPage.emit(event); } - loadNextBatch(event: Pagination) { + loadNextBatch(event: Pagination): void { this.loadNext.emit(event); } @@ -484,4 +485,10 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy { this.location.go(url); } } + + onInfiniteScrolling(): void { + this.infiniteScrolling = !this.infiniteScrolling; + this.infinitePaginationComponent.reset(); + this.reloadForInfiniteScrolling(); + } } diff --git a/lib/core/pagination/infinite-pagination.component.ts b/lib/core/pagination/infinite-pagination.component.ts index bebb295e87..479286075f 100644 --- a/lib/core/pagination/infinite-pagination.component.ts +++ b/lib/core/pagination/infinite-pagination.component.ts @@ -104,6 +104,11 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio } } + reset() { + this.pagination.skipCount = 0; + this.target.updatePagination(this.pagination); + } + ngOnDestroy() { if (this.paginationSubscription) { this.paginationSubscription.unsubscribe();