reset pagination on data source change (#2443)

This commit is contained in:
Denys Vuika
2017-10-06 12:22:03 +01:00
committed by Eugenio Romano
parent bdd26e6c42
commit 100479f017
2 changed files with 13 additions and 1 deletions

View File

@@ -972,4 +972,11 @@ describe('DocumentList', () => {
expect(documentList.reload).toHaveBeenCalledTimes(2); expect(documentList.reload).toHaveBeenCalledTimes(2);
}); });
it('should reset pagination when switching sources', () => {
spyOn(documentList, 'resetPagination').and.callThrough();
documentList.loadFolderByNodeId('-trashcan-');
documentList.loadFolderByNodeId('-sites-');
expect(documentList.resetPagination).toHaveBeenCalledTimes(2);
});
}); });

View File

@@ -404,7 +404,9 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
// gets folder node and its content // gets folder node and its content
loadFolderByNodeId(nodeId: string) { loadFolderByNodeId(nodeId: string) {
this.loading = true; this.loading = true;
this.resetSelection(); this.resetSelection();
this.resetPagination();
if (nodeId === '-trashcan-') { if (nodeId === '-trashcan-') {
this.loadTrashcan(); this.loadTrashcan();
@@ -421,7 +423,6 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
.getFolderNode(nodeId).then(node => { .getFolderNode(nodeId).then(node => {
this.folderNode = node; this.folderNode = node;
this.currentFolderId = node.id; this.currentFolderId = node.id;
this.skipCount = 0;
this.currentNodeAllowableOperations = node['allowableOperations'] ? node['allowableOperations'] : []; this.currentNodeAllowableOperations = node['allowableOperations'] ? node['allowableOperations'] : [];
this.loadFolderNodesByFolderNodeId(node.id, this.pageSize, this.skipCount).catch(err => this.error.emit(err)); this.loadFolderNodesByFolderNodeId(node.id, this.pageSize, this.skipCount).catch(err => this.error.emit(err));
}) })
@@ -467,6 +468,10 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
this.selection = []; this.selection = [];
} }
resetPagination() {
this.skipCount = 0;
}
private loadTrashcan(): void { private loadTrashcan(): void {
const options = { const options = {
include: [ 'path', 'properties' ], include: [ 'path', 'properties' ],