Spaces:
Running
Running
Claude commited on
Commit Β·
95bc2d3
1
Parent(s): d31601b
Disable all form controls while data is loading
Browse filesIntroduce setFormLocked(locked) which disables/re-enables selState,
selBess, inpDate and btnLoad atomically. Called with true before the
fetch and false in the finally block, so all controls are restored
regardless of success or error.
https://claude.ai/code/session_01Vm5dTYdRf99LZ9MfB86vjx
- app/static/js/app.js +9 -2
app/static/js/app.js
CHANGED
|
@@ -92,6 +92,13 @@ function onBessChange() {
|
|
| 92 |
}
|
| 93 |
|
| 94 |
/* ββ Load data ββ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
async function onLoad() {
|
| 96 |
const duid = selBess.value;
|
| 97 |
const date = inpDate.value;
|
|
@@ -101,7 +108,7 @@ async function onLoad() {
|
|
| 101 |
hideError();
|
| 102 |
hideResults();
|
| 103 |
showLoading(true);
|
| 104 |
-
|
| 105 |
|
| 106 |
try {
|
| 107 |
const resp = await fetch(`${API}/api/data?duid=${encodeURIComponent(duid)}&date=${date}`);
|
|
@@ -118,7 +125,7 @@ async function onLoad() {
|
|
| 118 |
showError(e.message);
|
| 119 |
} finally {
|
| 120 |
showLoading(false);
|
| 121 |
-
|
| 122 |
}
|
| 123 |
}
|
| 124 |
|
|
|
|
| 92 |
}
|
| 93 |
|
| 94 |
/* ββ Load data ββ */
|
| 95 |
+
function setFormLocked(locked) {
|
| 96 |
+
selState.disabled = locked;
|
| 97 |
+
selBess.disabled = locked || !selState.value;
|
| 98 |
+
inpDate.disabled = locked || !selBess.value;
|
| 99 |
+
btnLoad.disabled = locked;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
async function onLoad() {
|
| 103 |
const duid = selBess.value;
|
| 104 |
const date = inpDate.value;
|
|
|
|
| 108 |
hideError();
|
| 109 |
hideResults();
|
| 110 |
showLoading(true);
|
| 111 |
+
setFormLocked(true);
|
| 112 |
|
| 113 |
try {
|
| 114 |
const resp = await fetch(`${API}/api/data?duid=${encodeURIComponent(duid)}&date=${date}`);
|
|
|
|
| 125 |
showError(e.message);
|
| 126 |
} finally {
|
| 127 |
showLoading(false);
|
| 128 |
+
setFormLocked(false);
|
| 129 |
}
|
| 130 |
}
|
| 131 |
|