Repository navigation
Commit bae933b
fix(record-page): the related tab offers only open-in-list and one add entry; a multi-pick add is all or none (#35725)
Part of #35601
Fixes #35710
Part of #35590
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:记录详情页的关联页签只剩「↗」和「+
添加」两个入口(普通关联的选择框只列出还没挂在任何记录下的子记录,不会悄悄把别处的记录改挂过来),一次选多条要么全部加上、要么一条不加;带状态的子记录按状态分组,已完成的排在最后;从「↗」打开的列表会写明来自哪条记录,可一键重置回去;明细表货币算不出来时合计照样显示金额。
- 为什么做:记录详情页子卡(关联页签只保留开列表与添加两件事),并顺带补上明细表合计缺失的子卡。
-
出错会怎样:一次选多条时如果其中一条失败,整批都不加并在列表下方显示服务端原话;目前这句话不一定点名是哪一条,这一半留在原卡等维护者定夺;改动只在界面层,直接撤回即可。
- 要你做什么:无。「批量添加失败时点名具体哪一条」已另开 #35726(给批量接口的报错加上第几条),本单合并后排队。
## What changes
**The related tab (`RelatedList.tsx`, the enlarged face).** The toolbar
draws two entries at its right end: 「↗」 (`data-related-open-list`, the
host's `onViewAll`) and 「+ 添加」 (`data-related-add`). The filter box, the
全部/我的/逾期 chips, the export, the tab's own New and the count line under
the table are gone; the count lives in the tab title. A page's declared
toolbar actions for the child (`toolbarActions`) still draw beside the
two entries: they are authored metadata, not tab chrome, and dropping
them would silently lose an authored action (see Acceptance notes).
**One add entry, chosen by the relationship** when the page authored no
`add` (`derivedAddOf`):
| child relationship | 「+ 添加」 opens |
|---|---|
| `lookup` | a picker of the child object, listing only UNLINKED
children (this relationship empty); its first row is New (`createRow`) |
| `master_detail` whose rows name a catalog record (exactly one other
required, single, editable `lookup`) | a picker of that catalog; a pick
creates a row naming it (`linkField`) |
| `master_detail` with no catalog | the new-record form, linked to this
record (the host's `onNew`) |
An authored `add` keeps its own picker and its own `picker.filter`, as
before.
**No silent re-parent (seat ruling on L1-a S1).** The derived lookup
picker filters `<relationship> is_empty`: a child already under this
record (a no-op pick) and a child under another parent (which a pick
would move without notice) are not offered. Moving a child between
parents stays on the child's own form, where the change is visible.
**All or none.** A pick of N records is ONE
`dataSource.batchTransaction` call: one `POST /api/v1/batch` with
`atomic: true` (ADR-0035, ADR-0119 D4), never a client loop.
Re-parenting a lookup child is `update`, a catalog pick is `create`. On
failure nothing is added, the picker closes and the server's own message
shows under the list (`role="alert"`). A data source with no
`batchTransaction` offers no picker (it falls back to New). This also
changes an authored `add` picker everywhere it is used: it was a loop of
single writes, it is now the same one batch.
**Status grouping.** On the related tab a child is grouped by status
when it has a status select (`detectStatusField`) AND a `dueLike` date
whose `settledWhen` the status settles. The rule, generic and declared,
not a name list: a status option is "completed" exactly when
`isDeadlineSettled(deadline, { [status]: option })` is true. Open
options come first in the order the select declares them, then rows with
no status (「—」), then the completed options; empty groups are not drawn;
each group header collapses its rows. No settling option ⇒ no groups
(the list draws as before).
**Remembered header sort and column widths.** Per list (`CHILD.FK`), in
the record page's existing per-user preference row
(`sys_user_preference` `ui.record.PARENT`, through
`RecordPagePreferencesContext`, which gains an optional `relatedLists`
slice); no new storage. The sort is applied once on first read; a header
click is written back. Column order and widths ride `object-grid`'s
existing `columnState` input and `onColumnStateChange` host prop.
**「↗」 on empty lists and body tables.** The card face draws 「↗」 on an
empty list and on a body table too (when the host offers a destination).
**The list 「↗」 opens knows its record**
(`RelatedRecordActionsBridge.tsx`, `ObjectDataPage.tsx`). The bridge
appends this record to the record trail (`?from=`) of the URL it already
built (`filter[FK]=ID`). The list page then names the record in the
condition's tag (「Account Globex ×」, the merged tag reused), draws a
breadcrumb (object / record / this list), offers 「Reset」 which puts the
sourced condition back after the reader changed or removed filters, and
opens New as that record's child (the record form overlay with
`formLink`, the related list's own New path). The condition itself stays
an ordinary URL filter.
**Body-table totals with no resolvable currency (the folded card).** A
currency column whose currency resolves to nothing (no code of its own,
no tenant default) now totals: the server's figure, drawn as its cells
are (two places, no symbol). Before, the total was left out. Record-mode
amounts whose rows name their own currency keep the per-currency
grouping (a mixed or unknown code still draws no total).
**`RecordPickerDialog`** gains an optional `createRow` prop (a dashed
first row). Columns and search are untouched.
No new i18n key: the strings reuse `detail.add`, `detail.new`,
`detail.viewAll`, `common.reset`. The keys the removed chips used
(`relatedFilter`, `relatedChips`, `relatedChipAll/Mine/Overdue`,
`relatedExport`, `relatedRows`) are now unread and left in the packs
(see Acceptance notes).
## Tests
Migrated and retired:
- `RelatedList.enlargedToolbar-27524.test.tsx`: rewritten. Retired the
chip, filter, export and in-tab New cases and the export describe; new
pins: exactly ↗ and Add (also on an empty list); lookup picker with New
first and three picks as ONE batch of three; a rejected batch adds
nothing, shows the reason and sends no single write; master_detail with
a catalog creates rows naming the catalog; master_detail without one
calls New; no batch route ⇒ no picker; status groups in order and
collapsible, with a control; the header sort written to and read from
the record-page preference.
- `RelatedList.enlargedListGrid-28865.test.tsx`: retired the filter-box
DEVIATION pin and the two chip-count pins; added "the count is not
repeated under the grid", column state read from and written to the
preference, and a no-store control.
- `RecordRelatedListRenderer.showViewAll-12741.test.tsx`: 「an EMPTY
list: no link」 migrated to 「an EMPTY list: ↗ still draws」.
- `RelatedList.bodyTable-27055.test.tsx`: 「…and not at all without one」
split; new pin: with no currency resolving the total is the server
figure, no symbol, one ungrouped aggregate.
- Add tests given a `batchTransaction` on their data source (the picker
gate now needs it): `addGateDataSource`, `addGrant-12082`,
`addPickerFilter`, `addPickerGuard`, `addPickerLabelField`,
`record-blocks.nestedLabelsI18nLabel-10993`.
New: `ObjectDataPage.sourceList-35601.test.tsx` (tag names the record,
breadcrumb, Reset, New linked, a no-trail control,
`sourceRelationshipField`); a `from` pin in
`RelatedRecordActionsBridge.viewAll-12741.test.tsx`; a `relatedLists`
sanitize pin in `RecordPreferencesProvider-25883.test.tsx`.
<details><summary>Readings at 6ea1cb9</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-detail
packages/app-shell/src/views/ObjectDataPage.sourceList-35601.test.tsx
packages/fields/src/widgets/RecordPickerDialog
packages/react/src/context` at 756d92b: 3 failed (all
`record-blocks.nestedLabelsI18nLabel-10993`, missing batch mock), 3773
passed; after the mock: that file and the sourced-list file 14/14.
- app-shell `ObjectDataPage*`, `RelatedRecordActionsBridge*`,
`RecordPreferencesProvider-25883`: 136/136 after the control fix;
console `record-block-record-reach`, `public-block-binding-reach`,
`PageBlockInspector.jsonFieldLabel-27178`, plugin-grid
`relatedListRowActionDisabled-33215`: 38/38.
- `type-check` (tsc --noEmit and tsconfig.test.json): react, fields,
plugin-detail, app-shell, exit 0.
- Ablation 1 (folded card): `else plan.amount = true;` replaced by `else
continue;` (anchor 1 to 0, blob efaf47a to 28984401): the new total pin
fails, 1 failed; restored, blob equals HEAD, `git diff HEAD` empty.
- Ablation 2 (one request): the batch call (now `await
ds.batchTransaction(operations);`) replaced by a per-op loop: 2 failed
(the lookup and the catalog batch pins); restored, blob equals HEAD.
</details>
<details><summary>Fixes after 6ea1cb9 (CI)</summary>
- df21125: dropped the unused `isPermissionError` import (Lint UI); the
related tab entry's `detail.add` fallback is written once
(`addFallbackLabel`), so the residue pin stays at 4 sites, and its
comment names the new entry.
- 05a187d: `batch.call(dataSource, …)` hid the add from the affordance
write census (`affordanceGrantMap-12082`); it now calls
`ds.batchTransaction(operations)` directly, and the census has one
`handleAddRecords :: batch` site mapped to `relatedNew` +
`relatedRowEdit` (replacing the old `create` / `update` pair).
- CI at 05a187d: 45 success, 13 skipped, 0 failed.
- e62ce9e (seat ruling on L1-a S1): the derived lookup picker filters
the relationship to empty; new pin in
`RelatedList.enlargedToolbar-27524`: a row linked here and a row linked
elsewhere are absent, the unlinked row is present, and every picker read
carries the rule.
</details>
## Acceptance notes
- **Open decision: naming the failed item.** Measured on a live boot:
`POST /api/v1/batch` with `atomic: true` answers a failing op with ONE
error (`404 {"error":"Record ID not found in
showcase_contact","code":"RECORD_NOT_FOUND",...}`) and no op index. The
list shows that message, which names the record only when the server's
own message does (here it does; a validation error such as a missing
required field does not). Naming the item in every case needs the batch
route to say which op failed (a `batch-routes.ts` widening, Clause-②
yes) or a data-source door over the per-object atomic batch
(`/data/OBJECT/batch`, which reports per row). Neither was made here:
the op index is filed as #35726 (nested under #35601), which is why the
body says Part of for the related-tab card.
- **Fence readings, declared:** `RecordPickerDialog` gains `createRow`
(the fence names its columns and search; neither changed).
`RecordPagePreferencesContext` (react) and `RecordPreferencesProvider`
(app-shell) gain the `relatedLists` slice: the ruling's per-user
mechanism, no new storage. `ObjectDataPage.tsx` carries the list route's
tag, breadcrumb and reset wiring (the claim's "list route wiring");
`useOpenRecordList.ts` needed no change.
- **Kept, not removed:** a page's declared `toolbarActions` for the
child still draw beside ↗ and Add (authored metadata, not tab chrome).
- **Not added:** auto-filling a catalog row's same-named fields
(description, unit price) on a picker add; the server's defaults and
hooks apply. 「Reset」 rewrites the URL filters; a quick-filter selection
inside the list view is read from the URL only on first mount.
- **Seen on the list page, not touched (list-page internals are out of
this card):** the list view's own locked chip repeats the sourced
condition with the raw id (「Account: = 3zKQ…」) under the named tag, and
the list view's own 「Reset」 sits under this page's 「Reset」 (screenshot
06).
- The "master_detail with no catalog" entry opens the new-record form
linked to the record (the ruling's "add a row directly"); it does not
insert an inline blank row.
- The removed chips' i18n keys are left in the packs, unread.
- No platform-checklist item changed:
`records-forms.related-list-server-pagination` still holds (paging kept
on the tab).
## Verification
Two-minute check: on the CRM example, open an opportunity, its
Activities tab: two buttons at the right (↗, Add), activities grouped
Planned / In Progress / Cancelled / Completed. Open the Line Items body
table: the Total row shows amounts with no currency symbol.
Browser reading (A4): built console (`pnpm console:build` at this
branch), headless Chromium 1440x900 at DSF 2; screenshots in the seat's
`a4-35601` folder.
<details><summary>A4 readings</summary>
- Showcase, account Globex, Contacts tab (lookup, empty): toolbar
`["View All","Add"]` (01). Add opens a picker of contacts, first row New
(02). Three picks, Confirm: ONE `POST /api/v1/batch` 200 with three
`update` ops and `atomic: true`; tab title Contacts 3 (03, 04).
- Failing case: three more picked, the third deleted before Confirm: ONE
`POST /api/v1/batch` 404 `RECORD_NOT_FOUND`; the alert shows the server
message; the account still has 3 contacts and the first two picks kept
their old account (05).
- ↗ round trip: the list opens at
`.../showcase_contact/data?filter[account]=ID&from=[{o,i,t:"Globex"}]`;
tag 「Account Globex」, breadcrumb 「Accounts (Success Overlay) / Globex /
Contacts」, Reset disabled (06); tag removed, Reset enabled (07); Reset
puts `filter[account]` back (08); New opens the Create Contact overlay
with `formLink=account:ID` (09); the breadcrumb record link returns to
the account page.
- CRM, opportunity Initech Expansion, Activities tab: groups `planned,
in_progress, cancelled` open and `completed` settled, in that order (11,
12 collapsed).
- CRM line items (master_detail, product is text, no catalog): enlarged
toolbar `["View All","Add"]`; Add opens the new-record form
(`form=new&formObject=crm_opportunity_line_item&formLink=opportunity:ID`),
no picker (15, 16). Body table total row 「Total 2,649.75 5,501.00」,
cells 「999.00」, 「3,601.50」: no symbol, as the cells (14).
- The CRM line-item add-3 case does not exist as filed: the CRM line
item has no catalog, so its Add is the form; the add-3 and failing cases
were read on the showcase Contacts tab instead.
</details>
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CZrgaiMgTJCnswR6jQ -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 96faf44 commit bae933b
23 files changed
Lines changed: 1223 additions & 496 deletions
File tree
- .changeset
- ui/packages
- app-shell/src
- context
- __tests__
- views
- __tests__
- fields/src/widgets
- i18n/src/__tests__
- plugin-detail/src
- __tests__
- renderers/__tests__
- plugin-form/src
- react/src/context
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
65 | 98 | | |
66 | 99 | | |
67 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
0 commit comments