aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/sbbuilder/Store.qml
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules/sbbuilder/Store.qml')
-rw-r--r--desktop/modules/sbbuilder/Store.qml26
1 files changed, 22 insertions, 4 deletions
diff --git a/desktop/modules/sbbuilder/Store.qml b/desktop/modules/sbbuilder/Store.qml
index c2afa5d..7036f36 100644
--- a/desktop/modules/sbbuilder/Store.qml
+++ b/desktop/modules/sbbuilder/Store.qml
@@ -32,20 +32,35 @@ QtObject {
// Assigned only when the set changes, as Qtm does: a Repeater bound to a
// fresh array per keystroke rebuilds the row being typed in.
property var manifests: []
+ // The helper takes a [manifests] table whole, in place of its default
+ // one, so with none in the file the default rows are the ones in effect
+ // and are listed; the first edit writes them all before its own.
+ readonly property bool manifestsDefault: !T.sections(st.draft).includes("manifests")
onDraftChanged: {
- const k = T.entries(st.draft, "manifests").map(e => e.key);
+ const k = st.manifestsDefault ? Object.keys(st.fallback("manifests") ?? {})
+ : T.entries(st.draft, "manifests").map(e => e.key);
if (JSON.stringify(k) !== JSON.stringify(st.manifests)) st.manifests = k;
}
+ function seedManifests(section) {
+ if (section !== "manifests" || !st.manifestsDefault) return;
+ const d = st.fallback("manifests") ?? {};
+ for (const k in d) st.draft = T.set(st.draft, "manifests", k, d[k]);
+ }
- function fallback(section, key) { return (st.defaults[section] || {})[key]; }
+ function fallback(section, key) { return key === undefined ? st.defaults[section] : (st.defaults[section] || {})[key]; }
function show(v) { return v === undefined ? undefined : Array.isArray(v) ? v.join(" ") : String(v); }
function placeholder(section, key) { return st.show(st.fallback(section, key)) ?? ""; }
- function get(section, key) { return st.show(T.get(st.draft, section, key)); }
+ function get(section, key) {
+ const v = T.get(st.draft, section, key);
+ // A listed default manifest shows its URL, so editing starts from it.
+ return st.show(v === undefined && section === "manifests" && st.manifestsDefault ? st.fallback(section, key) : v);
+ }
// The effective value, typed: the file's, else the default.
function value(section, key) { return T.get(st.draft, section, key) ?? st.fallback(section, key); }
function entries(section) { return T.entries(st.draft, section); }
function put(section, key, v) {
+ st.seedManifests(section);
try { st.draft = T.set(st.draft, section, key, v); } catch (e) {
st.error = e.message;
st.markInvalid(section + "/" + key, true); // hold Save back
@@ -63,7 +78,10 @@ QtObject {
: typeof d === "number" ? Number(t)
: typeof d === "boolean" ? t === "true" : t);
}
- function remove(section, key) { st.draft = T.remove(st.draft, section, key); }
+ function remove(section, key) {
+ st.seedManifests(section);
+ st.draft = T.remove(st.draft, section, key);
+ }
function markInvalid(id, bad) {
if (!!st.invalid[id] === bad) return;