mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
feat: enhance entity field management with configurable order
Added optional `fields_order` to the entity configuration schema, allowing for custom field sorting. Updated `getFields` method to support sorting based on this configuration. Adjusted related methods and UI components to handle field order during updates and serialization. Improved handling of virtual fields in various contexts.
This commit is contained in:
@@ -120,17 +120,20 @@ function entityFieldActions(bkndActions: TSchemaActions, entityName: string) {
|
||||
return await bkndActions.add("data", `entities.${entityName}.fields.${name}`, validated);
|
||||
},
|
||||
patch: () => null,
|
||||
set: async (fields: TAppDataEntityFields) => {
|
||||
set: async (fields: TAppDataEntityFields, order?: string[]) => {
|
||||
try {
|
||||
const validated = parse(entityFields, fields, {
|
||||
skipMark: true,
|
||||
forceParse: true,
|
||||
});
|
||||
const res = await bkndActions.overwrite(
|
||||
"data",
|
||||
`entities.${entityName}.fields`,
|
||||
validated,
|
||||
);
|
||||
await bkndActions.overwrite("data", `entities.${entityName}.fields`, validated);
|
||||
if (order) {
|
||||
await bkndActions.overwrite(
|
||||
"data",
|
||||
`entities.${entityName}.config.fields_order`,
|
||||
order,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("error", e);
|
||||
if (e instanceof InvalidSchemaError) {
|
||||
|
||||
Reference in New Issue
Block a user