improve schema reordering

This commit is contained in:
Ruben Fiszel
2024-01-12 00:42:43 +01:00
parent d59b89ec3c
commit b3fa1cd77d
2 changed files with 22 additions and 1 deletions
@@ -94,7 +94,25 @@
resourceTypes = await getResourceTypes()
}
reorder()
loadResourceTypes()
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
}
}
</script>
<div class="w-full {clazz} {flexWrap ? 'flex flex-row flex-wrap gap-x-6 ' : ''}">
@@ -87,10 +87,12 @@
resourceTypes = await getResourceTypes()
}
reorder()
loadResourceTypes()
$: schema && reorder()
function reorder() {
console.log('reodering')
if (schema?.order && Array.isArray(schema.order)) {
const n = {}
@@ -104,6 +106,7 @@
n[x] = schema.properties[x]
})
schema.properties = n
keys = Object.keys(schema.properties ?? {})
}
}
</script>