Skip to content

Add units (enheter), imported from the authoritative source - #30

Merged
RonnyB71 merged 2 commits into
mainfrom
feat/units
Nov 1, 2026
Merged

RonnyB71 merged 2 commits into
mainfrom
feat/units

Conversation

@RonnyB71

@RonnyB71 RonnyB71 commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Models units (divisjon, avdeling, seksjon) as the basis for the organisation chart and the unit pages. This covers the structure only. What a unit leader maintains in Saman, such as the mandate (LO-03, LO-04), comes later.

Requirements: LO-01, LO-02 (except the mandate), FO-02, NF-07

Specification (own commit)

  • 4.2 data model: Enhet ||--|| Enhet ("exactly one to exactly one") becomes Enhet }o--o| Enhet. A unit belongs to at most one parent unit and can have zero or more sub-units.
  • 4.1: a unit's name, level, parent unit and leader come from the authoritative source.
  • FO-02: «enheten eller enhetene i linjen» ("the unit or units in the line organisation"). A person can belong to more than one unit, as the data model already showed.
  • An entry in decisions.md.

Collection enheter (units)

Field Content
externalUnitId The source's ID, unique. The import matches on it
name, code Name, and a short code where the unit has one («SSR»)
level division / department / section, shown as Divisjon / Avdeling / Seksjon
externalParentId → parent The parent unit, as an ID from the source and a relationship. Empty for divisions
externalLeaderId → leader The unit leader, as its own field from the source (the person's externalId)
active false for a closed unit, which is kept so its history isn't lost
children, people Joins: sub-units, and the people in the unit

personer gets externalUnitIds and units, both of which can hold more than one unit.

Access: the same as personer and lokasjoner. Anyone logged in can read. Nobody can create, change or delete units through the admin panel or the API, not even administrators. Only the import, which uses the Local API, can. That's why there's no add button.

The import itself isn't part of this PR. Units come in a file of their own. The import will match on externalUnitId and set parent, leader and people's units from the external IDs once everything exists, the same pattern as manager and location on personer.

Tests

  • New tests/int/units.int.spec.ts covers:
    • default values and unique externalUnitId
    • a required, valid level
    • the hierarchy with sub-units
    • the leader, and the people in a unit
    • a person in two units
    • reading with and without login
    • no changes by users, not even administrators
  • Results: pnpm lint passes. pnpm test: CMS 36 passed, web 15 passed. I didn't run e2e locally (the dev servers are in use); CI runs it.

🤖 Generated with Claude Code

RonnyB71 and others added 2 commits November 1, 2026 20:42
A unit has at most one parent and any number of sub-units (4.2 said one
to one), its name, level, parent and leader come from the authoritative
source (4.1), and an employee can belong to more than one unit (FO-02).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Divisions, departments and sections (LO-01), each with at most one
parent, its sub-units, a leader and its people (LO-02). Like people and
locations they come from Digdir's authoritative source (NF-07), from a
file of their own, so only the import can create or change them. A person
can belong to more than one unit (FO-02).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RonnyB71
RonnyB71 merged commit 6d6ff32 into main Nov 1, 2026
6 checks passed
@RonnyB71
RonnyB71 deleted the feat/units branch November 1, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant