diff --git a/lib/content-services/document-list/components/document-list.component.spec.ts b/lib/content-services/document-list/components/document-list.component.spec.ts index 99909f5e67..8bc27e01b1 100644 --- a/lib/content-services/document-list/components/document-list.component.spec.ts +++ b/lib/content-services/document-list/components/document-list.component.spec.ts @@ -959,6 +959,38 @@ describe('DocumentList', () => { documentList.loadFolderByNodeId('123'); }); + it('should reset noPermission on loading folder by node id', () => { + documentList.noPermission = true; + fixture.detectChanges(); + + documentList.loadFolderByNodeId('-trashcan-'); + fixture.detectChanges(); + + expect(documentList.noPermission).toBeFalsy(); + }); + + it('should reset noPermission upon reload', () => { + documentList.noPermission = true; + fixture.detectChanges(); + + documentList.reload(); + fixture.detectChanges(); + + expect(documentList.noPermission).toBeFalsy(); + }); + + it('should reload contents if node data changes after previously got noPermission error', () => { + spyOn(documentList.data, 'loadPage').and.callThrough(); + + documentList.noPermission = true; + fixture.detectChanges(); + + documentList.ngOnChanges({ node: new SimpleChange(null, {list: {entities: {}}}, true) }); + + expect(documentList.data.loadPage).toHaveBeenCalled(); + expect(documentList.noPermission).toBeFalsy(); + }); + xit('should load previous page if there are no other elements in multi page table', (done) => { documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692'; documentList.folderNode = new NodeMinimal(); diff --git a/lib/content-services/document-list/components/document-list.component.ts b/lib/content-services/document-list/components/document-list.component.ts index bf50a7530a..64f07db716 100644 --- a/lib/content-services/document-list/components/document-list.component.ts +++ b/lib/content-services/document-list/components/document-list.component.ts @@ -337,6 +337,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte } else if (this.data) { if (changes.node && changes.node.currentValue) { this.resetSelection(); + this.data.loadPage(changes.node.currentValue); this.pagination.next(changes.node.currentValue.list.pagination); } else if (changes.rowFilter) { @@ -557,6 +558,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte loadFolderNodesByFolderNodeId(id: string, maxItems: number, skipCount: number, merge: boolean = false): Promise { return new Promise((resolve, reject) => { this.resetSelection(); + this.documentListService .getFolder(null, { maxItems: maxItems, @@ -581,6 +583,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte resetSelection() { this.dataTable.resetSelection(); this.selection = []; + this.noPermission = false; } private isSkipCountChanged(changePage: SimpleChanges) {