From c0cff3a6db67cb4e09c4e25ae1bff5c4cc7408af Mon Sep 17 00:00:00 2001 From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com> Date: Tue, 18 May 2021 14:04:35 +0200 Subject: [PATCH] fix for https://github.com/GNS3/gns3-web-ui/issues/1140 --- .../project-map/project-map.component.ts | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index e93e2461..9fc4b977 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -383,16 +383,27 @@ export class ProjectMapComponent implements OnInit, OnDestroy { Mousetrap.bind('del', (event: Event) => { event.preventDefault(); - const selected = this.selectionManager.getSelected(); + this.deleteItems(); + }); + } - selected - .filter((item) => item instanceof MapNode) - .forEach((item: MapNode) => { - const node = this.mapNodeToNode.convert(item); - this.nodeService.delete(this.server, node).subscribe((data) => { - this.toasterService.success('Node has been deleted'); + deleteItems() { + this.bottomSheet.open(ConfirmationBottomSheetComponent); + let bottomSheetRef = this.bottomSheet._openedBottomSheetRef; + bottomSheetRef.instance.message = 'Do you want to delete all selected objects?'; + const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => { + if (result) { + const selected = this.selectionManager.getSelected(); + + selected + .filter((item) => item instanceof MapNode) + .forEach((item: MapNode) => { + const node = this.mapNodeToNode.convert(item); + this.nodeService.delete(this.server, node).subscribe((data) => { + this.toasterService.success('Node has been deleted'); + }); }); - }); + } }); }