You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 571b494
Browse filesBrowse the repository at this point in the historyBrowse files
fix(console): the record page's edit-state save writes a closing header after its lines (ADR-0162 D4) (#39007)
Part of #38997
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
控制台记录页进入编辑状态后,同时改明细行并把单据改成关闭状态(如“已付款”)的一次保存,会先写明细、最后写单据头,整单保存成功;以前这样的保存会被整单拒绝。不关单的保存与今天一样。
- 属于“记录关闭态锁”这一组工作,替记录页编辑状态补上主从表单已有的“关单写在最后”的顺序。
- 出错时,编辑状态下改明细并关单的保存可能仍被整单拒绝,或不关单的保存顺序变了;改动只在控制台,可直接撤回。
- 无
## What changes
Item 1 of the card (the edit-state save order). Item 2, the full-record
edit dialog's closed lock, waits on the record-page lock work of #37773
(branch `claude/issue-37773-record-page-lock`), which adds the
data-layer lock to the record approvals hook; this PR adds no lock read
of its own and touches no file of that work.
- **Batch builder**
(`ui/packages/plugin-form/src/RecordBodyTableEditor.tsx`,
`buildRecordEditBatch`): takes the object's `closedStates` as a new
optional fifth argument, the `MasterDetailEditOptions` that
`buildMasterDetailEditBatch` takes. When the field draft sets a value
the object lists in `closedStates` (judged by the shared
`closesRecord`), the record's update is written after every line write
and owned as `{ kind: 'parent' }` at the end. Otherwise the record's
update stays op 0. Callers that pass nothing get the old order. ADR-0162
D4.
- **Edit-state controller**
(`ui/packages/app-shell/src/views/recordEditState.tsx`): reads
`closedStates` off the object definition the page's
`RecordContextProvider` already carries (no request), hands it to the
builder, and drops an empty draft's record update by its owner instead
of slicing index 0.
- Changeset: `.changeset/38997-edit-state-closing-order.md`
(`@object-ui/plugin-form` and `@object-ui/app-shell`, patch).
## Tests
- `RecordBodyTableEditor.recordEditBatch-35599.test.ts`, new describe: a
closing draft puts the record update last with its owner last, and a
refusal is still placed on the record field and on the line; CONTROL: a
non-closing value, a non-state field, and no `closedStates` keep the
record first.
- `RecordDetailView.harness.test.tsx`, `recordEditState-35599` block:
two new cases drive the real record page. Edit lines, pick the closing
status, Save: the one batch ends with the record update. CONTROL: the
same edits with a status the object does not close on keep the record
first.
<details><summary>Ablations (each restored, blob equal to
HEAD)</summary>
- Controller: passing `{}` instead of `{ closedStates }` turns the
closing harness case red (record update not last); its control and the
other 9 cases stay green.
- Builder: forcing `closing = false` turns the closing unit case red;
the other 9 in the file stay green.
</details>
## Acceptance notes
- Request count: unchanged. The controller reads the object definition
the page already holds; the record page's one-request record open is not
touched.
- Item 2 (the edit dialog opens locked with the closed wording on a
closed record) is not in this PR. It builds on the record-page lock work
of #37773, once that lands.
- `closesRecord` judges only the edited keys of the draft, as the
master-detail form does: a save that edits lines on a record that is
already closed is still refused by the server (that is the lock the
dialog and the page should show, item 2).
## Verification
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-form/src/RecordBodyTableEditor.recordEditBatch-35599.test.ts`
(from the repo root): 10 passed, including the closing describe.
Read first: `recordEditState.tsx` (the owner-based drop of the record
op), then `buildRecordEditBatch`.
<details><summary>Local readings, head 79b7870</summary>
- plugin-form full suite: 255 files, 2,842 passed, 1 skipped.
- app-shell: `RecordDetailView.harness.test.tsx` and
`recordEditState.helpers-35599.test.ts`: 98 passed.
- `type-check`: plugin-form exit 0, app-shell exit 0. eslint on the four
touched source and test files: 0 errors.
- `dispatch-gates --ran` (taken at 23ace6e): 39 derived, 39 run, 0
NOT-MEASURED. The set is unchanged at 79b7870; the ratchet families
(type-check coverage and debt, test-source-alias,
cross-package-test-inputs, nul-bytes, undeclared-dep-imports) re-run
there: all exit 0.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzhKEbEnW8pwZRgK2gJ
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(console): the record page's edit-state save writes a closing header after its lines
7
+
8
+
Clause-②: no
9
+
Metadata-protocol: none
10
+
11
+
On a record page in its edit state, a Save that edits the body-table lines and also sets the record to a state its object lists in `closedStates` now writes every line first and the record's update last, in the same one batch. Before, the record's update went first, the line writes then met a closed record, and the whole save was refused. A Save that does not close the record keeps the record's update first, as before. This is the order the master-detail form already uses (ADR-0162 D4).
12
+
13
+
`buildRecordEditBatch` takes the object's `closedStates` as a new optional fifth argument (`{ closedStates }`), the same option `buildMasterDetailEditBatch` takes. Callers that pass nothing get the old order. Find the record's operation by its owner (`{ kind: 'parent' }`), not by index 0: a closing update is the last operation.
0 commit comments