Embedded child region: 3. Region renderer
Frontend, reading surface only, under the parent's view form. The region owns its fetch (/api/list, form=view-form, the fixed fk-eq filter, the region's :sort) and keeps the child payload in region-local state — never setData, formValues, the query setters, or the router. Rows through the existing list-cell pipeline, prev/next pager, accordion expand to the child's view-form fields, inline Add via direct /api/insert (uuid preset, hidden FK, jump to the last page), Reply's quote preset with the one-level strip, and loaded-empty vs failed fetch as explicit state flags. :hide-list (DONE) already suppresses the parent table. No footer link: that link is defined as landing on the scoped tab (4); an interim substitute — a search pre-fill, a display-column filter — is the second filter spelling the ordering exists to prevent. This is the App.tsx slice that can go wrong; isolating it means a broken hop cannot hide a broken expand. Smoke slice: oldest-first render, pager, expand, Add preset and last-page landing, Reply strip, guest sees no Add, zero-comment no-create renders nothing, failed fetch renders the error line; npm run build or it is invisible.
Plan: 03-region-renderer.org
Implemented per the plan. web/src/region.ts: pure helpers — composeReply (quoteLine: strip one leading > + optional space, flatten remaining markers, prefix exactly one > =; attribution only from a nonblank string =user, never lifted from the body; missing user → empty preset), normalizeRoles (string → itself, array → element zero, nonempty strings only), lastOffset (total<=0 → 0), regionPayloadData (add-form keys ∪ via minus roles; blanks omitted, nonblanks untrimmed, explicit null preserved, undefined absent so :autofill :user supplies the username; via assigned unconditionally after filtering so a backend-hidden FK still rides), and insertOutcome (HTTP OK + success + inserted: true + nonempty id → inserted; inserted: false → noop; else invalid). web/src/region.test.mjs + npm run test:region (37 checks): all four quote cases plus multiline nesting, no-space markers, forged attribution, missing/null/[]=/blank users, flat + nested + malformed roles, totals 0/1/20/21/40/41, payload membership/blank/sparse/null/untrimmed/hidden-:via, roles never in data, and the outcome matrix. App.tsx: ItemResponse grows children, ListResponse['type-roles']= widens to Array<string | [string, ...unknown[]]>, ChildSpec + childSpec state retained from openEditForm's envelope (viewing only, after stillCurrent; cleared at open start, in clearLoadedForm / clearRecordTarget, on parent-type Add; not re-cleared by the 3s status poll); Region mounts immediately after the parent </form>, keyed by type|via|sort|parentId (parent/spec change remounts and resets by construction), outside every !hideList block; region-local fetch via requestRegionList / commitRegion / loadRegion (sequence + mounted fences; the sort plist wire trap avoided — spec.sort is the emitted ["created-at","asc"] pair and the URL spells field:dir); offset state is the sole effect-driven display-fetch trigger; pager handlers and the shrink/post-insert handoffs synchronously invalidate old work and set the target offset (at most two list fetches after a POST, one final rows commit, no intermediate-page paint); manual Reload reads the live offset, commits through the clamp path, and retains expansion only when the expanded id survives the refreshed page; collapsed rows and expanded fields both use the region's own view-form + formFieldKeys through renderCellValue / cellText clamp + tooltip / renderReadOnlyField without ctx (no FK navigation out of the region); row-click contract via INTERACTIVE_SELECTOR, tr.row-clickable, tabIndex, role"button", Enter, Expand/Collapse aria-label; =React.Fragment rows keep FieldRow instances inside a <td colSpan>; Add presets spec.via to the parent uuid and skips it in the visible map (RegionPanel renders the shared renderRegionField alphabet — hidden nothing, read-only, markdown/textarea, renderFormField fallback); the panel is a <div> with type"button"= controls and an explicit Submit handler (no nested <form>, no implicit submit); insert failure keeps the panel/body/page with the server's message; noop closes and same-page Reloads; a confirmed insert probes the fresh total and hands off to lastOffset; a failed probe or display fetch is a load failure with Reload (never a retry or a restore); roles ride top-level, normalized — never verbatim from type-roles; guest (create false) sees no Add/Reply; total===0 with no create renders nothing, with create the Add control is the empty state; in-flight renders only the container; failed fetch renders one error line + Reload (console.error). Smoke-tested end to end over the live REPL image on =blog-test (guest/member): be-rec → children spec, fk-eq region fetch ordering and totals, member insert with uuid preset + autofilled user + flat roles visible to guest, whitespace-body 400 message, shrink shape (offset 20, total 4, zero rows), reply-preset round trip. Full suite green (2668 checks, 49 groups).
- Slot
- 4300
- Status
- 60 Done
- Tags
- mvp, backend, frontend, model, blog
- Contributors
- Donnie