Restore the previous status when an application status change is refused
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
0e268f3f3c
commit
d100ab21ef
1 file changed
+3
-2
@@ -59,7 +59,7 @@
|
|||||||
const company = companies.get(application.company_key);
|
const company = companies.get(application.company_key);
|
||||||
cell(tr, "Company", company ? company.name : application.company_key);
|
cell(tr, "Company", company ? company.name : application.company_key);
|
||||||
const select = statusSelect(application.status);
|
const select = statusSelect(application.status);
|
||||||
select.addEventListener("change", () => setStatus(application.id, select));
|
select.addEventListener("change", () => setStatus(application.id, select, application.status));
|
||||||
cell(tr, "Status", select);
|
cell(tr, "Status", select);
|
||||||
const saved = cell(tr, "Saved", savedOn(application.created_at));
|
const saved = cell(tr, "Saved", savedOn(application.created_at));
|
||||||
saved.title = application.created_at;
|
saved.title = application.created_at;
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
count(applications.length, "tracked application");
|
count(applications.length, "tracked application");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setStatus(id, select) {
|
async function setStatus(id, select, was) {
|
||||||
select.disabled = true;
|
select.disabled = true;
|
||||||
try {
|
try {
|
||||||
await api(`/api/applications/${encodeURIComponent(id)}/status`, {
|
await api(`/api/applications/${encodeURIComponent(id)}/status`, {
|
||||||
@@ -77,6 +77,7 @@
|
|||||||
});
|
});
|
||||||
render(await api("/api/applications"));
|
render(await api("/api/applications"));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
select.value = was; // the change was refused, so the row still holds `was`
|
||||||
select.disabled = false;
|
select.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user