From 92aa66114ce153a10fa39fb08d61f05e394e23ca Mon Sep 17 00:00:00 2001 From: Veiko Aasa Date: Sat, 12 Apr 2025 09:15:30 +0300 Subject: [PATCH] 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 Reviewed-by: Sunil Mohan Adapa --- plinth/modules/users/static/users.js | 6 +++++- static/themes/default/js/main.js | 17 +++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/plinth/modules/users/static/users.js b/plinth/modules/users/static/users.js index 8f4e4c0c3..c0b0dd836 100644 --- a/plinth/modules/users/static/users.js +++ b/plinth/modules/users/static/users.js @@ -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) { diff --git a/static/themes/default/js/main.js b/static/themes/default/js/main.js index eaeb86b03..07c533a69 100644 --- a/static/themes/default/js/main.js +++ b/static/themes/default/js/main.js @@ -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.