Repository navigation
Commit 77edd2a
fix(plugin-grid): phone card amount slot takes a formula or summary that draws as money (#38100)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoJgGMcVYe3tSvxAWdknWFST)_
Fixes #37890
repo:objectstack#3 · os-tesla · session_01L9qibvqGhhENZcAuiMxqA7
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 手机上看订单行、报价行这类明细列表时,卡片右下角的金额现在显示这一行的总额,不再错显示单价;电脑上的表格不变。
- 属于手机端列表卡片的体验线,替 HotCRM 等有明细行的应用解决金额读错的问题。
- 只改卡片挑哪一列当金额,数据和接口都不变;若挑错,最多是卡片上金额位置显示另一列,可以直接撤回。
- 无
## What changes
- `ui/packages/plugin-grid/src/ObjectGrid.tsx`,
`buildMobileCardRenderer`: the amount slot now takes the first shown
body column whose value draws as money. That is a `currency` column, or
a `formula` / `summary` column for which
`resolveFormulaValueType(fieldDef, number)` (the exported
`@object-ui/fields` rule the formula cell draws by) answers `currency`:
a formula declaring `returnType: 'currency'`, or a summary declaring its
currency (`currencyConfig`). The slot is still chosen once for the list,
so every card keeps one shape.
- Unchanged: a masked column is not promoted; a view that presents the
field as another type (column `type`) keeps it a plain value; a
number-returning formula is not an amount; view order still picks among
several money columns; desktop table untouched.
- No new export (seat ruling: option A). `patch` changeset for
`@object-ui/plugin-grid`.
## Why
On a phone, an order line (2 × 6,000.00, 10% off) showed its unit price
6,000.00 in the amount slot; the line total 10,800.00 is a formula
returning currency, which the slot never considered. Reordering columns
did not help: the total moved into the subtitle.
## Tests
`ui/packages/plugin-grid/src/__tests__/phoneCardAmount-34615.test.tsx`,
a new top-level `describe` in the existing harness (390 px):
- currency formula shown before the unit price → amount `CN¥10,800.00`,
subtitle `2 · CN¥6,000.00`;
- currency formula as the only money column → amount `CN¥10,800.00`;
- summary declaring its currency → amount `CN¥777.00`;
- unit price shown first stays the amount (view order unchanged);
- CONTROL: number-returning formula → no amount line;
- CONTROL: the currency formula presented as `type: 'text'` → no amount
line.
<details><summary>Readings (head f800825 = b4dd4f2 + merge of
origin/main 815e882..f72f335)</summary>
- New describe at b4dd4f2: `Tests 11 passed (11)` for the harness file.
- Ablation on the committed fix (ObjectGrid.tsx restored from base
815e882, tree only, then restored from HEAD; `drawsAsMoney` count 0 → 2
on disk): `Tests 3 failed | 8 passed (11)`. The three red are exactly
the predicted RED directions; both CONTROLs and all five #34615 cases
stay green.
- After merging origin/main (which brought #37929, also in plugin-grid)
and rebuilding the closure (`turbo run build
--filter='@object-ui/plugin-grid^...'`, 57/57): `pnpm --filter
@object-ui/plugin-grid type-check` exit 0; `pnpm --dir ui exec vitest
run packages/plugin-grid/`: `Test Files 319 passed (319)`, `Tests 2805
passed (2805)`.
- eslint on the two changed files: 0 errors (155 warnings, none on the
changed hunk).
- `dispatch-gates --ran` at b4dd4f2: 39 derived, 39 run, all exit 0, 0
NOT MEASURED, 0 unrun.
</details>
## Acceptance notes
- Premise measured on origin/main 815e882 before writing (390 px probe,
readings on the card's pre-claim report): unit price first → slot
`CN¥6,000.00`; total first → slot still `CN¥6,000.00`, total in
subtitle; formula-only or summary-only → no slot, though the cell
already drew currency.
- `#37929` and `#37924` also touch `ObjectGrid.tsx`, in hunks far from
this one; whichever lands later merges main.
## Verification
Read first (by risk):
1. `ObjectGrid.tsx`: `drawsAsMoney` and the `amountCol` line under it.
2. The new `describe` in `phoneCardAmount-34615.test.tsx`, especially
the two CONTROL cases.
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-grid/src/__tests__/phoneCardAmount-34615.test.tsx` shows
11 passing; replace `drawsAsMoney(c)` with `c.type === 'currency'` and
the same command shows 3 failing.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the two
changed files: 0 errors)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibvqGhhENZcAuiMxqA7)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent bbe4258 commit 77edd2a
3 files changed
Lines changed: 130 additions & 5 deletions
File tree
- .changeset
- ui/packages/plugin-grid/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
4429 | 4429 | | |
4430 | 4430 | | |
4431 | 4431 | | |
4432 | | - | |
4433 | | - | |
4434 | | - | |
| 4432 | + | |
| 4433 | + | |
| 4434 | + | |
4435 | 4435 | | |
4436 | 4436 | | |
4437 | 4437 | | |
| 4438 | + | |
| 4439 | + | |
| 4440 | + | |
| 4441 | + | |
| 4442 | + | |
| 4443 | + | |
| 4444 | + | |
| 4445 | + | |
| 4446 | + | |
| 4447 | + | |
| 4448 | + | |
| 4449 | + | |
| 4450 | + | |
| 4451 | + | |
| 4452 | + | |
4438 | 4453 | | |
4439 | | - | |
| 4454 | + | |
4440 | 4455 | | |
4441 | 4456 | | |
4442 | 4457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 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 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
0 commit comments