Skip to content

Add generated forms for entity types with source, owner and validity - #2619

Merged
pournasserian merged 2 commits into
v2from
2614-entity-forms
Oct 19, 2026
Merged

pournasserian merged 2 commits into
v2from
2614-entity-forms

Conversation

@pournasserian

Copy link
Copy Markdown
Member

Closes #2614

What

The second slice of F-FRM (#2426): generated forms for entity types, where every field is a fact with its source, owner and validity (FRM-01, SCH-03). Saving works as for content types (#2613): the version and its operation go into a new open change set, here as an entity operation.

  • FactFields (Components/Forms): a fieldset under each field's value widget. It has the source kind (URL, file, person or system) and the source, the owner from the users list, and valid from, valid until and last verified as UTC date and times. A stored fact without a source is marked unsourced (ENT-02) next to its field.
  • FactValues (Admin/Forms) turns the posted parts (Form.Facts[price.kind] and so on) into the fact object SCH-03 defines, always with all six properties. It also shows a stored fact back.
    • A kind without a source or a source without a kind, an unknown kind or owner, and a time that is not a date and time are each reported next to the field.
    • A field whose value is left empty is left out, as for content types.
  • The editor renders the fact fields for entity types, and the entries list links entities to their form. The "comes later" notes from Add generated forms for content types, saved as a person's change set #2613 are gone.
  • Browser tests: the default timeout is 30 seconds, since the axe check now walks ten pages twice per theme, and a loaded machine once timed out at 15. An entity form is one of those pages.

Why

  • One editor for both kinds of type. An entity field is a fact around a value. The value takes the same widget it would take on a content type, and the fact fields sit next to it. That keeps one save path and one set of field widgets.
  • Owners from the users list. SCH-03's owner is a user, so a select is both simpler and harder to get wrong than a typed id.
  • Not in this PR: search-backed pickers, confirming a value without changing it (ENT-05, M2), and rule hints (FRM-03, needs F-RUL F-RUL: Rule book as versioned content #2419).

Tests

  • Unit (FactValuesTests):
    • Posted parts become the full fact object, trimmed, with UTC times.
    • A fact without details is unsourced and keeps every property as null.
    • Each half-given source, unknown kind, bad owner or bad time is a problem of its own part.
    • A stored fact shows its value and parts, with the times in UTC.
  • Integration, host (EntityFormScreenTests):
    • A person creates a product entity. The operation is an entity create, and the price fact stores its value, source, owner, valid until and last verified exactly, with valid from null.
    • The name, saved without a source, is flagged unsourced by IEntityFacts and marked once in the edit form, which shows the stored source and times.
    • A half-given source and a bad time are reported next to their fields, the typed text stays, and nothing is stored.
  • Browser: the axe check covers an entity type's form.

dotnet build -warnaserror and the full suite with the browser tests pass locally against a postgres:17 container as well as SQLite. A loaded full run had nine PostgreSQL failures in untouched classes, and all 103 tests of those classes passed on a rerun. No new package and no new project reference.

Checklist

  • Linked to an issue a maintainer has confirmed
  • Targets v2
  • Tests or docs updated where behaviour changed
  • No tool-generated co-author trailers or footers

@pournasserian pournasserian added this to the M1 Governance core milestone Oct 19, 2026
@pournasserian pournasserian added type:feature New capability v2 FluentCMS v2 (v2 branch) area:forms Generated forms (FRM) labels Oct 19, 2026
@pournasserian
pournasserian merged commit 81274f3 into v2 Oct 19, 2026
2 checks passed
@pournasserian
pournasserian deleted the 2614-entity-forms branch October 19, 2026 09:12
pournasserian added a commit that referenced this pull request Oct 19, 2026
…ch (#2638)

Closes #2630
Closes #2633

## What

Follow-ups from the independent reviews of #2613 and #2619 (F-FRM,
#2426). The generated form now keeps the version it was made from and
the values the person didn't touch.

- **Base version.** The hidden `BaseVersion` comes from the form being
shown. A form refused for its own problems keeps the version it started
from, so its next save is refused as a conflict instead of overwriting a
change saved meanwhile.
- **Untouched values.**
  - `FieldValues.Read` and `FactValues.Read` take the stored value.
- A posted text that shows the same as the stored value keeps the stored
JSON. Seconds, offsets, `4.50` and LF line breaks survive a save.
- Textarea line breaks are compared as LF. Only CR and CRLF are
converted; other line separators stay as typed.
- A stored value the field's current type no longer takes, as after a
number field became text, is read from what was posted.
- A `text` value with line breaks is shown in a textarea, since a
single-line input drops them.
- A textarea value that starts with a line break gets one more, since
HTML drops the first.
- **Which draft the form shows.**
- When the latest version isn't the published one and no set is
reviewing it, a note names the version shown. It offers
`?from=published`. The update is still made from the latest version, so
the version check holds.
  - A reverted create, which leaves nothing published, says so too.
- **Entity facts.**
- The owner list holds every user, and disabled users are labelled
"(disabled)", so a stored owner stays selected.
  - Owner ids are compared as GUIDs, and the stored text is kept.
- A posted owner that is neither a user nor the fact's stored owner is
refused.
- **Untouched facts are kept exactly.** A fact whose value and parts all
show as stored is saved as stored, with its property order, spaces and
any other properties.
- **A stored plain value** of a type made an entity type later shows as
the value of a fact with no details yet, flagged unsourced. It no longer
fails the save or is dropped. A fact is an object with a `value`, so a
plain JSON object is a plain value too.
- **An owner who is no user**, such as one an agent set, shows as
"Unknown user" on its own field and stays selected.
- **The published version the values came from** is posted under
`?from=published`, and whenever the latest version is the published one.
- `EntryEdit.PublishedBase` carries it to `EntryEdits`. That checks it
before the unit of work, and again against the version the operation is
based on.
- If publishing or a revert has moved on, the save is refused as a
conflict, so it can't undo what was published.
- **Booleans.** An unchecked box saves `false` only when a value was
stored, the field is required, or its fact details were given. Otherwise
the field is left out, as an empty field is. A name-only edit no longer
adds an unsourced `{"value": false}` fact.
- **Fact details for an empty value** are reported next to the field
instead of being dropped.
- **`EntryEdits`** checks the rationale and sources before it writes.
- **`PickerField`** names `aria-controls` only while its list exists.
The new axe check found it pointing at a missing id (#2622).

## Why

- **Keep the stored JSON when the text matches.** No widget can show
every stored value exactly, such as a date-time's seconds or a number's
trailing zero. Comparing what the widget would show tells an untouched
field from an edited one without client script.
- **The base version stays the latest version under `?from=published`.**
Another base would weaken the version check. The person sees which
values they start from, and the set's diff shows the full change.

## Tests

- Unit:
- `FieldValues.Read` keeps stored date-times, numbers, CRLF text and
JSON whose text matches, and replaces a changed one.
  - Unchecked booleans.
- `FactValues.Read` keeps a stored owner's case and a stored time's
seconds.
  - An unknown owner is refused.
  - `HasDetails`.
  - A JSON object without a `value` is a plain value.
  - A U+2028 in an edited text is kept.
  - A picker without matches has no `aria-controls`.
- Integration (`EntryFormScreenTests`, `EntityFormScreenTests`):
  - The #2630 overwrite scenario ends in the conflict message.
- After a published revert, the form names the reverted draft and offers
the published version. A form from a published version since replaced is
refused.
  - A reverted create says so.
- Editing an entry written before its type held facts shows its plain
values, a JSON object included, and saves its facts.
  - A title-only edit keeps several values exactly as stored:
    - a CRLF body that starts with a line break;
    - a multi-line `text` value, which gets a textarea;
    - the date-time text `09:30:45.5+02:00`;
    - `4.50`;
    - an absent boolean.
- `EntryEdits` refuses a blank source, and an update whose published
base isn't the published version. Neither writes a version or an event.
- A form open on the published version when a revert publishes an older
one is refused on save.
- An untouched value after its field changed from number to text is
saved as text.
- Editing a published entry proposes an update from version 1, and a
stray draft is named. The saved set is submitted from the set view.
  - The unknown enum value is reported.
- A name-only entity edit keeps the other fact byte for byte, including
a disabled upper-case owner, a source in another order with a trailing
space, and times with seconds and offsets. It also keeps an owner who is
no user, and an absent boolean.
- Problems and the unsourced marker sit inside their field's fact
fieldset.
  - A forged owner and fact details without a value are refused.
- Browser:
- A title-only edit in Chromium keeps a multi-line text and a rich text
that starts with a line break.
- The axe check covers a form with every widget, and a refused submit.
The keyboard path through a form and its save is `FormPickerTests` from
#2622.

`dotnet build -warnaserror`, the unit and bUnit suite, the browser tests
and the integration suite pass locally. No new package and no new
project reference.

## Checklist

- [x] Linked to an issue a maintainer has confirmed
- [x] Targets `v2`
- [x] Tests or docs updated where behaviour changed
- [x] No tool-generated co-author trailers or footers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:forms Generated forms (FRM) type:feature New capability v2 FluentCMS v2 (v2 branch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated forms for entity types with source, owner and validity

1 participant