pagination workarounds (#321)

* pagination workarounds

* update the code
This commit is contained in:
Denys Vuika
2018-04-19 08:17:23 +01:00
committed by Cilibiu Bogdan
parent cb409335b0
commit c4b03e2bb4
2 changed files with 9 additions and 8 deletions

View File

@@ -44,7 +44,6 @@ import { PageComponent } from '../page.component';
})
export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
private routeData: any = {};
isValidPath = true;
private nodePath: PathElement[];
@@ -77,7 +76,6 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
const { route, contentManagementService, contentService, nodeActionsService, uploadService } = this;
const { data } = route.snapshot;
this.routeData = data;
this.title = data.i18nTitle;
route.params.subscribe(({ folderId }: Params) => {
@@ -128,7 +126,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
return this.nodesApi.getNode(nodeId);
}
fetchNodes(parentNodeId?: string, options: any = {}): Observable<NodePaging> {
fetchNodes(parentNodeId?: string, options: { maxItems?: number, skipCount?: number } = {}): Observable<NodePaging> {
const defaults = {
include: [ 'isLocked', 'path', 'properties', 'allowableOperations' ]
};
@@ -205,15 +203,17 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
}
}
load(showIndicator: boolean = false, pagination: any = {}) {
load(showIndicator: boolean = false, options: { maxItems?: number, skipCount?: number } = {}) {
this.isLoading = showIndicator;
this.fetchNodes(this.getParentNodeId(), pagination)
this.fetchNodes(this.getParentNodeId(), options)
.flatMap((page) => {
if (this.isCurrentPageEmpty(page) && this.isNotFirstPage(page)) {
const newSkipCount = pagination.skipCount - pagination.maxItems;
const newSkipCount = options.skipCount - options.maxItems;
return this.fetchNodes(this.getParentNodeId(), {skipCount: newSkipCount, maxItems: pagination.maxItems});
return this.fetchNodes(this.getParentNodeId(), {
skipCount: newSkipCount, maxItems: options.maxItems
});
}
return Observable.of(page);