Backend + frontend: edit/delete field definitions #36
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The Fields Management milestone shipped create + list only for field definitions (
POST/GET /api/admin/field-definitions). There is no way to edit a definition's labels/group/required flag, or to delete one. The db layer has onlycreate_field_definition,field_definition_by_key,list_field_definitions— no update/delete functions.Ask
update_field_definitionanddelete_field_definitiontocrates/db/src/fields.rs.PATCH /api/admin/field-definitions/{key}(edit labels / group / required — and decide whetherdata_type/key/binding are immutable; they likely should be, since changing a field's type invalidates existing object data) andDELETE /api/admin/field-definitions/{key}, bothEditCatalogue./fieldsscreen — make list rows selectable/editable (likely a real detail/edit pane on the right instead of the always-create form, or an edit dialog), and a delete affordance.The hard part — referential integrity (same class as #30)
A field definition is the schema that catalogue objects' flexible
fieldsare validated and rendered against. Deleting or retyping a definition that objects already use is dangerous:409+ the list/count of objects using the field, or allow and define what happens to the stored values (orphaned JSON keys, or a cascading scrub). A "is this field referenced by any object?" check is needed (objects store flexible values keyed by fieldkey).requiredtoggled on: existing objects may now violate the requirement — decide whether to block, or allow with a warning.Acceptance
key,data_type, binding) documented and rejected if changed./fields.Done in
873efe1(merged tomain). Added auditedPATCH/DELETE /api/admin/field-definitions/{key}.key/data_type/binding are immutable (structurally absent from the update DTO); onlylabels/group/requiredare editable, andrequiredis not retroactively enforced. Delete is blocked with 409 + count when any object stores that field key (jsonb_exists). Frontend: the/fieldsright pane becomes an in-place edit form (immutable inputs disabled) with a delete affordance.