add a delete confirmation modal

This commit is contained in:
Andrew Bauer 2020-08-18 08:06:58 -05:00
parent 7e679809f2
commit b32bcab91f
2 changed files with 42 additions and 0 deletions

View File

@ -303,5 +303,27 @@ while ( $event_row = dbFetchNext($results) ) {
</table>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div id="deleteConfirm" class="modal fade" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Delete Confirmation</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>Populaed by Javascript</p>
</div>
<div class="modal-footer">
<button id="delCancelBtn" type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo translate('Cancel') ?></button>
<button id ="delConfirmBtn" type="button" class="btn btn-danger"><?php echo translate('Delete') ?></button>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -163,12 +163,32 @@ function initPage() {
return;
}
var modal = $j('#deleteConfirm');
var selections = getIdSelections();
evt.preventDefault();
modal.find('.modal-body p').text('You are about to delete '+selections.length+' events. Are you sure?');
$j('#deleteConfirm').modal('show');
});
// Manage the DELETE CONFIRMATION modal button
document.getElementById("delConfirmBtn").addEventListener("click", function onDelConfirmClick(evt) {
if ( ! canEditEvents ) {
alert("You do not have permission to delete events.");
return;
}
var selections = getIdSelections();
evt.preventDefault();
$j.getJSON(thisUrl + '?view=events&action=delete&eids[]='+selections.join('&eids[]='));
window.location.reload(true);
});
// Manage the CANCEL modal button
document.getElementById("delCancelBtn").addEventListener("click", function onDelCancelClick(evt) {
$j('#deleteConfirm').modal('hide');
});
}
$j(document).ready(function() {