mirror of
https://github.com/kbenestad/invoice.git
synced 2026-06-18 16:14:33 +00:00
Fix project code not persisting across page reloads
ct-pick was missing data-ls so the selected charge-to client was never saved. On reload, the pcode select was rebuilt with global project codes, so client-specific codes (e.g. AC-100) couldn't be restored. Fix: persist ct-pick, then in restoreStorage call fillChargeTo() to rebuild the correct project code options before re-applying the saved pcode value. Also re-save after to fix any intermediate state written by fillChargeTo's currency auto-set. https://claude.ai/code/session_0151QtsUhzXmgzEhSvXG2SDt
This commit is contained in:
parent
2795a593ef
commit
77cf865ddc
1 changed files with 12 additions and 1 deletions
|
|
@ -555,7 +555,7 @@ function buildForm() {
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-title" style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
|
<div class="card-title" style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
|
||||||
<span id="sec-ct">${t("charge-to")}:</span>
|
<span id="sec-ct">${t("charge-to")}:</span>
|
||||||
<select id="ct-pick" style="width:auto;font-size:12px">
|
<select id="ct-pick" data-ls="ct-pick" style="width:auto;font-size:12px">
|
||||||
<option value="">${t("select")}</option>
|
<option value="">${t("select")}</option>
|
||||||
${ctOpts}
|
${ctOpts}
|
||||||
<option value="__other__">${t("other")}</option>
|
<option value="__other__">${t("other")}</option>
|
||||||
|
|
@ -1049,6 +1049,17 @@ function restoreStorage() {
|
||||||
if (el) el.value = v;
|
if (el) el.value = v;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Restore charge-to: rebuild its project code options then re-apply pcode.
|
||||||
|
// fillChargeTo() calls updateProjectCodes() which resets the pcode select,
|
||||||
|
// and may call saveStorage() mid-flow, so we re-apply and re-save after.
|
||||||
|
const ctPickEl = document.getElementById("ct-pick");
|
||||||
|
if (ctPickEl?.value) {
|
||||||
|
fillChargeTo(ctPickEl.value);
|
||||||
|
const pcodeEl = document.getElementById("pcode");
|
||||||
|
if (pcodeEl && d.pcode) pcodeEl.value = d.pcode;
|
||||||
|
saveStorage();
|
||||||
|
}
|
||||||
|
|
||||||
// Restore "Other" project-code visibility
|
// Restore "Other" project-code visibility
|
||||||
if (d.pcode === "__other__") {
|
if (d.pcode === "__other__") {
|
||||||
const w = document.getElementById("pcode-other-wrap");
|
const w = document.getElementById("pcode-other-wrap");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue