Repository navigation
Commit f71d488
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg8ZBQe4UHadd2fGHGeWRW9V)_
repo:objectstack#5 · os-bill · session_01Utp6CbdHk3orAeensH6EzS
Fixes #35490
Fixes #37471
Clause-②: yes (widening)
Metadata-protocol: added
## What
A quantity (`unitConfig` on a `number` field) now renders with its unit
on every display face: the grid cell, the form (read-only and edited),
and the detail row (DetailSection, the quick-look panel, RelatedList). A
unit-code `text` field (`unitMode: 'code'`) shows its unit's name (Open
item 8 (A)).
- **Choosing a unit (Open item 8, ruled A: 「有下拉」, #37471).** In a form,
a unit code field is a searchable picker (`UnitCodeField`), never a
typed box. That covers a `text` field declaring `unitMode: 'code'` and
the `unitField` a `record` quantity on the same form points at; the form
stamps that pointer (`withUnitCodePointer`) and hands the field its
record. The picker lists the record's organization's non-retired
`sys_unit` rows, then every standard code, each by its translated name
(spec fallback) and limited to the declared `unitDimension`. It stores
the code. Read-only, the field shows the unit's name, not the bare code.
- **Authorable key (`Metadata-protocol: added`).** `unitConfig` is now
declared on `@object-ui/types`' `FormField` / `FormFieldSchema`, by
reference to the spec's `FieldSchema.unitConfig`, beside
`currencyConfig`, so `objectui validate` accepts it on a hand-authored
form field. `@object-ui/types` ships `minor` (the `scale` /
`currencyConfig` precedent). The tolerant face now checks the key's
value against `UnitConfigSchema` where it passed as an unknown key
before.
- **Which unit.** Fixed mode uses `unitConfig.unit`. Record mode reads
the row's `unitField`. Grid, ListView and RelatedList add the unit
column and `organization_id` to their `$select` when the unit column is
not shown.
- **Name.** An org unit (`sys_unit`, U3) shows its `label`. A standard
code shows the platform's name for it in the reader's locale (L2, 2A):
the spec English base `STANDARD_UNIT_NAMES`, and each platform bundle
serves `messages.standardUnit<CODE>`. The UI reads
`app.messages.standardUnit<CODE>` and falls back to the English base.
- **Decimals.** These come from the unit row (org unit `decimal_places`,
or the `sys_standard_unit_setting` row for a standard code, OI10 (A)).
The row is the one whose `organization_id` matches the record's
organization (note 7180167601). L4 holds: the display width is `min(unit
places, field scale)`.
- **Rounding (OI6, ruled A).** The display rounds half away from zero
(Intl `halfExpand`) at a fixed width. The stored value, footer totals
(summed exact, then formatted), exports, the API and MCP stay exact. No
marker is shown.
- **Bare code.** A retired ("deleted") org unit, an unknown code, or a
reader who may not read `sys_unit` (an external member, comment
7030066814) gets the bare code, never an error.
The rows are read once per data-source adapter for the session (the
`homeAmountPreview` precedent). Each table is read on its own, so a
refusal of one leaves the other usable.
## Server-side home of the names (measured)
The platform-objects translation bundles, flat `messages` map, with
single-segment keys `standardUnit<CODE>`. The keys are not dotted
`units.standard.<CODE>` because `FileI18nAdapter.resolveKey` splits on
`.` and walks the parts as nesting (the plugin-audit precedent). The
console's served document lays bundles under `app`, so the UI key is
`app.messages.standardUnit<CODE>`. English is copied from the spec base,
never re-typed. Ten locales are translated, and a pin test holds every
locale to exactly the 41 codes.
## Acceptance notes
- **platform-catalog row:** deferred to #37431 (`skills/**` fence).
- **Standalone `ObjectGrid` with no `SchemaRendererContext`:** there is
no data source, so no unit rows are read. Codes show bare at the field's
own width. This known limit is pinned in
`gridQuantityUnit-35490.test.tsx`.
- **English names are singular,** e.g. `1,235 kilogram`.
- **The catalog is cached per adapter for the session.** A unit edited
mid-session shows after a reload. A failed read stays unread for the
session; this is deliberate, because an external member's refusal is
permanent and re-reading per mount would cost a request per grid cell.
Follow-ups N4/N5 are on #37472.
- **Grid and detail cells of a pointed unit field** show the stored
code. The pointer is stamped on the form face, where the quantity and
its unit field sit together.
- **Known overlap with #37436 (#36806).** Both PRs edit the `const
extraFields = [...]` line in
`ui/packages/plugin-grid/src/objectGridRowLoad.ts`: this PR appends
`...quantityUnitFields`, and #37436 inserts `...lockOperandFields`.
Whichever lands second merges main and keeps both entries.
## Verification
- Card tests: core 21, fields 26, components form, plugin-grid 2,
plugin-list, plugin-detail 3. green; the fields, core, components-form
and schema-catalog suites (13,000+ tests) pass on the picker head. spec
`standard-units` 18/18; platform-objects translations 613/613.
- Ablations, each restored to blob == HEAD:
- resolver → 24/52 red;
- org-row pick → 8/48 red;
- served-name read → 1/26 red (the zh served-name case);
- picker's retired-unit filter → 4/56 red;
- form pointer stamp → 1/2 red;
- TextField's picker branch → 3/30 red.
- Typecheck: spec, platform-objects and fields are clean.
`check:api-surface` was regenerated (2 added exports).
- Gates: `check-i18n-bundles`, `check-i18n-stale-fill` and
`check-i18n-walk-parity` pass. `check-published-readme-exports` passes.
- `overlap-check`: clean against main, #37437, #37436 and #37427.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CXM7nqtiQ3M9JqGAqL
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CbdHk3orAeensH6EzS -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent df0894a commit f71d488
46 files changed
Lines changed: 2576 additions & 44 deletions
File tree
- .changeset
- content/docs/frontend
- packages
- platform-objects/src/apps/translations
- spec
- api-surface
- export-origins
- src/data
- ui/packages
- components/src/renderers/form
- __tests__
- core/src
- utils
- __tests__
- fields
- src
- __tests__
- widgets
- plugin-detail/src
- __tests__
- plugin-grid/src
- __tests__
- plugin-list/src
- __tests__
- types/src
- __tests__
- zod
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
87 | 117 | | |
88 | 118 | | |
89 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
0 commit comments