diff --git a/web/src/objects/object-form.test.tsx b/web/src/objects/object-form.test.tsx index d12a4c1..b2fad57 100644 --- a/web/src/objects/object-form.test.tsx +++ b/web/src/objects/object-form.test.tsx @@ -82,6 +82,18 @@ test("edit mode: no visibility control, save button, prefilled values", async () expect(screen.getByRole("button", { name: /save/i })).toBeInTheDocument(); }); +test("groups flexible fields by definition group with subheadings", async () => { + renderApp( {}} />); + + expect(await screen.findByText("Description")).toBeInTheDocument(); + expect(screen.getByText(/^Other$/)).toBeInTheDocument(); + + const inscription = screen.getByLabelText(/inscription/i); + const material = screen.getByLabelText(/material/i); + + expect(inscription.compareDocumentPosition(material) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); +}); + test("pruneFields: localized_text keeps only the default-language key, other object fields unaffected", () => { const localizedTextKeys = new Set(["title_ml"]); diff --git a/web/src/objects/object-form.tsx b/web/src/objects/object-form.tsx index 0e72c0b..418c11e 100644 --- a/web/src/objects/object-form.tsx +++ b/web/src/objects/object-form.tsx @@ -6,6 +6,7 @@ import { useFieldDefinitions } from "../api/queries"; import { useConfig } from "../config/config-context"; import { FieldInput } from "./field-input"; import { pruneFields } from "./prune-fields"; +import { groupDefinitions } from "../lib/group-fields"; import { UnsavedChangesDialog } from "../lib/unsaved-changes-dialog"; import { useUnsavedChanges } from "../lib/use-unsaved-changes"; import { Button } from "@/components/ui/button"; @@ -197,19 +198,23 @@ export function ObjectForm({ {definitions && definitions.length > 0 && (
- - {t("form.flexibleHeading")} - + {t("form.flexibleHeading")} - {definitions.map((def) => ( -
- + {groupDefinitions(definitions, t("fields.other")).map((g) => ( +
+
{g.group}
- {errors.fields?.[def.key] && ( -

- {errors.fields[def.key]?.message ?? t("form.required")} -

- )} + {g.defs.map((def) => ( +
+ + + {errors.fields?.[def.key] && ( +

+ {errors.fields[def.key]?.message ?? t("form.required")} +

+ )} +
+ ))}
))}