Badges: persist template controls_cfg; fix onchange syntax in template form

This commit is contained in:
Scott Idem
2026-04-09 15:10:03 -04:00
parent 76c28a7e22
commit d05420d9c1
2 changed files with 106 additions and 14 deletions

View File

@@ -121,18 +121,27 @@ interface ControlsCfg {
shown?: string[];
auth_editable?: string[];
}
let template_controls_cfg = $derived(
(() => {
try {
const parsed = JSON.parse(
$lq__event_badge_template_obj?.other_json ?? '{}'
);
return (parsed?.controls_cfg ?? null) as ControlsCfg | null;
} catch {
return null;
let template_controls_cfg = $derived.by((): ControlsCfg | null => {
try {
const raw = $lq__event_badge_template_obj?.cfg_json ?? null;
if (raw) {
const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
if (parsed?.controls_cfg) return parsed.controls_cfg as ControlsCfg;
}
})()
);
} catch {
// fall through to other_json fallback
}
try {
const raw2 = $lq__event_badge_template_obj?.other_json ?? null;
if (raw2) {
const parsed2 = typeof raw2 === 'string' ? JSON.parse(raw2) : raw2;
return (parsed2?.controls_cfg ?? null) as ControlsCfg | null;
}
} catch {
return null;
}
return null;
});
// Default auth-editable fields when the template has no explicit config.
// Covers the fields an attendee most commonly needs to fix at the badge table.