Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/39658-unit-titled-by-label.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/platform-objects': patch
---

fix(platform-objects): a unit of measure is titled by its label, not its code

Clause-②: no
Metadata-protocol: none

`sys_unit` now declares `label` as its title field (`nameField` and `displayNameField`), where it declared `code`. An admin who creates a unit 斤 with code `JIN1` now sees 斤 in the "created" message, the record header, list titles and pickers, instead of `JIN1`. A quantity still stores and names its unit by code; only the unit row's own title changes. `sys_standard_unit_setting` and `sys_exchange_rate` keep their code titles.
8 changes: 8 additions & 0 deletions packages/platform-objects/src/system/sys-unit.object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ describe('sys_unit — declaration (ADR-0158 U3)', () => {
expect(SysUnit.pluralLabel).toBe('Units of Measure');
});

it('is titled by its label, the human name, never by its code (ADR-0079)', () => {
// The toast on create and every face that shows a record title read the
// declared title field: a unit 斤 coded JIN1 must read 斤 there.
expect(SysUnit.nameField).toBe('label');
expect(SysUnit.displayNameField).toBe('label');
expect(fields.label.required).toBe(true);
});

describe('uniqueness', () => {
const uniqueIndexes = (SysUnit.indexes ?? []).filter((i: any) => i.unique);

Expand Down
4 changes: 2 additions & 2 deletions packages/platform-objects/src/system/sys-unit.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ export const SysUnit = ObjectSchema.create({
description:
"The organization's own units of measure, beside the standard units every organization has — " +
'one row per unit, named by a code in the organization namespace.',
displayNameField: 'code',
nameField: 'code', // [ADR-0079] canonical primary-title pointer (mirrors deprecated displayNameField)
displayNameField: 'label',
nameField: 'label', // [ADR-0079] canonical primary-title pointer (mirrors deprecated displayNameField)
highlightFields: ['code', 'label', 'dimension', 'ratio', 'retired'],

fields: {
Expand Down
Loading