Repository navigation
Commit bf95e78
fix(platform-objects): title a unit of measure by its label, not its code (#39712)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D6q8dUDEiRaQSo6oAsacVv3)_
Fixes #39658
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:管理员在设置里新建计量单位「斤」(编码 JIN1)后,成功提示、记录标题、列表标题和选择框都显示「斤」,不再显示编码
JIN1。
- 为什么做:属于计量单位这组工作,替设置管理员解决「新建单位后看到的是机器编码」的问题。
- 出错会怎样:只影响自定义计量单位记录的标题显示,数量字段仍按编码存储和引用,改回原样即可直接撤回。
- 要你做什么:无。
## What changes
`sys_unit` declared `code` as its title (`nameField` and
`displayNameField`). Both now name `label`, the required "name shown
beside a quantity in this unit". This follows `sys_email_template` and
`sys_personal_view`, and matches ADR-0079's "a record's human name". A
quantity still stores and names its unit by code (ADR-0158 U4); only the
unit row's own title changes. `sys_standard_unit_setting` and
`sys_exchange_rate` are untouched, and so is item 12b (the ratio's
12-decimal display).
Nothing reads `sys_unit`'s title as a code. No reference field points at
`sys_unit`, and the console's unit display
(`ui/packages/core/src/utils/unit-display.ts`) reads the `label` column
by name, not through the title pointer. No test pinned `code` as the
title. No generated artifact carries these two declarations.
**Read first** (by risk):
1. `packages/platform-objects/src/system/sys-unit.object.ts` lines
125-126: the two-pointer change.
2. `packages/platform-objects/src/system/sys-unit.object.test.ts`: the
new pin, which also asserts that `label` stays required, so the title
can never be empty.
**Two-minute check:** `pnpm --filter @objectstack/platform-objects exec
vitest run --maxWorkers=2 src/system/sys-unit.object.test.ts` should
report 31 passed. In a running console, create unit 斤 (code JIN1): the
toast should read 「计量单位"斤"已创建」.
## Tests
- Pin test: `sys_unit` is titled by `label` (`nameField`,
`displayNameField`), and `label` is required.
- Ablation: I reverted `nameField` to `'code'` on disk, and the pin
turned red (`Expected: "label"`, `Received: "code"`, 1 failed / 30
passed). Then I restored it.
<details><summary>Package suite and typecheck, at f577f2f</summary>
- `pnpm --filter @objectstack/platform-objects test`: Test Files 137
passed (137), Tests 2458 passed (2458), command-exit 0 under
os-verify-lock. The package was built first: its own suite self-imports
`@objectstack/platform-objects/system` from `dist`, and the first run
without that build failed on exactly that import.
- `pnpm --filter @objectstack/platform-objects typecheck`: exit 0
(`check:test-typecheck: OK`).
- `pnpm --filter '@objectstack/platform-objects^...' build`: dependency
closure built.
</details>
## Acceptance notes
- The object's `description` still says "named by a code in the
organization namespace". That describes the code namespace, not the
title. It is outside this card's file surface and I left it unchanged.
## Verification
<details><summary>Derived gate subset (dispatch-gates --commands, at
f577f2f)</summary>
- 65 derived, 57 run with exit 0, 8 NOT MEASURED, 0 UNRUN
(`dispatch-gates --ran`: `65 derived famil(ies) accounted for`).
- NOT MEASURED, exit 3 PREREQUISITE NOT MET:
`check:dual-build-cjs-loads` and `check:lean-entry-closure` (they need a
workspace-wide `dist`), `check:i18n` (the CLI is not built),
`check-plugin-teardown-shape --self-test` (shallow clone). CI runs
these.
- NOT MEASURED, exit 124 (killed by timeout on a shared box, no verdict
printed): `check-comment-mask-corpus`, `check:query-options-erasure`,
`check:slot-lookup`, `check:type-check-debt`. CI runs these.
- `check:nul-bytes`: exit 0.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4d1cnRvyiAqrarmDhZV
<!-- signed: repo:objectstack@os-elon-musk · os-elon-musk ·
session_016WV4d1cnRvyiAqrarmDhZV -->
Co-authored-by: Claude <noreply@anthropic.com>1 parent 758cd97 commit bf95e78
3 files changed
Lines changed: 20 additions & 2 deletions
File tree
- .changeset
- packages/platform-objects/src/system
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | | - | |
| 125 | + | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
0 commit comments