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 0ad44a3
Browse filesBrowse the repository at this point in the historyBrowse files
fix(fields): the fill-in dialog judges option visibleWhen on the record the write would leave (#37264)
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ
Fixes#37250
Clause-②: yes (widening) — the exported `RequiredWhenPromptField` of
`@object-ui/fields` gains one optional member, `record?: Record<string,
unknown>`
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:在记录上就地改动(改阶段、改列表单元格、行内编辑、看板拖动)弹出「补填必填字段」时,弹窗里的下拉、单选、级联选择、关联查找和金额币种,都按这次改动后的记录来显示;比如商机改为「失败」后,丢单原因会列出该有的选项,不再显示「暂无可选项」。
-
为什么做:补填弹窗之前根本没把记录交给里面的控件,凡是要读记录的控件都按一条空记录判断,于是有的选项被藏掉、要先选上级的列表一直停在「请先选择」,改动保存不了。
-
出错会怎样:影响补填弹窗里各控件如何读取记录(选项显示、级联、关联查找的过滤、金额跟随的币种);若有误,最多是弹窗里某些选项多显示或少显示,可直接撤回本次改动,不涉及数据。
- 要你做什么:无
## What changes
The required-fields fill-in dialog rendered each control with no record
at all, so an option `visibleWhen` reading `record.*` was judged on an
empty record. An option list whose every option reads the field the
change writes (hotcrm's `crm_opportunity.loss_reason`, shown only while
`stage == "closed_lost"`) offered nothing: the select drew its empty
state and the change could not be saved.
- `collectRequiredWhenPromptFields` already judges the prompt on one
merge, the stored record with the change (`next = { ...record,
...changes }`). Each field it returns now carries that record as
`record` (new optional member of `RequiredWhenPromptField`).
- `RequiredFieldsDialog` hands every control `dependentValues` = that
record with the values typed into the dialog on top, i.e. the record the
write would leave. A row a host builds itself (a refusal-named field)
reads the same record whenever any shown field carries one.
- `requiredWhen` / field `visibleWhen` / `readonlyWhen`: already judged
on `next` by the collector (unchanged); the new collector assertion pins
that the carried record is that same merge.
## Tests
`ui/packages/fields/src/__tests__/RequiredFieldsDialog.inPlace-35956.test.tsx`,
new top-level describe (objectstack#37250), five cases: the collector
carries the merged record; a select whose options read the changed field
offers them instead of the empty state; a radio offers exactly the
options visible on the merged record (a won-only option stays hidden); a
value typed into the dialog joins the record the other rows read; the
mirror case, a select whose options are won-only, offers them on a move
to closed-won.
## Acceptance notes
- Same family, outside this card's file surface, not changed here: the
hosts' `refusalField` rows are built as `{ name, def }` with no record.
With at least one collected field shown they now read the dialog's
record; with zero collected fields (the record header's stage menu
opening the dialog as a pure confirmation) a refusal-added option row
reads only the typed values. Hosts:
`ui/packages/plugin-detail/src/renderers/recordPathStageChange.tsx`,
`ui/packages/plugin-detail/src/InlineEditSaveBar.tsx`,
`ui/packages/plugin-grid/src/objectGridRequiredPrompt.tsx` (kanban
passes no `refusalField`).
- `ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx` add-row dialog
renders `FieldEditWidget` with no `dependentValues`, so an option
`visibleWhen` reading a sibling row field is judged on an empty record
there too. Not a pending-change case; noted only.
## Verification
Two-minute check: `cd ui && pnpm --filter @object-ui/fields exec vitest
run --root ../.. --maxWorkers=2
packages/fields/src/__tests__/RequiredFieldsDialog.inPlace-35956.test.tsx`
— expect 12/12 passed.
Read first: `ui/packages/fields/src/RequiredFieldsDialog.tsx` (the
`liveRecord` memo and the `dependentValues` prop), then
`ui/packages/fields/src/requiredWhenPrompt.ts` (`record: next`).
## Rework round 1 (head `f731d2461f2`)
Per the seat L1 7158746595: M1 — the widening is declared here and in
the changeset; S1 — the changeset now states the condition as "the
dialog handed its controls no record" and names what now resolves
(option visibility, `dependsOn` gates, dependent-lookup filters, a money
field's followed currency); N1 — a `win_reason` mirror pin. Dialog file
12/12; `@object-ui/fields` 5021 passed; type-check 0; 38/38 derived
gates exit 0. Follow-up for host refusal rows: #37270.
Host refusal rows (refusal-named fields with no `record`) are carried by
#37270.
## Provenance
Opened by seat repo:objectstack#4 on the maintainer's authorization in
the seat session (「#37250(推送被拦):放行」). The seat's os-dev subagent's first
push was refused by its permission check; it stopped without retrying.
Branch `claude/issue-37250-fill-in-dialog-pending-values` @
`57e988ac224`.
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(fields): the required-fields fill-in dialog hands its controls the record the change would leave
6
+
7
+
Clause-②: yes (widening)
8
+
Metadata-protocol: none
9
+
10
+
A change made in place (a stage move on the record page, a list cell, an inline edit, a kanban drop) can make another field required. The fill-in dialog then asks for that field. The dialog handed its controls no record, so every control that reads the record judged it on an empty one. Any option `visibleWhen` that read a record field was judged without that field. A condition guarded by `has(record.x)` was false, so the option was hidden. A condition without that guard could not be evaluated, and the option was offered whatever the condition said. A choice field whose options were all hidden showed "No options available", and the change could not be saved. Example: each loss reason is shown only while the stage is "closed lost", so moving an opportunity to "closed lost" asked for a loss reason and offered none. Every option list gated by `dependsOn`, and every dependent lookup, stayed on its "select the parent first" gate.
11
+
12
+
The dialog now hands every control the record as the write would leave it: the saved record, with the change and the values typed into the dialog so far applied on top. What reads that record now resolves on it:
13
+
14
+
- option visibility;
15
+
-`dependsOn` gates on option lists and lookups;
16
+
- dependent-lookup filters;
17
+
- the currency of a money field that takes its currency from the record or from a parent record.
18
+
19
+
Each option is now shown or hidden by its condition on the record the write would leave. If the condition is true on that record, the option is shown. If it is false, the option is hidden. This includes an option the dialog used to offer only because its condition could not be evaluated on an empty record. For example, an unguarded `record.stage == "closed_lost"` used to be offered whatever the stage. It is now hidden when the stage stays "negotiation". So in an app whose option conditions do not guard with `has()`, the dialog can offer fewer options than before. A condition that still cannot be evaluated on that record is still offered, for example one that names a field the record does not carry. An option that depends on another value typed into the dialog appears once that value is typed. Which fields the dialog asks for was already decided on this record and does not change.
20
+
21
+
Widening: the exported `RequiredWhenPromptField` type gains one optional member, `record?: Record<string, unknown>`. That is the record the field was judged against. `collectRequiredWhenPromptFields` sets it on every field it returns, and `RequiredFieldsDialogField` inherits it. The dialog passes it, with the typed values, to every control as `dependentValues`. A row a host builds itself (a field a refusal names) carries no `record`. It reads the record of another field shown in the dialog. When no shown field carries one, it reads only the typed values.
0 commit comments