Repository navigation
Todo
Labels
enhancementNew feature or request
Description
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
- A case worker needs to see and add them on the detail page without going to another table.
- buildiq parity: the
relatedwidget (detail only) and "relations and their inverse" (uses,used), which Tables lacks beyond a single relation column (sections 3 and 7 of the feature comparison). - It depends on relations with inverse lookup (Relations: filter, sort, inverse lookups, inline resolve, import and export #3347) and on the detail page (Detail page type for one row #3435): "the file type (sprint 1) and relations (sprint 3) before the related widget and the detail sidebar". Several rows per cell (Multi-valued relations #3348) makes one relation column hold a list.
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
Acceptance Criteria
- Listed by
GET /api/2/widget-typeswith 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 rowNcSelect. Usable at 360 px wide: nothing cut off, no horizontal scroll of the page. Every action works by keyboard.
Components
- CnRelatedObjectsWidget (rewrite, week 48): rewritten as the related rows widget on the adapter method
relations(source, id, direction), which reads the relation columns in both directions (Relations: filter, sort, inverse lookups, inline resolve, import and export #3347). - CnRelatedCollections (rewrite, week 48): rewritten as titled lists of the rows that point at the current row, through the inverse lookups of Relations: filter, sort, inverse lookups, inline resolve, import and export #3347.
- CnRelationLinkModal (adapt, week 46): picks an existing row of the target table and sets the relation cell of the current row to it, through the row update route.
- CnResourceSelect (adapt, week 46): the row picker behind it: searches the target table through
list, shows the choice throughget, and can create a row from the typed text.
Out of scope
- The inverse lookup itself (Relations: filter, sort, inverse lookups, inline resolve, import and export #3347), several rows per cell (Multi-valued relations #3348) and delete behaviour (Delete behaviour on relation and file columns #3350).
- Links to mails, Deck cards and other apps (Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468).
- Proposed slicing, one PR each in landing order: the list (read only), then adding and removing.
Describe alternatives you've considered
Questions for maintainers
- 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.
- 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
- The issue touches rows and their relation cells, on the detail page.
- Today: the relation column points one way at one row. Filter, sort, inverse lookups, inline resolve and import remapping are Relations: filter, sort, inverse lookups, inline resolve, import and export #3347; several rows per cell is Multi-valued relations #3348 (Robert's draft
Issues-2/issues/08-multi-valued-relations.md); delete behaviour is Delete behaviour on relation and file columns #3350. Links of Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468 are separate stored edges, not cells. - What this issue must do: keep the widget's source a setting (a relation column today), so a later option can list links of type
relatedto rows of other tables in the same widget. Check read permission per related row. When a relation is added in the incoming direction, check write permission on the table that holds the relation column, not on the current one. Follow Delete behaviour on relation and file columns #3350 for a target row that is deleted. - A widget that shows another app's object (a Deck board, a calendar, a text file) is the same registration question as Q2 of the plan: apps register widgets for Tables. The Teams widgets work in Team dashboard circles#2552, and Team dashboard V1 circles#3010 goes in a similar direction. Maintainers can say whether Tables widgets and Teams widgets should share one registry.
Relevant files:
Related issues
- Multi-valued relations #3348
- depends on Relations: filter, sort, inverse lookups, inline resolve, import and export #3347
- Delete behaviour on relation and file columns #3350
- links between rows and other apps (Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468)
Drafted with AI assistance from the project plan; @remko48 reviews it. Part of #3419.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity