refac/fix: valves array type handling

Co-Authored-By: Jacob Leksan <63938553+jmleksan@users.noreply.github.com>
This commit is contained in:
Timothy Jaeryang Baek
2025-09-25 13:13:03 -05:00
co-authored by Jacob Leksan
parent a7061383e8
commit 53cd660de7
2 changed files with 28 additions and 7 deletions
+13 -4
View File
@@ -27,10 +27,19 @@
class="p-1 px-3 text-xs flex rounded-sm transition"
type="button"
on:click={() => {
valves[property] =
(valves[property] ?? null) === null
? (valvesSpec.properties[property]?.default ?? '')
: null;
const propertySpec = valvesSpec.properties[property] ?? {};
if ((valves[property] ?? null) === null) {
// Initialize to custom value
if ((propertySpec?.type ?? null) === 'array') {
const defaultArray = propertySpec?.default ?? [];
valves[property] = Array.isArray(defaultArray) ? defaultArray.join(', ') : '';
} else {
valves[property] = propertySpec?.default ?? '';
}
} else {
valves[property] = null;
}
dispatch('change');
}}