mirror of
https://github.com/itflow-org/itflow
synced 2026-11-22 04:17:24 +00:00
Undo: the message after archiving, a move or a bulk change has Undo, which puts it back as it was unless it changed since, and archiving no longer asks first except for clients; covers archiving every kind on Archived with contact roles, document links and a client's recurring invoices, file, document, folder and rack moves, and the bulk changes that set a field on tickets, assets, contacts, clients, projects, invoices, products and IP addresses
This commit is contained in:
@@ -50,6 +50,9 @@ if (!empty($_SESSION['alert_message'])) {
|
||||
// Escaping lives in one place now - see alertMessageHtml() in functions/sanitize.php
|
||||
$alert_safe_message = alertMessageHtml($_SESSION['alert_message']);
|
||||
|
||||
// Undo, when the change can be put back (functions/undo.php) - and the message stays up longer for it
|
||||
$alert_undo_token = function_exists('undoTokenForAlert') && !empty($_SESSION['csrf_token']) ? undoTokenForAlert() : '';
|
||||
|
||||
?>
|
||||
|
||||
<?php /* `show` is on the element from the server, and `fade` is gone: the
|
||||
@@ -62,11 +65,15 @@ if (!empty($_SESSION['alert_message'])) {
|
||||
loaded in the header. */ ?>
|
||||
<div class="toast-container position-fixed top-0 end-0 p-3" style="z-index: 1090;">
|
||||
<div id="itflowFlashToast"
|
||||
class="toast show itflow-toast align-items-center <?= $alert_style ?> border-0"
|
||||
class="toast show itflow-toast<?= $alert_undo_token ? ' itflow-toast-undo' : '' ?> align-items-center <?= $alert_style ?> border-0"
|
||||
role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="d-flex align-items-center">
|
||||
<i class="fas fa-fw <?= $alert_icon ?> fa-lg ms-3"></i>
|
||||
<div class="toast-body"><?= $alert_safe_message ?></div>
|
||||
<?php if ($alert_undo_token) { ?>
|
||||
<a class="btn btn-sm <?= $alert_dark_text ? 'btn-outline-dark' : 'btn-outline-light' ?> fw-semibold text-nowrap flex-shrink-0 me-1" data-undo
|
||||
href="/agent/post.php?undo=<?= escapeHtml($alert_undo_token) ?>&csrf_token=<?= escapeHtml($_SESSION['csrf_token']) ?>"><i class="fas fa-undo me-1"></i>Undo</a>
|
||||
<?php } ?>
|
||||
<?php /* No data-bs-dismiss - the click handler below covers the
|
||||
whole toast, and this button sits inside it. */ ?>
|
||||
<button type="button"
|
||||
@@ -90,7 +97,16 @@ if (!empty($_SESSION['alert_message'])) {
|
||||
|
||||
// Click anywhere on it to dismiss, the way toastr did. The close
|
||||
// button is inside the toast, so this covers it too.
|
||||
el.addEventListener('click', function () {
|
||||
el.addEventListener('click', function (event) {
|
||||
// Undo goes where it links - and only once
|
||||
var undo = event.target.closest('[data-undo]');
|
||||
if (undo) {
|
||||
if (undo.classList.contains('disabled')) {
|
||||
event.preventDefault();
|
||||
}
|
||||
undo.classList.add('disabled');
|
||||
return;
|
||||
}
|
||||
el.remove();
|
||||
});
|
||||
|
||||
@@ -109,6 +125,7 @@ if (!empty($_SESSION['alert_message'])) {
|
||||
|
||||
unset($_SESSION['alert_type']);
|
||||
unset($_SESSION['alert_message']);
|
||||
unset($_SESSION['alert_undo']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user