feat(editor): forms described by the server, field checks on focus lost #166
No reviewers
Labels
No labels
bug
enhancement
needs-triage
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/deckle!166
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/164"
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?
Closes #164
What
The browser no longer knows field types. Every editor form is described by the server and checked by the server.
POST /api/formdescribes the element form (with item rows), the inline-element dialog (the browser sends the chip's current params), page properties (Page module and a module's Properties tab) and the create dialog. Each field carries name, label, widget, widget settings, required, itemDisplay, summary role and its current value, read through the field-type definitions from #163. Unreadable stored values describe as the default, else empty. AdateTimefield in the create dialog starts at now.internal/element/ftype_*.gonames its widget and settings. The browser has a widget registry (web/src/widgets/) andcomponents/fields.tsxis gone. A Go drift test and a vitest test pin both sides toweb/src/widgets/names.json, so the server can't name a widget the browser lacks.POST /api/form/checkruns on focus lost, using the same code a save runs. Every save (element incl. items and body, properties, page create) returns422 {error, errors:[{field,msg}]}with all failing fields; item rows areitems[<i>].<name>.POST /api/form/inlinechecks the whole form and returns either the errors or the chip's complete new params, written by the server (categories comma-joined, datetime RFC3339, link +Target).{href, newTab}; still stored as<name>+<name>Target.2026-07-10,2026-07-10 09:00:00,2026-07-10T09:00:00and10 Jul 2026in a block element, an item row and an inline element show in the form and save untouched as RFC3339./api/modulesserves{name,label,widget,sortable}per field and labelled filter options{value,label}. The browser no longer has a sort-type list or filter-kind switches.GET /api/page/settingsis removed (replaced byPOST /api/formkindproperties). README documents the new API.scaffold/site/AGENTS.mdnow says adatetimeshortcode param may be written in any spelling Hugo reads and the editor writes RFC3339.Verification
make testpasses: vitest 69 files / 1905 tests, andgo test ./...passes for every package.tsc --noEmitis clean andgo vet ./...passes.harness serveon a freshharness initsite, set to the Europe/Vienna timezone, with customdatetimeelement, items and inline sidecars. Covered:Notes
/api/modules(polled) rather than the client's category store, so a just-created category shows in the filter after the next poll.fields, only required orcreate: truefields may be seeded, and requiredness is enforced. The page tree's quick create (nofields) is unchanged.optionsshows blank and must be re-picked; item rows are written back on one line.🤖 Generated with Claude Code
The browser stops knowing field types. Every editor form — the element form with its item rows, the inline-element dialog, page properties and the create dialog — is described by the server: per field its label, widget, widget settings, required flag, item display and current value, read on the server through the field-type definitions. The browser holds widgets (text, multiline, number, checkbox, choice, multichoice, dateTime, imagePicker, linkPicker, pagePicker, categoryPicker) and hands back what the user entered; it has no field-type list, no checks and no value conversions. - element: each field type names its widget and settings; Schema.Describe, DescribeNew (a datetime starts at now in the create dialog), CheckForm and CheckField. A link field has one value {href, newTab}, still stored as <name> + <name>Target. FieldError marshals as {field, msg}. - server: POST /api/form (describe), POST /api/form/check (field check on focus lost, the same code a save runs), POST /api/form/inline (inline dialog submit; the server writes the params). Every save and check reports all failing fields in one 422 format {error, errors:[{field,msg}]}, item rows as items[<i>].<name>. GET /api/page/settings is removed. /api/modules serves each field's widget and sortable flag and labels every filter option. - Element params are read when the form loads, so a hand-written date in any spelling Hugo reads shows in the form and saves as RFC3339 (#158). - web: widget registry pinned to web/src/widgets/names.json by a Go and a vitest drift test; components/fields.tsx is gone. - AGENTS.md: a datetime shortcode param may be written in any spelling Hugo reads; the editor writes RFC3339. Closes #164 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>[autoland] verdict: pass
Validated: PASS, with one non-blocking concern. Head
39b0256.Signal relied on: Forgejo Actions
ci / build-and-testpassed on the head (run 154, 9m41s). Not re-run. The head already containsmain, so there is no conflict.Checked
Closes #164.CheckFormthe saves use.{href, newTab}round trip.scaffold/site/AGENTS.mdupdated, as CLAUDE.md requires.39b0256resolves the four review findings from the first pass, each with tests:FormValues.rebase) and the form reads dirty.Titlecan be created.pageops.Createtrims the title.Concern (non-blocking)
web/src/widgets/controls.tsx:96-100:NumberControlconverts the typed text to aNumberand writesString(n)back into the input.-0.5loses the minus, because-0displays as0.5.1to5.drops the dot.props.onChange(text).[autoland] verdict: pass
Re-validated: PASS. Head
30e70b8.Signal relied on: Forgejo Actions
ci / build-and-testpassed on the head (run 155). Not re-run. The head already containsmain, so there is no conflict.The non-blocking concern from the previous approval is resolved by
30e70b8:NumberControlnow hands back the input's text unconverted, as the pre-PR widget did. The server reads a number written as text.5.,-or1eis no longer rewritten, and a value from a save or a new description is still written.widgets.test.tsx.Everything from the previous approval stands (#164 scope, AGENTS.md, and the four review fixes in
39b0256). Nothing open.