Skip to content

Commit 5064289

Browse files
fix(console): word a closed record apart from one in approval, and save a closing header last (ADR-0162 item 4) (#38994)
Part of #37773: this PR lands the grid, the line grid and the closing-header-last save. The record-page half stays open on the card and waits on #38995. Clause-②: no Metadata-protocol: none ## 维护者速读 - 控制台表格和明细表格里已关闭的行(如已付款发票及其明细行)编辑时提示“已关闭,无法更改”,不再提供编辑和删除;审批中的行与今天一样;记录页本身暂不变。 - 属于“记录关闭态锁”这一组工作(ADR-0162 第 4 项),让用户分清“已关闭”和“审批中”,并让同时改明细和关单的一次保存整单成功。 - 出错时表格里可能显示错误的锁原因,或关单保存被整单拒绝;改动只在控制台和一段文档,可直接撤回。 - 无 ## What changes ADR-0162 item 4, the grid half: the grid and the line grid ask the data layer's one lock read (D9, landed in #38913) for a row's edit and delete affordances, and word the reason from its `lockReason`. The master-detail form writes a closing header last. - **Grid and line grid** (`ui/packages/plugin-grid/src/hooks/useRowApprovalLocks.ts`): the on-demand page read now goes to `POST /api/v1/data/OBJECT/locks`, chunked at `RECORD_LOCKS_MAX_RECORD_IDS`. It is gated on `routes.data` in discovery (not on the approvals service), and the 501 latch is kept. Each answer keeps `lockReason`. New members `closed(id)` and `deleteRefused(id)`; `heldByMaster` is gone. `deleteRefused` is true on `closed_state` for either source, and on `approval` only for `lockSource: 'master'`, which is the published rule. Same request count as before. - **Grid wording** (`objectGridCellFacts.ts`, `ObjectGrid.tsx`, `objectGridTranslations.ts`): a new `closedLocked` read-only kind, checked before `approvalLocked`. A cell on a closed row opens no editor and says "This record is closed, so it can't be changed."; a closed row that is also held reads as closed. - **Row menu** (`objectGridActionsColumn.tsx`): Edit and Delete read the same answer, so a closed row offers neither. Greying Edit instead of hiding it is #38996. - **Master-detail save** (`ui/packages/plugin-form/src/masterDetailTx.ts`, `MasterDetailForm.tsx`): an edit save whose header data sets a value the header object lists in `closedStates` puts the header update after every line write (ADR-0162 D4). Otherwise the header stays first. The form reads `closedStates` from the header's own served definition, and the result mapping finds the parent by object and id, not by index 0. Create stays parent-first, because its lines point at operation 0. - **Strings**: `grid.readOnlyReason.closedLocked` in all eleven console locales; zh-Hant is generated from zh-Hans. - **Docs** (`content/docs/data-modeling/closed-states.mdx`, § Line edits go before the closing write): the passage that said the console's master-detail form saves the header first now says it writes a closing header last, so such a save lands whole. Only that passage changes. - `userActions` predicates and action buttons are untouched: the lock read hides no action. ## Tests - New: `plugin-form/src/masterDetailTx.closingHeaderLast-37773.test.ts` (7) and `MasterDetailForm.closingHeaderLast-37773.test.tsx` (2). The second drives the real form: it picks `paid`, edits a line, and pins `['update invoice_line', 'update invoice']`. A second save diffs against what the first wrote, and the control keeps the header first. - New blocks: `rowMenuApprovalLock-36911.test.tsx` (2: closed own and closed line offer neither Edit nor Delete, own approval keeps Delete) and `ObjectGrid.cellSelection-35684.test.tsx` (closed wording; closed and held reads as closed). - Moved to the data door: the grid lock pins (36911, 35684, 35685, 27365, the row CRUD verdict, discovery 38849). - app-shell is unchanged from main. Its one-request record-open pins (27627, 28470, 12701, 13010, 28737) pass unedited against this grid. <details><summary>Ablations (one per fix, each restored)</summary> - Save order: forcing `closing = false` in `buildMasterDetailEditBatch` turns 3 of the 9 new plugin-form tests red. - Grid: dropping `closed_state` from `deleteRefused` and `closed` turns the three closed pins in 36911 and 35684 red (42 of 45 still pass). </details> ## Acceptance notes - **The record-page half waits on #38995** (a data-lock part on the record-page payload, so a record open stays one request). The removed record-page work is pushed, with no PR, on `claude/issue-37773-record-page-half-wip` at `ca71605f`. Its record-page files, against main: `ui/packages/app-shell/src/hooks/useRecordApprovals.ts`, `views/RecordDetailView.tsx`, `views/recordDeleteHeldByMaster.ts`, the tests `useRecordApprovals.lockSource-37195`, `RecordDetailView.approvalLock-25934`, `RecordDetailView.harness` (§ closedLock-37773) and `AppContent.editDialogApprovalLock-27138`, and the strings `detail.lockedClosed` / `detail.lockedClosedTooltip`. Until it lands, the record page reads the approvals lock as main does: a closed record there still shows Edit (the server refuses the write), with no closed wording. - **Greying the grid row menu's Edit** with the closed sentence, instead of hiding it, is #38996. - **The record page's edit-state save order and the full-record edit dialog's closed lock** are #38997. - Main's `recordDeleteHeldByMaster.ts` header comment still names `useRowApprovalLocks.heldByMaster`, which this PR removes. The comment only; the record-page half rewrites that file. - A reader who may not see the state field gets the closed wording from the lock answer alone; the grid reads no field for it. ## Verification Browser, on the showcase (paid invoice from #38917) through this branch's console source: https://claude.ai/artifact/1WWaA6gcswQuZHN2yJDnW8 (private until shared). For this PR, the grid frame applies: an edit on the paid row INV-1003 opens no editor and shows the closed sentence. The record-page frames there show the half that moved to #38995. Two-minute check: in the showcase, open Invoices, select the Owner Email cell of a paid invoice and press Enter. Expect "This record is closed, so it can't be changed." and no editor; a draft invoice's cell opens its editor. <details><summary>Local readings</summary> - plugin-grid full suite, in three parts: 323 files, 2,850 tests passed. plugin-form and i18n full suites: green after the zh-Hant regeneration. - app-shell: the five one-request pin files plus the four test files back on main, with i18n: 119 files, 2,031 passed, 13 skipped. - `dispatch-gates --ran` on the final tree (73 derived, the docs families included): 73 run, all exit 0, 0 NOT-MEASURED. - ui `check:spec-symbols`, `check:i18n-keys`, `check:i18n-drift` and `check:new-line-citations`: exit 0. `overlap-check`: clean against origin/main. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ <!-- signed: repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhKEbEnW8pwZRgK2gJ --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent fc7534a commit 5064289

28 files changed

Lines changed: 665 additions & 143 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/plugin-grid': patch
3+
'@object-ui/plugin-form': patch
4+
'@object-ui/i18n': patch
5+
---
6+
7+
fix(console): a closed row in a grid reads as closed, not as in approval, and a save that closes a master writes its lines first
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
The grid and the line grid now ask the data layer's one lock read (`POST /api/v1/data/{object}/locks`, on the first cell or row selection) for the edit and delete affordances of a row, and word the reason from its `lockReason`. They no longer ask the approvals lock read for this.
13+
14+
- A closed row (`lockReason: 'closed_state'`, its own state or its master's) opens no cell editor, and the cell says "This record is closed, so it can't be changed." Its row menu offers neither Edit nor Delete, for either `lockSource`. A row that is closed and also held by an approval reads as closed.
15+
- A row held by an approval behaves as before: its own approval keeps Delete, and a line of a held master does not.
16+
- The answer is read above the caller's field permissions, so a reader who may not see the state field still gets the closed wording.
17+
- A master-detail edit save that sets a closing state on the header (a value its object lists in `closedStates`) writes every line first and the header last, in one batch, so the save is not refused against the record it is closing. A save that does not close keeps the header first.
18+
- New string `grid.readOnlyReason.closedLocked` in every console locale.
19+
20+
The grid's lock read is gated on the `data` route in discovery, not on the approvals service, and makes the same number of requests as before. The record page is unchanged here.

‎content/docs/data-modeling/closed-states.mdx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,10 @@ app that reassigns closed documents ships an action for it.
308308
Once the write that closes a document has landed, a later write in the same unit
309309
of work meets a closed record. So when line edits and the closing write travel in
310310
one save, the lines are written first and the header that closes the document
311-
last. The console's master-detail form saves the header before its lines, in one
312-
transaction, so a save there that both closes the document and changes a line is
313-
refused whole: change the lines, then close the document in a save of its own.
311+
last. The console's master-detail form follows this order: when a save sets a
312+
value the header object lists in `closedStates`, it writes every line first and
313+
the header last, in one transaction, so a save that changes lines and closes the
314+
document lands whole.
314315

315316
A create has no such order. A caller cannot create a document that is already
316317
closed together with its lines, because each line would be added under a closed

‎ui/packages/i18n/src/locales/ar.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ const ar = {
621621
viewOff: "التحرير في القائمة متوقف لهذا العرض.",
622622
objectReadOnly: "لا يمكن تحرير هذه السجلات هنا.",
623623
noPermission: "ليس لديك إذن بتحرير هذه السجلات.",
624+
closedLocked: "هذا السجل مغلق ولا يمكن تغييره.",
624625
approvalLocked: "هذا السجل مقفل أثناء الموافقة عليه.",
625626
checking: "جارٍ التحقق مما إذا كان يمكن تعديل هذا السجل…",
626627
noRecordPermission: "ليس لديك إذن بتحرير هذا السجل.",

‎ui/packages/i18n/src/locales/de.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ const de = {
587587
viewOff: "Das Bearbeiten in der Liste ist für diese Ansicht ausgeschaltet.",
588588
objectReadOnly: "Diese Datensätze können hier nicht bearbeitet werden.",
589589
noPermission: "Sie haben keine Berechtigung, diese Datensätze zu bearbeiten.",
590+
closedLocked: "Dieser Datensatz ist abgeschlossen und kann nicht mehr geändert werden.",
590591
approvalLocked: "Dieser Datensatz ist während der Genehmigung gesperrt.",
591592
checking: "Es wird geprüft, ob dieser Datensatz bearbeitet werden kann…",
592593
noRecordPermission: "Sie haben keine Berechtigung, diesen Datensatz zu bearbeiten.",

‎ui/packages/i18n/src/locales/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ const en = {
866866
viewOff: 'Editing in the list is turned off for this view.',
867867
objectReadOnly: 'These records can\'t be edited here.',
868868
noPermission: 'You don\'t have permission to edit these records.',
869+
closedLocked: 'This record is closed, so it can\'t be changed.',
869870
approvalLocked: 'This record is locked while it\'s in approval.',
870871
checking: 'Checking whether this record can be edited…',
871872
noRecordPermission: 'You don\'t have permission to edit this record.',

‎ui/packages/i18n/src/locales/es.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ const es = {
599599
viewOff: "La edición en la lista está desactivada para esta vista.",
600600
objectReadOnly: "Estos registros no se pueden editar aquí.",
601601
noPermission: "No tiene permiso para editar estos registros.",
602+
closedLocked: "Este registro está cerrado y ya no se puede modificar.",
602603
approvalLocked: "Este registro está bloqueado mientras está en aprobación.",
603604
checking: "Comprobando si este registro se puede editar…",
604605
noRecordPermission: "No tiene permiso para editar este registro.",

‎ui/packages/i18n/src/locales/fr.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ const fr = {
594594
viewOff: "La modification dans la liste est désactivée pour cette vue.",
595595
objectReadOnly: "Ces enregistrements ne peuvent pas être modifiés ici.",
596596
noPermission: "Vous n'avez pas l'autorisation de modifier ces enregistrements.",
597+
closedLocked: "Cet enregistrement est clôturé et ne peut plus être modifié.",
597598
approvalLocked: "Cet enregistrement est verrouillé pendant son approbation.",
598599
checking: "Vérification de la possibilité de modifier cet enregistrement…",
599600
noRecordPermission: "Vous n'avez pas l'autorisation de modifier cet enregistrement.",

‎ui/packages/i18n/src/locales/ja.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ const ja = {
587587
viewOff: "このビューでは一覧での編集がオフになっています。",
588588
objectReadOnly: "これらのレコードはここでは編集できません。",
589589
noPermission: "これらのレコードを編集する権限がありません。",
590+
closedLocked: "このレコードはクローズ済みのため変更できません。",
590591
approvalLocked: "このレコードは承認中のためロックされています。",
591592
checking: "このレコードを編集できるか確認しています…",
592593
noRecordPermission: "このレコードを編集する権限がありません。",

‎ui/packages/i18n/src/locales/ko.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ const ko = {
587587
viewOff: "이 보기에서는 목록 편집이 꺼져 있습니다.",
588588
objectReadOnly: "이 레코드는 여기에서 편집할 수 없습니다.",
589589
noPermission: "이 레코드를 편집할 권한이 없습니다.",
590+
closedLocked: "이 레코드는 마감되어 변경할 수 없습니다.",
590591
approvalLocked: "이 레코드는 승인 중이라 잠겨 있습니다.",
591592
checking: "이 레코드를 편집할 수 있는지 확인하는 중…",
592593
noRecordPermission: "이 레코드를 편집할 권한이 없습니다.",

‎ui/packages/i18n/src/locales/pt-BR.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ const pt = {
594594
viewOff: "A edição na lista está desativada para esta visualização.",
595595
objectReadOnly: "Estes registros não podem ser editados aqui.",
596596
noPermission: "Você não tem permissão para editar estes registros.",
597+
closedLocked: "Este registro está fechado e não pode mais ser alterado.",
597598
approvalLocked: "Este registro está bloqueado enquanto está em aprovação.",
598599
checking: "Verificando se este registro pode ser editado…",
599600
noRecordPermission: "Você não tem permissão para editar este registro.",

0 commit comments

Comments
 (0)