mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
users: Drop jQuery code as the library dependency has been removed
Closes: #2484 Tests: - Functional tests for users app works. - When updating the user if the delete user is not checked, delete confirmation dialog is not shown. - When updating the user if the delete user is checked, delete confirmation dialog is shown. It can be dismissed and re-shown many times. When confirm button is clicked, the form is submitted and user is deleted. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
79482f7a38
commit
f2ce5b7afd
@ -22,8 +22,6 @@
|
||||
* in this page.
|
||||
*/
|
||||
|
||||
var deleteConfirmed = false;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
const form = document.querySelector('form.form-update');
|
||||
form.addEventListener('submit', onUserUpdateSubmit);
|
||||
@ -33,28 +31,31 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
confirmDeleteButton.addEventListener('click', () => {
|
||||
onUserDeleteConfirmed(form);
|
||||
});
|
||||
|
||||
var deleteConfirmed = false;
|
||||
const modal = new bootstrap.Modal('#user-delete-confirm-dialog');
|
||||
|
||||
// Show the confirmation dialog if the delete checkbox is selected
|
||||
function onUserUpdateSubmit(event) {
|
||||
const deleteUserCheckbox = document.getElementById('id_delete');
|
||||
if (!deleteUserCheckbox.checked) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deleteConfirmed) { // Deletion is already confirmed
|
||||
deleteConfirmed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
modal.show();
|
||||
};
|
||||
|
||||
// Submit the user edit form
|
||||
function onUserDeleteConfirmed(form) {
|
||||
deleteConfirmed = true;
|
||||
modal.hide();
|
||||
// Click instead of submit to disable the submission button
|
||||
form.querySelector('input[type=submit]').click();
|
||||
};
|
||||
});
|
||||
|
||||
// Show the confirmation dialog if the delete checkbox is selected
|
||||
function onUserUpdateSubmit(event) {
|
||||
const deleteUserCheckbox = document.getElementById('id_delete');
|
||||
if (!deleteUserCheckbox.checked) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deleteConfirmed) { // Deletion is already confirmed
|
||||
deleteConfirmed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
$("#user-delete-confirm-dialog").modal('show');
|
||||
};
|
||||
|
||||
// Submit the user edit form
|
||||
function onUserDeleteConfirmed(form) {
|
||||
deleteConfirmed = true;
|
||||
$('#user-delete-confirm-dialog').modal('hide');
|
||||
// Click instead of submit to disable the submission button
|
||||
form.querySelector('input[type=submit]').click();
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user