Skip to content

Commit

Permalink
Added confirmation when deleting alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascumsille committed Dec 12, 2024
1 parent 801539d commit f7cfffa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions www/docs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,20 @@ document.addEventListener('DOMContentLoaded', function() {
createAccordion('.accordion-button', '.accordion-content');
});

// Comfirm deletion of alerts
function confirmDelete() {
var triggers = document.querySelectorAll('.js-confirm-delete');

triggers.forEach(function(trigger) {
trigger.addEventListener('click', function(event) {
var message = "Are you sure you want to delete all alerts?";
if (!confirm(message)) {
event.preventDefault();
}
});
});
}
confirmDelete();

$(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') ?>">
</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') ?>">
</form>
<?php } ?>
<form action="<?= $actionurl ?>" method="post">
Expand Down

0 comments on commit f7cfffa

Please sign in to comment.