javascript: Fix disabled submit buttons when navigating back to a page

When navigating back to a page, enable buttons that were previously
**temporarily** disabled.

Closes #1996

Tested that on the manage snapshots page, when browsing to delete view
and then back, the "Create Snapshot" button is enabled.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa 2020-12-17 12:19:25 +02:00 committed by Sunil Mohan Adapa
parent c986bf8ff5
commit 472590f6fc
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -85,7 +85,9 @@ function onSubmitAddProgress(event) {
// Disable all form submit buttons on the page
for (const formbutton of getSubmitButtons()) {
if (!(formbutton.classList.contains('btn-link') ||
formbutton.classList.contains('no-running-status'))) {
formbutton.classList.contains('no-running-status') ||
formbutton.hasAttribute('disabled'))) {
formbutton.classList.add('temporarily-disabled');
formbutton.setAttribute('disabled', 'disabled');
}
}
@ -105,11 +107,12 @@ document.addEventListener('DOMContentLoaded', function(event) {
// back/forward we want them to be able to submit the forms again. So clear all
// the button disabling.
window.addEventListener('pageshow', function(event) {
const selector = "input[type='submit'].running-status-button";
const submitButtons = document.querySelectorAll(selector);
for (const button of submitButtons) {
for (const button of getSubmitButtons()) {
button.classList.remove('running-status-button');
button.removeAttribute('disabled');
if (button.classList.contains('temporarily-disabled')) {
button.classList.remove('temporarily-disabled');
button.removeAttribute('disabled');
}
}
const beforeSelector = ".running-status-button-before";