Skip to content

Related rows widget #3447

Todo
Todo

Description

@rubenvdlinde

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

  • A record with its related records is the core of most applications, for example a case with its documents and contacts.
Why this is needed

Describe the solution you'd like

  • A widget for the detail page that lists the rows related to the current row, in one direction or both, with the option to add or remove a relation.
Diagram
sequenceDiagram
    actor U as User
    participant W as Related rows widget
    participant API as Rows API v2
    participant RL as Inverse lookup of issue 3347
    participant P as PermissionsService
    U->>W: open a row's detail page
    W->>API: rows related to this row, out, in or both
    API->>RL: outgoing cells and rows that point here
    API->>P: may the user read each related row?
    API-->>W: related rows the user can read
    U->>W: add a relation
    W->>API: update the relation cell
    API->>P: may the user write the table with the column?
    API-->>W: saved, list refreshed
Loading
Acceptance Criteria
  • Listed by GET /api/2/widget-types with its settings schema: relation column, direction.
  • Uses the inverse lookup of Relations: filter, sort, inverse lookups, inline resolve, import and export #3347.
  • Adding and removing a relation respects the write permission of the table.
  • A Playwright spec on a detail page.
  • Only related rows the reader may read are listed, also in counts.
  • Adding and removing a relation (a write to the relation cell): the route declares its permission with #[RequirePermission] (update on the table that holds the relation column) using a fixed node type (table), and 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.
  • Removing a relation clears the cell, and does not delete either row.
  • The list uses NcListItem, the picker to add a row NcSelect. Usable at 360 px wide: nothing cut off, no horizontal scroll of the page. Every action works by keyboard.
Components
Out of scope

Describe alternatives you've considered

Questions for maintainers

  1. Adding a relation in the incoming direction writes a cell in the other table. Allow it when the user may write that table, or only allow the outgoing direction? We would go with allowing it, with the write check on the other table, because that is what a case worker expects on the case.
  2. What each related row shows: its title column only, or columns chosen in the widget settings? We would go with chosen columns, defaulting to the title.

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