From 407c1d2cad8ba4e9ac984afd818f41a510722d4b Mon Sep 17 00:00:00 2001 From: MichalKinas Date: Tue, 17 Dec 2024 13:31:24 +0100 Subject: [PATCH] [ACS-8604] Add new param to control undo for deleting nodes --- .../src/lib/services/content-management.service.ts | 4 ++-- projects/aca-content/src/lib/store/effects/node.effects.ts | 4 ++-- projects/aca-shared/store/src/actions/node.actions.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/aca-content/src/lib/services/content-management.service.ts b/projects/aca-content/src/lib/services/content-management.service.ts index 1d4142d50d..d191352fbf 100644 --- a/projects/aca-content/src/lib/services/content-management.service.ts +++ b/projects/aca-content/src/lib/services/content-management.service.ts @@ -660,7 +660,7 @@ export class ContentManagementService { ); } - deleteNodes(items: NodeEntry[]): void { + deleteNodes(items: NodeEntry[], allowUndo = true): void { const batch: Observable[] = []; items.forEach((node) => { @@ -671,7 +671,7 @@ export class ContentManagementService { const status = this.processStatus(data); const message = this.getDeleteMessage(status); - if (message && status.someSucceeded) { + if (message && status.someSucceeded && allowUndo) { message.userAction = new SnackbarUserAction('APP.ACTIONS.UNDO', new UndoDeleteNodesAction([...status.success])); } diff --git a/projects/aca-content/src/lib/store/effects/node.effects.ts b/projects/aca-content/src/lib/store/effects/node.effects.ts index a2378beae9..3a88f80895 100644 --- a/projects/aca-content/src/lib/store/effects/node.effects.ts +++ b/projects/aca-content/src/lib/store/effects/node.effects.ts @@ -163,14 +163,14 @@ export class NodeEffects { map((action) => { this.store.dispatch(new ShowLoaderAction(true)); if (action?.payload?.length > 0) { - this.contentService.deleteNodes(action.payload); + this.contentService.deleteNodes(action.payload, action.allowUndo); } else { this.store .select(getAppSelection) .pipe(take(1)) .subscribe((selection) => { if (selection && selection.count > 0) { - this.contentService.deleteNodes(selection.nodes); + this.contentService.deleteNodes(selection.nodes, action.allowUndo); } }); } diff --git a/projects/aca-shared/store/src/actions/node.actions.ts b/projects/aca-shared/store/src/actions/node.actions.ts index ca39694761..4e3413291f 100644 --- a/projects/aca-shared/store/src/actions/node.actions.ts +++ b/projects/aca-shared/store/src/actions/node.actions.ts @@ -60,7 +60,7 @@ export class SetSelectedNodesAction implements Action { export class DeleteNodesAction implements Action { readonly type = NodeActionTypes.Delete; - constructor(public payload: NodeEntry[] = []) {} + constructor(public payload: NodeEntry[] = [], public allowUndo = true) {} } export class UndoDeleteNodesAction implements Action {