Skip to content

Commit

Permalink
Add confirmation dialog when deleting all alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascumsille committed Dec 12, 2024
1 parent 801539d commit 97070f9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions www/docs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,23 @@ document.addEventListener('DOMContentLoaded', function() {
});


// Confirm Alert deletion
function confirm_delete_handler(event) {
event.preventDefault();
if (confirm('Are you sure you want to delete all alerts?')) {
event.target.closest('form').submit();
}
}

function setup_confirm_delete() {
document.querySelectorAll('.js-confirm-delete').forEach(function(button) {
button.addEventListener('click', confirm_delete_handler);
});
}

document.addEventListener('DOMContentLoaded', setup_confirm_delete);


$(function() {

$('#how-often-annually').click(function() {
Expand Down
2 changes: 1 addition & 1 deletion www/includes/easyparliament/templates/html/alert/_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<div class="clearfix">
<form action="<?= $actionurl ?>" method="POST" class="pull-right">
<!-- No need to reference $alert['token'] here, as you're deleting all alerts -->
<input type="submit" class="button button--negative small" name="action" value="<?= gettext('Delete All') ?>">
<input type="submit" class="button button--negative small js-confirm-delete" name="action" value="<?= gettext('Delete all alerts') ?>">
</form>
</div>
2 changes: 1 addition & 1 deletion www/includes/easyparliament/templates/html/alert/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
<?php if ($keyword_alerts || $spoken_alerts || $own_member_alerts) { ?>
<form action="<?= $actionurl ?>" method="POST" class="pull-right">
<input type="hidden" name="t" value="<?= _htmlspecialchars($delete_token) ?>">
<input type="submit" class="button button--negative small" name="action" value="<?= gettext('Delete All') ?>">
<input type="submit" class="button button--negative small js-confirm-delete" name="action" value="<?= gettext('Delete all alerts') ?>">
</form>
<?php } ?>
<form action="<?= $actionurl ?>" method="post">
Expand Down

0 comments on commit 97070f9

Please sign in to comment.