1
0

feat(helpdesk): add delete button on edit page, fix flash notifications

- Edit page: managers see 'Delete handover' button in aside with confirm dialog
- Delete handler: POST action=delete → deleteByIds → redirect to list
- Flash scope set to null (global) so toast shows reliably after redirect
  regardless of locale prefix or query string in URL
- i18n: added Delete handover / Delete this handover? / Handover deleted (de+en)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
aminovfariz
2026-06-01 15:51:36 +02:00
parent 1caa198286
commit 9caa771a73
5 changed files with 50 additions and 3 deletions

View File

@@ -595,5 +595,8 @@
"Create and assign": "Erstellen & zuweisen",
"Handover created and assigned": "Übergabe erstellt und zugewiesen",
"No active employees found.": "Keine aktiven Mitarbeiter gefunden.",
"Please select an employee to assign": "Bitte wählen Sie einen Mitarbeiter aus"
"Please select an employee to assign": "Bitte wählen Sie einen Mitarbeiter aus",
"Delete handover": "Übergabe löschen",
"Delete this handover?": "Diese Übergabe löschen?",
"Handover deleted": "Übergabe gelöscht"
}

View File

@@ -595,5 +595,8 @@
"Create and assign": "Create and assign",
"Handover created and assigned": "Handover created and assigned",
"No active employees found.": "No active employees found.",
"Please select an employee to assign": "Please select an employee to assign"
"Please select an employee to assign": "Please select an employee to assign",
"Delete handover": "Delete handover",
"Delete this handover?": "Delete this handover?",
"Handover deleted": "Handover deleted"
}

View File

@@ -186,7 +186,7 @@ if ($step === $formStep) {
$sessionStore->remove($sessionKey);
$listUrl = lurl('helpdesk/handovers');
Flash::success(t('Handover created and assigned'), $listUrl, 'handover_created');
Flash::success(t('Handover created and assigned'), null, 'handover_created');
Router::redirect($listUrl);
return;
}

View File

@@ -61,6 +61,30 @@ if (!is_array($fieldValues)) {
$errorBag = formErrors();
// Handle delete POST
if ($request->isMethod('POST') && (string) $request->body('action', '') === 'delete') {
if (!Session::checkCsrfToken()) {
Flash::error(t('Form expired, please try again'), $editTarget, 'csrf_expired');
Router::redirect($editTarget);
return;
}
if (!$canManage) {
Flash::error(t('Only managers can delete handovers'), $closeTarget, 'delete_denied');
Router::redirect($closeTarget);
return;
}
$deleteResult = $service->deleteByIds($tenantId, [$handoverId], HandoverService::PERMISSION_MANAGE);
if ($deleteResult['ok']) {
Flash::success(t('Handover deleted'), null, 'handover_deleted');
} else {
Flash::error($deleteResult['error'] ?? t('Failed to delete handovers'), null, 'delete_failed');
}
Router::redirect($closeTarget);
return;
}
// Handle submit-for-review POST
if ($request->isMethod('POST') && (string) $request->body('action', '') === 'submit_for_review') {
if (!Session::checkCsrfToken()) {

View File

@@ -201,6 +201,23 @@ $editBasePath = $editBasePath ?? ('helpdesk/handovers/edit/' . ($handover['id']
</form>
<?php endif; ?>
<?php if ($canManage && !$isViewingRevision): ?>
<hr>
<form method="post">
<input type="hidden" name="action" value="delete">
<?php \MintyPHP\Session::getCsrfInput(); ?>
<button
type="submit"
class="danger outline small"
style="width: 100%;"
data-confirm-message="<?php e(t('Delete this handover?')); ?>"
data-confirm-variant="danger"
>
<i class="bi bi-trash3"></i> <?php e(t('Delete handover')); ?>
</button>
</form>
<?php endif; ?>
<hr>
<?php if ($revisions !== []): ?>