Skip to content

Form page type to create a row #3437

Todo

Description

@rubenvdlinde

Is your feature request related to a problem? Please describe.

  • Many applications start with a request form. Today the only way to add a row is the row modal of the table.
Why this is needed

Describe the solution you'd like

  • A page type that is a form built from the columns of one table. It can have one step or several, validates each field against its column type and format, and creates a row on submit.
Diagram
flowchart LR
    M["Menu item of the application"] --> F["Form page<br/>chosen columns of one table"]
    F --> S1["Step 1"]
    S1 --> V1{"Valid for column type<br/>and format?"}
    V1 -- no --> S1
    V1 -- yes --> S2["Step 2"]
    S2 -- back, input kept --> S1
    S2 --> V2{"Valid?"}
    V2 -- no --> S2
    V2 -- yes --> P["POST api/2/tables/{nodeId}/rows"]
    P --> C["Confirmation"]
    P --> D["Detail page of the new row"]
Loading
Acceptance Criteria
  • The form page belongs to one table and lists a chosen subset of its columns, in a chosen order.
  • Fields can be grouped into steps; the user can go back without losing input.
  • Each field is validated against its column type and format before the next step.
  • On submit one row is created, and the page shows a confirmation or opens the row.
  • Unit tests for the validation, a Playwright spec for a two-step form.
  • Writes: the submit goes through the existing row create route, which declares #[RequirePermission] (create) on the table, and creating or changing the form page goes through the page routes, which declare manage on the application (context). The service checks the same right before it writes (as agreed on UUIDs for rows #3093 and in the review of feat(contexts): give applications a menu with its own API #3135). A test runs every write as a reader and expects 403, or 404 where the reader may not know the object exists.
  • The form configuration (columns, order, steps) is stored as JSON in a text column of the page, like widget settings today, never in the database JSON column type (as agreed on Grid pages in applications (frontend) #3099).
  • If the page needs a new column for it: nullable, backfilled, then NOT NULL; no empty-string defaults, since Oracle stores '' as NULL (as raised on Technical name for tables and applications, CRUD routes by application and table #3094); the version in appinfo/info.xml is bumped with the migration (as raised on feat(rows): add persistent UUIDv7 identifiers to rows #3229).
  • Deleting the table deletes its form pages in the same transaction, and deleting a column removes it from the forms that list it. A repair step that runs once after the upgrade removes leftovers, not a recurring cleanup job (as agreed on Grid pages in applications (data model and API) #3100).
  • Steps use NcStepper (feat(NcStepper): add stepper component nextcloud-libraries/nextcloud-vue#9162, merged); fields use the same inputs as the row modal, and the submit button uses a checkmark, not a save icon.
  • Usable at 360 px wide: nothing cut off, no horizontal scroll of the page. Every action works by keyboard.
Components
  • CnFormPage (adapt, week 46): the form page type. It already submits to a configured endpoint; in Tables that is the row create route of the bound table. Its remote visibility rules are the only OpenRegister calls and stay out, as this issue leaves visibleWhen out.
Out of scope

Describe alternatives you've considered

Questions for maintainers

  1. A form as a page type of its own, or a form widget on a grid page? We would go with a page type, because the public link of Submit a form page without an account #3438 needs its own page address and buildiq models the form as a page.
  2. The steps: stored as JSON in a text column of the page, or as their own entities in a new table? We would go with JSON in a text column, because steps are only ever read with their page.
  3. After a submit: a confirmation text, or open the new row? We would go with a confirmation by default, and opening the row as an option per form, because many people who fill in a form cannot read the table.

Additional context

Linking to other objects
Relevant files:
Related issues

Drafted with AI assistance from the project plan; @remko48 reviews it. Part of #3419.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions