fix: make submit form order static

This commit is contained in:
Ruben Fiszel
2024-03-30 15:00:52 +01:00
parent d8a9ee4945
commit 951758ffb6
3 changed files with 13 additions and 2 deletions
@@ -167,7 +167,6 @@
(schemaStripped = stripSchema(fields, $stateId))
function stripSchema(inputs: AppInputs, s: any): Schema {
console.log('Strip schema', inputs)
if (inputs === undefined) {
return emptySchema()
}
@@ -179,6 +178,8 @@
console.warn('Error loading schema')
return emptySchema()
}
// schema.order = Object.keys(fields)
// console.log(schema.order)
// Remove hidden static inputs
Object.keys(inputs ?? {}).forEach((key: string) => {
@@ -40,6 +40,9 @@
let { schema } = await getScriptByPath(x.path)
if (!deepEqual(x.schema, schema)) {
x.schema = schema
if (!x.schema.order) {
x.schema.order = Object.keys(x.schema.properties ?? {})
}
fields = computeFields(schema, false, fields)
}
} catch (e) {
@@ -53,6 +56,9 @@
const { schema } = (await loadSchema($workspaceStore ?? '', x.path, 'flow')) ?? emptySchema()
if (!deepEqual(x.schema, schema)) {
x.schema = schema
if (!x.schema.order) {
x.schema.order = Object.keys(x.schema.properties ?? {})
}
fields = computeFields(schema, false, fields)
}
} catch (e) {
@@ -36,7 +36,11 @@
path: string,
runType: 'script' | 'flow' | 'hubscript'
): Promise<{ schema: Schema; summary: string | undefined }> {
return loadSchema(workspace, path, runType) ?? emptySchema()
const schema = await loadSchema(workspace, path, runType)
if (!schema.schema.order) {
schema.schema.order = Object.keys(schema.schema.properties ?? {})
}
return schema ?? { schema: emptySchema(), summary: undefined }
}
async function pickScript(path: string) {