Multi-select party picker on the dedicated submission draft editor —
lawyer picks which of the project's parties to mention in this
specific submission. Adds the t-paliad-277 variable-bag multi-party
shape ({{parties.claimants}}, {{parties.claimant.0.name}}) while
keeping the legacy flat aliases ({{parties.claimant.name}}) for every
existing .docx template authored before the rename.
Surfaces an explicit "Aus Projekt importieren" button + last-imported
timestamp at the top of the variable sidebar so the lawyer can re-pull
project-derived variables (project.*, parties.*, deadline.*,
procedural_event.*, rule.*) when the project data drifts away from the
saved draft overrides. firm.*, today.*, user.* overrides survive the
import — those values aren't sourced from the project record.
Schema: mig 131 adds two columns to paliad.submission_drafts:
- selected_parties uuid[] DEFAULT '{}'::uuid[]
Empty = include every party (legacy default).
Non-empty = restrict to the subset, grouped by role at substitution.
- last_imported_at timestamptz NULL
Bumped each "Aus Projekt importieren" click; surfaced in UI.
Backend:
- SubmissionVarsContext gains SelectedParties — filterPartiesBySelection
restricts the resolved bag before role bucketing.
- addPartyVars emits THREE coexisting forms per role: comma-joined
(parties.claimants), indexed (parties.claimant.0.name), and flat
legacy (parties.claimant.name → first selected claimant). Flat
aliases are kept forever per the issue's backward-compat contract.
- SubmissionDraftService.ImportFromProject strips overrides for
project-derived prefixes and bumps last_imported_at; rejects
project-less drafts (nothing to import from).
- New endpoint POST /api/submission-drafts/{id}/import-from-project.
- DraftPatch + PATCH handlers accept selected_parties.
- submissionDraftView now ships available_parties so the editor can
render the picker without an extra round-trip.
Frontend:
- submission-draft.tsx: new import-row + parties block in the sidebar.
- client/submission-draft.ts: paintImportRow / paintPartyPicker /
onPartySelectionChange / onImportFromProject; group parties by
role bucket (claimant / defendant / other) with DE+EN role-string
matching to mirror the backend bucketing.
- 3 new i18n keys (DE+EN): import.button, parties.title, parties.hint.
- CSS for the picker + import row in global.css.
Tests: 6 new unit tests in submission_vars_parties_test.go covering
the multi-party bag emission, German role-string bucketing, flat-alias
first-of-role resolution, empty-selection-means-all default, non-empty
restriction, and the isProjectDerivedKey policy that powers the
import path.
Build hygiene: go build/vet clean; go test -short ./internal/... pass;
bun run build clean (2876 i18n keys, scan clean).
33 lines
1.9 KiB
SQL
33 lines
1.9 KiB
SQL
-- t-paliad-277 / m/paliad#109: per-draft party selection + import provenance.
|
|
--
|
|
-- Adds two columns to paliad.submission_drafts:
|
|
--
|
|
-- selected_parties uuid[] — IDs of paliad.parties rows the lawyer
|
|
-- has chosen to mention in this specific submission. An empty
|
|
-- array (the default) means "include every party on the project"
|
|
-- so all existing drafts keep their current rendering. Non-empty
|
|
-- restricts the variable bag to the chosen subset, grouped by
|
|
-- role in SubmissionVarsService.
|
|
--
|
|
-- last_imported_at timestamptz — when the lawyer last clicked
|
|
-- "Aus Projekt importieren" on the draft editor (or NULL if they
|
|
-- never did). The frontend surfaces this timestamp next to the
|
|
-- button so a stale draft is obvious at a glance.
|
|
--
|
|
-- Both columns are purely additive and nullable / default-bearing —
|
|
-- the migration is safe to apply with active drafts in the table.
|
|
-- No FK on selected_parties: paliad.parties is project-scoped and we
|
|
-- prune stale references on read inside SubmissionVarsService rather
|
|
-- than chasing FK cascades across two tables (the variable bag silently
|
|
-- drops any uuid that no longer matches a row in paliad.parties).
|
|
|
|
ALTER TABLE paliad.submission_drafts
|
|
ADD COLUMN IF NOT EXISTS selected_parties uuid[] NOT NULL DEFAULT '{}'::uuid[],
|
|
ADD COLUMN IF NOT EXISTS last_imported_at timestamptz;
|
|
|
|
COMMENT ON COLUMN paliad.submission_drafts.selected_parties IS
|
|
't-paliad-277: party IDs (paliad.parties) the lawyer has chosen to mention in this submission. Empty array = include every party on the project (backward-compat default). Non-empty = restrict to subset, grouped by role.';
|
|
|
|
COMMENT ON COLUMN paliad.submission_drafts.last_imported_at IS
|
|
't-paliad-277: timestamp of the last "Aus Projekt importieren" click — surfaced next to the button so the lawyer can see staleness at a glance. NULL = never imported.';
|