Submission generator: improved party selector (pick from project's parties) + import-from-project affordance #109
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
m's report (2026-05-25 16:22)
Scope — two related improvements to the submission draft editor
A. Import-from-project affordance
When the draft is attached to a project (the normal case), pre-fill variables from the project's metadata automatically AND surface an explicit "Aus Projekt importieren" button so the lawyer can re-pull if data is stale.
Current state (per t-paliad-238 Slice A + brunel #84):
SubmissionVarsService.Resolvewalks project + parties + rule at preview time and emits the bag. Already auto-populates. m wants this to be MORE explicit + easier to refresh.UI: top of the variable sidebar, a small "Aus Projekt importieren" button + last-imported-at timestamp. Clicking refreshes every project-derived variable to the current DB state. Lawyer-set overrides are NOT touched (variables.jsonb keeps its merge precedence).
B. Improved party selector — pick from project's parties
Projects can have multiple parties (claimants, defendants, intervenors, …). The submission may mention ONE primary claimant, ONE primary defendant, OR a subset of multiple. m's ask: a selector that lists every party on the project and lets the lawyer pick which to mention in this specific submission.
UI: a multi-select party picker block in the variable sidebar (replaces or augments the current
{{party.claimant.name}}/{{party.defendant.name}}flat slots):{{party.claimants}}= comma-joined names of all selected claimants{{party.defendants}}= comma-joined names of all selected defendants{{party.claimant.0.name}},{{party.defendant.0.name}}, etc. for indexed access (templates that want the primary){{party.claimant.name}}continues to resolve to the FIRST selected claimant for backwards compat (deprecated, but kept)Underlying data shape
paliad.partiesalready exists (project-scoped). The current submission render reads the first claimant + first defendant.selected_parties uuid[]column topaliad.submission_drafts(default = all parties on the project, lawyer can deselect). Migration 12X.SubmissionVarsServiceconsumesselected_partiesand emits the multi-shape bag.What to do
paliad.submission_drafts.selected_parties uuid[] DEFAULT '{}'::uuid[](empty = all).SubmissionVarsService.Buildconsumesselected_parties. If empty → include all parties on the project. If non-empty → only the selected ones.POST /api/.../drafts/{id}/import-from-project(Idempotent re-pull; updateslast_imported_at) + party selection PATCH on the existing draft endpoint.Files most likely touched
internal/db/migrations/12X_submission_drafts_party_selection.up.sqlinternal/models/models.go—SubmissionDraft.SelectedParties []uuid.UUIDinternal/services/submission_vars.go— multi-party bag shapeinternal/services/submission_draft_service.go— selection update + import refreshinternal/handlers/submission_drafts.go— endpointsfrontend/src/submission-draft.tsx+client/submission-draft.ts— new picker block + import buttonfrontend/src/client/i18n.ts+frontend/src/i18n-keys.tsfrontend/src/styles/global.css— picker stylingHard rules
selected_parties) keep rendering as before (all parties included by default).{{party.claimant.name}}(old shape) continue to get the first claimant.go build ./... && go test ./internal/... && cd frontend && bun run buildclean.mai/<worker>/submission-party-selector-project-import.Out of scope
Reporting
mai report completedwith branch + SHAs + migration slot + UX path: open a draft → see project's parties listed with role chips → de-select an intervenor → confirm preview re-renders without their name → click "Aus Projekt importieren" → confirm timestamps update + variables refresh.SHIPPED on
mai/artemis/gitster-submission@4fc3005Commit
What's in
Schema (mig 131 — slot reservation per paliadin head-up, m/paliad#96 takes 129, m/paliad#108 takes 130):
paliad.submission_drafts.selected_parties uuid[] DEFAULT '{}'::uuid[]— empty = include every party (legacy default), non-empty = restrict to subset.paliad.submission_drafts.last_imported_at timestamptz NULL— bumped on each "Aus Projekt importieren" click.Backend:
SubmissionVarsContextgainsSelectedParties;filterPartiesBySelectionrestricts before role bucketing.addPartyVarsemits three coexisting forms per role:{{parties.claimants}},{{parties.claimants.representatives}}(skips empty reps from join), same fordefendants/others.{{parties.claimant.0.name}},{{parties.claimant.0.representative}},{{parties.defendant.0.name}}, etc.{{parties.claimant.name}}resolves to the first selected claimant — kept forever per the issue's backward-compat contract.SubmissionDraftService.ImportFromProjectstrips overrides forproject.*/parties.*/deadline.*/procedural_event.*/rule.*prefixes and bumpslast_imported_at.firm.*/today.*/user.*overrides survive (those aren't project-derived). Rejects project-less drafts withErrInvalidInput→ 400.POST /api/submission-drafts/{id}/import-from-project.DraftPatch+ project-scoped PATCH + global PATCH all acceptselected_parties.submissionDraftViewnow shipsavailable_partiesso the editor renders the picker in one round-trip (no extraGET /api/projects/{id}/partiesneeded).Frontend (
submission-draft.tsx+client/submission-draft.ts):selected_parties. Re-checking everything writes back as[]so a future party added to the project gets picked up automatically.submissions.draft.import.button,submissions.draft.parties.title,submissions.draft.parties.hint.global.css.Tests
6 new unit tests in
internal/services/submission_vars_parties_test.go:TestAddPartyVars_MultiPartyMixedRoles— pins all 3 forms (joined, indexed, flat) with mixed roles + empty representatives.TestAddPartyVars_GermanRoleStrings— confirmsKlägerin/Beklagterbucket correctly.TestAddPartyVars_BackwardCompatFlatAliasResolvesFirstRow— pins the m/paliad#109 backward-compat contract.TestFilterPartiesBySelection_EmptyMeansAll— bothniland[]uuid.UUID{}mean "include every party".TestFilterPartiesBySelection_NonEmptyRestricts— subset selection preserves input order.TestIsProjectDerivedKey— covers the import-from-project policy (project/parties/deadline/procedural_event/rule are derived; firm/today/user survive).Build hygiene
go build ./...✅go vet ./...✅go test -short ./internal/...✅ (6 new tests pass, no regressions)bun run build✅ (2876 i18n keys, data-i18n scan clean)gofmt -wapplied to touched files.UX path (after head merge)
Open any project with multiple parties → Schriftsätze → pick a draft → see the party picker in the sidebar with role chips → de-select an intervenor → confirm preview re-renders without their name in
{{parties.others}}→ click "Aus Projekt importieren" → confirm timestamp updates and project-derived variables refresh (user-typed firm/user overrides survive).Out of scope (per issue body)
/projects/{id}/partiestab).Not self-merged. Awaiting head.