Fix API panel re-injecting field defaults over cleared values

startPluginEdit pre-filled any empty field with its descriptor default,
treating an explicitly cleared field (stored "") the same as one never set
(undefined). So a saved-blank OpenSky bounding box reappeared as the
default 50.5,3.2,53.7,7.3 on reopen (and would be re-persisted on save).
Only inject a default when the field has never been stored (undefined), so
intentional blanks stay blank.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
tajniak81
2026-07-13 23:09:46 +02:00
co-authored by Claude Opus 4.8
parent 125d0ccc7d
commit 6a007fd25e
3 changed files with 6 additions and 4 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#0F1E3D" />
<title>PilotVault · API Server</title>
<script type="module" crossorigin src="/assets/index-BkFF389B.js"></script>
<script type="module" crossorigin src="/assets/index-BPK80y5V.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CVh8EDzq.css">
</head>
<body>
+4 -2
View File
@@ -271,9 +271,11 @@ async function togglePlugin(p) {
function startPluginEdit(p) {
editingPlugin.value = editingPlugin.value === p.name ? "" : p.name;
const cfg = { ...(p.config || {}) };
// Preselect each field's effective default when nothing is stored yet.
// Preselect each field's effective default only when it has never been stored.
// An explicitly cleared field (stored as "") is left blank, so it stays blank on
// save instead of the default being re-materialised on every reopen.
for (const f of p.configFields || []) {
if ((cfg[f.key] === undefined || cfg[f.key] === "") && f.default) cfg[f.key] = f.default;
if (cfg[f.key] === undefined && f.default) cfg[f.key] = f.default;
}
editConfig.value = cfg;
}