mirror of
https://github.com/bugsink/bugsink.git
synced 2026-01-06 05:10:15 -06:00
Implement delete functionality with confirmation modals for users. Ensure proper authorization checks are in place before deletion. Add corresponding JavaScript files to handle modal interactions and form submissions. Based on #84 Signed-off-by: Animesh Agrawal <animesh@flick2know.com>
33 lines
1016 B
JavaScript
33 lines
1016 B
JavaScript
"use strict";
|
|
|
|
/**
|
|
* Initializes delete functionality for user list page
|
|
*/
|
|
function initializeDeleteModal() {
|
|
const modal = document.getElementById('deleteModal');
|
|
const deleteButtons = document.querySelectorAll('.delete-button');
|
|
const cancelBtn = document.getElementById('cancelDelete');
|
|
const deleteActionInput = document.getElementById('deleteAction');
|
|
|
|
if (!modal || deleteButtons.length === 0 || !cancelBtn || !deleteActionInput) {
|
|
console.error('One or more required elements not found');
|
|
return;
|
|
}
|
|
|
|
deleteButtons.forEach(button => {
|
|
button.addEventListener('click', () => {
|
|
const userId = button.getAttribute('data-user-id');
|
|
deleteActionInput.value = 'delete:' + userId;
|
|
modal.classList.remove('hidden');
|
|
});
|
|
});
|
|
|
|
cancelBtn.addEventListener('click', () => {
|
|
modal.classList.add('hidden');
|
|
});
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
initializeDeleteModal();
|
|
});
|