mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2393] fixed reloading on delete with infinite scrolling (#3057)
* [ADF-2393] fixed reloading on delete with infinite scrolling * [ADF-2393] refactored after PR
This commit is contained in:
@@ -295,7 +295,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
emitReadyEvent(event: any) {
|
||||
if (this.pageIsEmpty(event)) {
|
||||
if (this.standardPagination && this.pageIsEmpty(event)) {
|
||||
this.standardPagination.goPrevious();
|
||||
} else {
|
||||
this.documentListReady.emit(event);
|
||||
@@ -328,11 +328,20 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
||||
onContentActionSuccess(message) {
|
||||
const translatedMessage: any = this.translateService.get(message);
|
||||
this.notificationService.openSnackMessage(translatedMessage.value, 4000);
|
||||
this.reloadForInfiniteScrolling();
|
||||
}
|
||||
|
||||
onDeleteActionSuccess(message) {
|
||||
this.uploadService.fileDeleted.next(message);
|
||||
this.deleteElementSuccess.emit();
|
||||
this.reloadForInfiniteScrolling();
|
||||
}
|
||||
|
||||
private reloadForInfiniteScrolling() {
|
||||
if (this.infiniteScrolling) {
|
||||
this.documentList.skipCount = 0;
|
||||
this.documentList.reload();
|
||||
}
|
||||
}
|
||||
|
||||
onManageVersions(event) {
|
||||
|
@@ -204,19 +204,6 @@ describe('DocumentActionsService', () => {
|
||||
expect(documentListService.deleteNode).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload target upon node deletion', () => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(Observable.of(true));
|
||||
|
||||
let target = jasmine.createSpyObj('obj', ['reload']);
|
||||
let permission = 'delete';
|
||||
let file: any = new FileNode();
|
||||
file.entry.allowableOperations = ['delete'];
|
||||
service.getHandler('delete')(file, target, permission);
|
||||
|
||||
expect(documentListService.deleteNode).toHaveBeenCalled();
|
||||
expect(target.reload).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit success event upon node deletion', (done) => {
|
||||
service.success.subscribe((nodeId) => {
|
||||
expect(nodeId).not.toBeNull();
|
||||
|
@@ -101,9 +101,6 @@ export class DocumentActionsService {
|
||||
private prepareHandlers(actionObservable, type: string, action: string, target?: any, permission?: string): void {
|
||||
actionObservable.subscribe(
|
||||
(fileOperationMessage) => {
|
||||
if (target && typeof target.reload === 'function') {
|
||||
target.reload();
|
||||
}
|
||||
this.success.next(fileOperationMessage);
|
||||
},
|
||||
this.error.next.bind(this.error)
|
||||
@@ -117,9 +114,6 @@ export class DocumentActionsService {
|
||||
if (this.contentService.hasPermission(node.entry, permission)) {
|
||||
handlerObservable = this.documentListService.deleteNode(node.entry.id);
|
||||
handlerObservable.subscribe(() => {
|
||||
if (target && typeof target.reload === 'function') {
|
||||
target.reload();
|
||||
}
|
||||
this.success.next(node.entry.id);
|
||||
});
|
||||
return handlerObservable;
|
||||
|
Reference in New Issue
Block a user