feat(dimensions): show the value's name after picking, and let an unused custom dimension be deleted (#2219) (#2255)
* feat(dimensions): show the value's name after picking, and let an unused custom dimension be deleted (#2219) Two things from the same Discord report, both in bookkeeping from the transaction view: 1. After picking a kostnadsställe the field showed only the code ("1"). DimensionCombobox now writes the value's full name under the field once a code is committed, exactly as AccountCombobox does for the account name (looked up in the full registry so an archived code stays readable). The input text itself stays the code: the blur/revert logic keys on it. 2. A self-created dimension could not be removed at all: the DB already allowed it (enforce_dimension_registry_guards lets a non-system dimension go when no posted/reversed line carries its number, and the value retention trigger fires on the cascade), but no route or UI asked. New DELETE /api/dimensions/[id]: 400 DIMENSION_SYSTEM_DELETE for kostnadsställe/projekt, the guard's own Swedish P0001 verbatim as 409 DIMENSION_REFERENCED, 404, and a happy path; the register gets a quiet "Ta bort dimension" link for the active custom dimension behind a DestructiveConfirmDialog. Keys added to sv and en. Closes #2219 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VnConrmMCxJRQ5kfiPPWyy * test: satisfy the TypeScript ratchet for two test files main inherited from #2247 and #2242 accounts-route.test.ts built SyncResult literals without the requestedFromDate / historyNarrowed fields #2247 added (vitest does not typecheck, so it passed locally); fiscal-periods route.test.ts got two more one-argument POST(req) calls from #2242 in a file already at its ratchet baseline. Both files now typecheck; the ratchet runs clean. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VnConrmMCxJRQ5kfiPPWyy --------- Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
Jakob Wennberg
parent
2c3ffaf51c
commit
a48508e5b0
@@ -4130,6 +4130,31 @@ const DIMENSION: Record<string, StructuredErrorEntry> = {
|
||||
message_sv: 'Dimensionen kunde inte uppdateras.',
|
||||
message_en: 'Failed to update dimension.',
|
||||
},
|
||||
DIMENSION_SYSTEM_DELETE: {
|
||||
httpStatus: 400,
|
||||
message_sv: 'Systemdimensioner (kostnadsställe och projekt) kan inte tas bort: avaktivera dem istället.',
|
||||
message_en: 'System dimensions (kostnadsställe/projekt) cannot be deleted: archive (inactivate) them instead.',
|
||||
},
|
||||
// The DB registry guard (enforce_dimension_registry_guards) raises when any
|
||||
// posted/reversed line is tagged with the dimension's number, and the value
|
||||
// retention trigger fires on the cascade to dimension_values. Routes surface
|
||||
// the trigger's own Swedish message via `messageSv`.
|
||||
DIMENSION_REFERENCED: {
|
||||
httpStatus: 409,
|
||||
message_sv:
|
||||
'Dimensionen används på bokförda verifikat och kan inte tas bort: avaktivera den istället.',
|
||||
message_en:
|
||||
'The dimension is referenced by posted vouchers and cannot be deleted: archive (inactivate) it instead.',
|
||||
remediation: {
|
||||
description:
|
||||
'Archive the dimension instead: PATCH /api/dimensions/[id] with { "is_active": false }. Numbers tagged on posted lines are retained for the BFL 7-year period.',
|
||||
},
|
||||
},
|
||||
DIMENSION_DELETE_FAILED: {
|
||||
httpStatus: 500,
|
||||
message_sv: 'Dimensionen kunde inte tas bort.',
|
||||
message_en: 'Failed to delete dimension.',
|
||||
},
|
||||
DIMENSION_VALUE_NOT_FOUND: {
|
||||
httpStatus: 404,
|
||||
message_sv: 'Dimensionsvärdet kunde inte hittas.',
|
||||
|
||||
Reference in New Issue
Block a user