mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 00:02:23 +00:00
fix: maintain order in flow inputs when never reordering
This commit is contained in:
@@ -38,6 +38,7 @@ export interface SchemaProperty {
|
||||
required?: string[]
|
||||
showExpr?: string
|
||||
password?: boolean
|
||||
order?: string[]
|
||||
}
|
||||
|
||||
export interface ModalSchemaProperty {
|
||||
|
||||
@@ -105,6 +105,9 @@
|
||||
if (!schema.required) {
|
||||
schema.required = []
|
||||
}
|
||||
if (!schema.order || !Array.isArray(schema.order)) {
|
||||
syncOrders()
|
||||
}
|
||||
schema.properties[modalProperty.name] = modalToSchema(modalProperty)
|
||||
if (modalProperty.required) {
|
||||
if (!schema.required.includes(modalProperty.name)) {
|
||||
@@ -118,8 +121,15 @@
|
||||
}
|
||||
|
||||
if (editing && oldArgName && oldArgName !== modalProperty.name) {
|
||||
let oldPosition = schema.order.indexOf(oldArgName)
|
||||
schema.order[oldPosition] = modalProperty.name
|
||||
reorder()
|
||||
handleDeleteArgument([oldArgName])
|
||||
}
|
||||
|
||||
if (!schema.order?.includes(modalProperty.name)) {
|
||||
schema.order.push(modalProperty.name)
|
||||
}
|
||||
modalProperty = Object.assign({}, DEFAULT_PROPERTY)
|
||||
editing = false
|
||||
oldArgName = undefined
|
||||
@@ -128,7 +138,6 @@
|
||||
}
|
||||
|
||||
schema = schema
|
||||
syncOrders()
|
||||
schemaString = JSON.stringify(schema, null, '\t')
|
||||
jsonEditor?.setCode(schemaString)
|
||||
dispatch('change', schema)
|
||||
@@ -177,7 +186,9 @@
|
||||
delete modifiedProperties[argName]
|
||||
|
||||
modifiedObject.required = schema.required.filter((arg) => arg !== argName)
|
||||
|
||||
if (modifiedObject.order) {
|
||||
modifiedObject.order = modifiedObject.order.filter((arg) => arg !== argName)
|
||||
}
|
||||
schema = schema
|
||||
schemaString = JSON.stringify(schema, null, '\t')
|
||||
dispatch('change', schema)
|
||||
@@ -216,6 +227,7 @@
|
||||
entries.splice(i, 1)
|
||||
entries.splice(up ? i - 1 : i + 1, 0, element)
|
||||
schema.properties = Object.fromEntries(entries)
|
||||
|
||||
syncOrders()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user