View form
A fourth form, :view-form, sibling of :list-form / :add-form / :update-form, same shape. View mode today renders :update-form read-only, so a reading surface cannot differ from the edit form — the blog gap: a post page cannot drop the Deploy button or re-order fields for reading. Core decision (settled 2026-10-21): treated exactly like the other forms in every respect, no fallback — absent means no view surface, just as absent :add-form means no Add surface. Payload presence ⇔ declaration (*forms* gains the fourth member; existing models' payloads stay byte-identical); the form parameter accepts view-form with no server-side fallback; frontend View button renders iff the payload carries view-form (the viewFormName update-form → list-form fallback chain dies). Buttons: explicit :button in a view form is legal, v1 unused; emission rule is buttons render on the update form only. Status companions land under :fields t (accepted feature); the injected :roles stays add/update-only. Rollups: :view-form joins the valid-rollup-matrix forbidden-key list. Settings auto-open read-only branch: update-capable → edit, else view-form present → view, else don't open. Base model: :users, :roles, :permissions, :settings, :secrets gain :view-form (:fields t); :resources loses all three of its forms (internal, display nil — dead payload; verify no be-list call targets it first). Corpus copy rule: every model in models/ and models/test/ — any type with :update-form gains :view-form with the same :fields. Layout: zero new keys — the label gutter renders iff at least one field renders a label; all-hidden collapses it flush-left (correct rendering, not an inference rule; mixed label-above stacking is post-MVP :layout :stack).
Notes: view-form-notes.org
Plan: view-form-plan.org
Implemented per the plan end to end:
- Compiler (
lisp/model.lisp)::view-formappended to*forms*(fourth position, existing three stable), thevalid-form-fieldsliteral, thevalid-rollup-matrixforbidden loop (present-nil signals too), and thepreliminary-model-checkwalker arm. Base model::users/:roles/:permissions/:settings/:secretsgain:view-form (:fields t)beside their:update-form;:resourcesloses all three forms (the plan's precondition re-verified — still nobe-list=/=be-reccaller passes a form against:resources; the only lisp/ references areuuid-exists-praw SQL,valid-compiled-modelkey presence,insert-sql,be-update's internal guard, andbase-resource-type-key-p). - Backend (
lisp/backend.lisp):fe-fields's button exclusion grows to(:list-form :add-form :view-form)(one list);show-roles-pexcludes(:list-form :view-form)with the docstring rewritten (the rollup-fallback sentence died with the fallback). Step-9 leftover-literal sweep clean: the only code survivors are the*forms*definition and the (now four-member) validator/walker literals. No augment-update-form twin (status auto-append stays update-only by design). - REST (
lisp/rest.lisp): no code change (parse-formwalks*forms*); the threeform-docstrings (rest-list,rest-item,rest-column) nameview-form. The/api/value"udpate-form"typo left as-is per the plan (out of scope). - Frontend (
web/src/App.tsx,index.css):viewFormNameis now the literalview-formwithhasViewFormgating the 👁 link and the settings three-way auto-open (update-capable → edit; view-form in payload → view; else don't open); the actions column collapses entirely when neither 👁 nor ✏️ can render (hasViewForm || data.result.updateon the shared th/td);ListResponsegainsview-form?. Label gutter: the open form's container getsform-no-labelswhen no field that renders in the current mode draws a label (view mode skips password/file/button/hidden —:settingsis the live case); one CSS rule.form-no-labels .field-label { display: none; }collapses the 180px flex track. Build clean (354.01 kB). - Corpus copy: every non-rollup type under
models/andmodels/test/declaring:update-formgained:view-formwith the identical:fields(mechanical, scripted; rollup types skipped — verified none carry the key; chores' explicit list copied verbatim). Two script-stumble fixes worth noting:todos.lisp's:page-descriptionembedded example carries the old three-form shape and was left alone (it is prose, not loadable —widget-all-models-compilestill passes), androllup-compile-test.lisp/compose-test.lisp/compose-sugar-test.lispuse nonstandard indents the first pass missed or mis-placed (a bare:books (:table t :view-form …)phantom type appeared; fixed by hand, then deduped a doubled insert inrollup-compile-test.lisp). - Fixture
models/test/view-form-test.lisp(:posts declares:view-form (:fields (:title :body))+ a:test-syncbutton — reuses thetests/action-tests.lispregistry, load that file beforeset-model;:notesdeclares none); suitetests/view-form-tests.lisp(22 checks:*forms*shape, compile accept/reject incl. rollup present-nil,parse-form,fe-fieldsfield keys exactly(:title :body)with no:id/ button / status / roles, byte-identical JSON for:notes,show-roles-psplit,form-field-keyscons-id,be-rec/be-listrecords keyed(:id :title :body), self-cleaning insert). Registered indata-ui.asd;run-view-form-testsadded torun-tests. - Docs:
model-reference.md(forms section +:view-formspecifics, type-key table row, eligibility rules, roles paragraph, rollup forbidden list, base-model table, Quick key index),rest.md(formvalues on /list, /item, /column parameter lines),hook-registry.md(button placement sentence).models/README.mdchecked — no change needed. - Full suite via
scripts/data-ui tests: 2187 checks, 42 groups, all passed. - Known behavior kept (plan-noted, not fixed here):
handleAction's poll-completion re-open callsopenEditForm({ id })with noviewingargument, so in view mode a completed poll flips the open form to update mode; the 3s poll effect's deps omitopenFormName(both pre-existing; the Row-click item owns action-entry UX).
- Slot
- 3100
- Status
- 60 Done
- Tags
- mvp, backend, frontend, model
- Contributors
- Donnie, Rose, Grok
- Plans
- View form — plan, View form, View form — plan (Grok)