diff --git a/.changeset/39658-unit-titled-by-label.md b/.changeset/39658-unit-titled-by-label.md new file mode 100644 index 00000000000..e6e8af80a87 --- /dev/null +++ b/.changeset/39658-unit-titled-by-label.md @@ -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. diff --git a/packages/platform-objects/src/system/sys-unit.object.test.ts b/packages/platform-objects/src/system/sys-unit.object.test.ts index 2f773fd6ed8..f9b49eba425 100644 --- a/packages/platform-objects/src/system/sys-unit.object.test.ts +++ b/packages/platform-objects/src/system/sys-unit.object.test.ts @@ -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); diff --git a/packages/platform-objects/src/system/sys-unit.object.ts b/packages/platform-objects/src/system/sys-unit.object.ts index 101ee46b049..237c06a425e 100644 --- a/packages/platform-objects/src/system/sys-unit.object.ts +++ b/packages/platform-objects/src/system/sys-unit.object.ts @@ -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: {