mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2391] skipCount is not reset on document-list when choosing a custom source from adf-sites-dropdown, nor the currentFolderId and folderNode (#3012)
* [ADF-2391] skipCount is not reset on document-list when choosing a custom source from adf-sites-dropdown, nor the currentFolderId and folderNode fix and tests added * [ADF-2391] refactor code & took into account merge parameter
This commit is contained in:
committed by
Eugenio Romano
parent
f41498658b
commit
0a748ac555
@@ -1218,6 +1218,27 @@ describe('DocumentList', () => {
|
||||
expect(documentList.folderNode).toBeNull();
|
||||
});
|
||||
|
||||
it('should reset folder node on loading folder by node id', () => {
|
||||
documentList.folderNode = <any> {};
|
||||
|
||||
const sitesApi = apiService.getInstance().core.sitesApi;
|
||||
spyOn(sitesApi, 'getSites').and.returnValue(Promise.resolve(null));
|
||||
|
||||
documentList.loadFolderByNodeId('-sites-');
|
||||
|
||||
expect(documentList.folderNode).toBeNull();
|
||||
});
|
||||
|
||||
it('should have correct currentFolderId on loading folder by node id', () => {
|
||||
documentList.currentFolderId = '12345-some-id-6789';
|
||||
|
||||
const peopleApi = apiService.getInstance().core.peopleApi;
|
||||
spyOn(peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve());
|
||||
|
||||
documentList.loadFolderByNodeId('-mysites-');
|
||||
expect(documentList.currentFolderId).toBe('-mysites-');
|
||||
});
|
||||
|
||||
it('should update pagination settings', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
|
||||
@@ -1304,4 +1325,21 @@ describe('DocumentList', () => {
|
||||
|
||||
expect(documentList.reload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reset skipCount from pagination settings on loading folder by node id', () => {
|
||||
spyOn(documentList, 'reload').and.stub();
|
||||
const favoritesApi = apiService.getInstance().core.favoritesApi;
|
||||
spyOn(favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(null));
|
||||
|
||||
documentList.maxItems = 0;
|
||||
documentList.skipCount = 0;
|
||||
|
||||
documentList.updatePagination({
|
||||
maxItems: 10,
|
||||
skipCount: 10
|
||||
});
|
||||
|
||||
documentList.loadFolderByNodeId('-favorites-');
|
||||
expect(documentList.skipCount).toBe(0, 'skipCount is reset');
|
||||
});
|
||||
});
|
||||
|
@@ -468,6 +468,14 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
this.folderChange.emit(new NodeEntryEvent(node.entry));
|
||||
}
|
||||
|
||||
updateCustomSourceData(nodeId: string, merge: boolean): void {
|
||||
this.folderNode = null;
|
||||
this.currentFolderId = nodeId;
|
||||
if (!merge) {
|
||||
this.skipCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when executing content action for a document or folder.
|
||||
* @param node Node to be the context of the execution.
|
||||
@@ -589,6 +597,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
private loadTrashcan(merge: boolean = false): void {
|
||||
this.updateCustomSourceData('-trashcan-', merge);
|
||||
|
||||
const options = {
|
||||
include: ['path', 'properties'],
|
||||
maxItems: this.maxItems,
|
||||
@@ -600,6 +610,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
private loadSharedLinks(merge: boolean = false): void {
|
||||
this.updateCustomSourceData('-sharedlinks-', merge);
|
||||
|
||||
const options = {
|
||||
include: ['properties', 'allowableOperations', 'path'],
|
||||
maxItems: this.maxItems,
|
||||
@@ -611,6 +623,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
private loadSites(merge: boolean = false): void {
|
||||
this.updateCustomSourceData('-sites-', merge);
|
||||
|
||||
const options = {
|
||||
include: ['properties'],
|
||||
maxItems: this.maxItems,
|
||||
@@ -631,6 +645,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
private loadMemberSites(merge: boolean = false): void {
|
||||
this.updateCustomSourceData('-mysites-', merge);
|
||||
|
||||
const options = {
|
||||
include: ['properties'],
|
||||
maxItems: this.maxItems,
|
||||
@@ -659,6 +675,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
private loadFavorites(merge: boolean = false): void {
|
||||
this.updateCustomSourceData('-favorites-', merge);
|
||||
|
||||
const options = {
|
||||
maxItems: this.maxItems,
|
||||
skipCount: this.skipCount,
|
||||
@@ -690,6 +708,8 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
||||
}
|
||||
|
||||
private loadRecent(merge: boolean = false): void {
|
||||
this.updateCustomSourceData('-recent-', merge);
|
||||
|
||||
this.getRecentFiles('-me-')
|
||||
.then((page: NodePaging) => this.onPageLoaded(page, merge))
|
||||
.catch(error => this.error.emit(error));
|
||||
|
Reference in New Issue
Block a user