users: Fix unable to delete user

Fixes an issue where confirming user deletion is not submitting the user
edit form.

Also fixes an issue where the user edit submit button is disabled after user
deletion confirmation is cancelled.

Fixes #2513.

Tests performed:
- Deleting a user works.
- All the users module tests pass.
- After cancelling the user deletion confirmation dialog, the user edit
  submit button is clickable.
- On the app pages, submit buttons are disabled when app enabling or disabling
is in progress.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa 2025-04-12 09:15:30 +03:00 committed by Sunil Mohan Adapa
parent 0d9c81da03
commit 92aa66114c
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 16 additions and 7 deletions

View File

@ -33,7 +33,11 @@ document.addEventListener('DOMContentLoaded', (event) => {
});
var deleteConfirmed = false;
const modal = new bootstrap.Modal('#user-delete-confirm-dialog');
const modalEl = document.querySelector('#user-delete-confirm-dialog');
const modal = new bootstrap.Modal(modalEl);
// Make the user edit submit button clickable again when closing modal
modalEl.addEventListener('hide.bs.modal', clearButtonDisabling);
// Show the confirmation dialog if the delete checkbox is selected
function onUserUpdateSubmit(event) {

View File

@ -113,11 +113,10 @@ document.addEventListener('DOMContentLoaded', function(event) {
}
});
// When using back/forward browser's bfcache is used and pages won't receive
// 'load' events. Instead a 'pageshow' event is available. When a user does
// back/forward we want them to be able to submit the forms again. So clear all
// the button disabling.
window.addEventListener('pageshow', function(event) {
/*
* Clear button disabling on the page.
*/
function clearButtonDisabling(event) {
for (const button of getSubmitButtons()) {
button.classList.remove('running-status-button');
if (button.classList.contains('temporarily-disabled')) {
@ -131,7 +130,13 @@ window.addEventListener('pageshow', function(event) {
for (const element of beforeElements) {
element.remove();
}
});
};
// When using back/forward browser's bfcache is used and pages won't receive
// 'load' events. Instead a 'pageshow' event is available. When a user does
// back/forward we want them to be able to submit the forms again. So clear all
// the button disabling.
window.addEventListener('pageshow', clearButtonDisabling);
/*
* Select all option for multiple checkboxes.