Simplify delete confirmation to native window.confirm

Bootstrap Modal async was unreliable. Replace with synchronous
window.confirm() which always works and needs no dependencies.

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 04:52:03 -04:00
co-authored by Copilot
parent 72e4c1b1d7
commit b172b89318
+2 -33
View File
@@ -107,41 +107,10 @@
<script src="{{ url_for('static', filename='js/bs-init.js') }}"></script> <script src="{{ url_for('static', filename='js/bs-init.js') }}"></script>
<script src="{{ url_for('static', filename='js/theme.js') }}"></script> <script src="{{ url_for('static', filename='js/theme.js') }}"></script>
{# ── Shared confirmation modal ─────────────────────────────────────────── #} {# ── Shared confirmation helper ────────────────────────────────────────── #}
<div class="modal fade" id="confirm-modal" tabindex="-1" aria-labelledby="confirm-modal-label" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirm-modal-label">Confirm delete</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="confirm-modal-body">Are you sure?</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" id="confirm-modal-ok">Delete</button>
</div>
</div>
</div>
</div>
<script> <script>
// Global helper: show confirmation modal, resolve true/false on user choice.
window.confirmDelete = function(message) { window.confirmDelete = function(message) {
return new Promise(function(resolve) { return Promise.resolve(window.confirm(message));
const modal = document.getElementById('confirm-modal');
document.getElementById('confirm-modal-body').textContent = message;
const bsModal = bootstrap.Modal.getOrCreate(modal);
const okBtn = document.getElementById('confirm-modal-ok');
function onOk() { cleanup(); resolve(true); }
function onHide() { cleanup(); resolve(false); }
function cleanup() {
okBtn.removeEventListener('click', onOk);
modal.removeEventListener('hidden.bs.modal', onHide);
bsModal.hide();
}
okBtn.addEventListener('click', onOk);
modal.addEventListener('hidden.bs.modal', onHide, { once: true });
bsModal.show();
});
}; };
</script> </script>
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}