mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
pagination workarounds (#321)
* pagination workarounds * update the code
This commit is contained in:
parent
cb409335b0
commit
c4b03e2bb4
@ -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);
|
||||
|
@ -64,7 +64,8 @@ export abstract class PageComponent {
|
||||
onPageLoaded(page: NodePaging) {
|
||||
this.isLoading = false;
|
||||
this.paging = page;
|
||||
this.pagination = page.list.pagination;
|
||||
// TODO: review after ADF-2768 is fixed
|
||||
this.pagination = this.pagination || page.list.pagination;
|
||||
this.isEmpty = !(page.list.entries && page.list.entries.length > 0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user