From 8f3eea87227e7fd4a180f5b8011ec6623ffc712c Mon Sep 17 00:00:00 2001 From: David Ovrelid <46874830+framitdavid@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:49:03 +0200 Subject: [PATCH] feat(Bpmnjs): Ensure that the user is fully informed about the consequences when deleting a task (#12702) * feat(Bpmnjs): Override default action when deleting a task --- .../SupportedContextPadProvider.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frontend/packages/process-editor/src/bpmnProviders/SupportedContextPadProvider.js b/frontend/packages/process-editor/src/bpmnProviders/SupportedContextPadProvider.js index b0e9ca95a05..b3294e3868f 100644 --- a/frontend/packages/process-editor/src/bpmnProviders/SupportedContextPadProvider.js +++ b/frontend/packages/process-editor/src/bpmnProviders/SupportedContextPadProvider.js @@ -4,9 +4,33 @@ class SupportedContextPadProvider { } getContextPadEntries() { + const overrideDeleteEntry = (entries) => { + const deleteEntry = entries['delete']; + entries['delete'] = { + ...deleteEntry, + action: { + click: function (event, element) { + if (element.type !== 'bpmn:Task') { + deleteEntry.action.click(event, element); + return; + } + + const isConfirmed = confirm( + 'Prosess-steget du vil slette kan være knyttet til en sidegruppe. Den kan inneholde visningsoppsett eller skjema du har satt opp. Hvis du sletter steget, sletter du også hele sidegruppen og alt som hører til.', + ); + + if (isConfirmed) { + deleteEntry.action.click(event, element); + } + }, + }, + }; + }; + return function (entries) { // Should not be able to replace the entry delete entries['replace']; + overrideDeleteEntry(entries); return entries; }; }