diff --git a/frontend/src/lib/common.ts b/frontend/src/lib/common.ts index 51c8602b21..3d829003b2 100644 --- a/frontend/src/lib/common.ts +++ b/frontend/src/lib/common.ts @@ -36,6 +36,7 @@ export type Schema = { $schema: string | undefined type: string properties: { [name: string]: SchemaProperty } + order?: string[] required: string[] } diff --git a/frontend/src/lib/components/LightweightSchemaForm.svelte b/frontend/src/lib/components/LightweightSchemaForm.svelte index 1e7aef452a..853386aec3 100644 --- a/frontend/src/lib/components/LightweightSchemaForm.svelte +++ b/frontend/src/lib/components/LightweightSchemaForm.svelte @@ -19,6 +19,25 @@ $: if (args === undefined) { args = {} } + + reorder() + + function reorder() { + if (schema.order && Array.isArray(schema.order)) { + const n = {} + + ;(schema.order as string[]).forEach((x) => { + n[x] = schema.properties[x] + }) + + Object.keys(schema.properties ?? {}) + .filter((x) => !schema.order?.includes(x)) + .forEach((x) => { + n[x] = schema.properties[x] + }) + schema.properties = n + } + }