mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2175] Document List requests are executed twice when opening the copy and move dialog (#2960)
* [ADF-2175] Document List requests are executed twice when opening the dialog fixed bug * [ADF-2175] added unit tests for the change & refactored initial code
This commit is contained in:
committed by
Eugenio Romano
parent
adb0b8df38
commit
d731cc651c
@@ -1204,4 +1204,22 @@ describe('DocumentList', () => {
|
||||
|
||||
expect(documentList.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should NOT reload data on first call of onNgChanges', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
const firstChange = true;
|
||||
documentList.ngOnChanges({ skipCount: new SimpleChange(undefined, 10, firstChange) });
|
||||
|
||||
expect(documentList.reload).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload data on NON-first calls of onNgChanges', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
const firstChange = true;
|
||||
documentList.ngOnChanges({ skipCount: new SimpleChange(undefined, 10, !firstChange) });
|
||||
|
||||
expect(documentList.reload).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@@ -567,6 +567,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
private isSkipCountChanged(changePage: SimpleChanges) {
|
||||
return changePage.skipCount &&
|
||||
!changePage.skipCount.isFirstChange() &&
|
||||
changePage.skipCount.currentValue !== null &&
|
||||
changePage.skipCount.currentValue !== undefined &&
|
||||
changePage.skipCount.currentValue !== changePage.skipCount.previousValue;
|
||||
@@ -574,6 +575,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
|
||||
private isMaxItemsChanged(changePage: SimpleChanges) {
|
||||
return changePage.maxItems &&
|
||||
!changePage.maxItems.isFirstChange() &&
|
||||
changePage.maxItems.currentValue &&
|
||||
changePage.maxItems.currentValue !== changePage.maxItems.previousValue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user