mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-2406] [Document Picker] Unnecessary extra request is made on Load more click (#3019)
* [ADF-2406] [Document Picker] Unnecessary extra request is made on Load more click fixed bug * [ADF-2406] refactored code * [ADF-2406] added tests
This commit is contained in:
parent
ac994ed7af
commit
c1f0537a0d
@ -1278,4 +1278,30 @@ describe('DocumentList', () => {
|
|||||||
|
|
||||||
expect(documentList.reload).toHaveBeenCalled();
|
expect(documentList.reload).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should NOT reload data on onNgChanges upon reset of skipCount to 0', () => {
|
||||||
|
spyOn(documentList, 'reload').and.stub();
|
||||||
|
|
||||||
|
documentList.maxItems = 10;
|
||||||
|
documentList.skipCount = 10;
|
||||||
|
|
||||||
|
const firstChange = true;
|
||||||
|
documentList.ngOnChanges({ skipCount: new SimpleChange(undefined, 0, !firstChange) });
|
||||||
|
|
||||||
|
expect(documentList.reload).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reload data upon changing pagination setting skipCount to 0', () => {
|
||||||
|
spyOn(documentList, 'reload').and.stub();
|
||||||
|
|
||||||
|
documentList.maxItems = 5;
|
||||||
|
documentList.skipCount = 5;
|
||||||
|
|
||||||
|
documentList.updatePagination({
|
||||||
|
maxItems: 5,
|
||||||
|
skipCount: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(documentList.reload).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -577,8 +577,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
private isSkipCountChanged(changePage: SimpleChanges) {
|
private isSkipCountChanged(changePage: SimpleChanges) {
|
||||||
return changePage.skipCount &&
|
return changePage.skipCount &&
|
||||||
!changePage.skipCount.isFirstChange() &&
|
!changePage.skipCount.isFirstChange() &&
|
||||||
changePage.skipCount.currentValue !== null &&
|
changePage.skipCount.currentValue &&
|
||||||
changePage.skipCount.currentValue !== undefined &&
|
|
||||||
changePage.skipCount.currentValue !== changePage.skipCount.previousValue;
|
changePage.skipCount.currentValue !== changePage.skipCount.previousValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user