Halte Kapitel am gewaehlten Vorgang fest und raeume die Arbeitsflaeche, damit Ziel, Auswahl und Rechte nicht an der Akte haengen bleiben.
Deploy Development / deploy (push) Successful in 23s
Test Suite / pytest-backend (push) Successful in 1m1s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 5s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-17 11:33:54 +02:00
1 parent 67d48378c9
commit cafa4e8b92
8 files changed
+523 -132

No files matched your search

+91 -28
View File
@@ -1,4 +1,4 @@
import { useContext, useEffect, useState } from "react";
import { useContext, useEffect, useRef, useState } from "react";
import { Link, useNavigate, useParams, useSearchParams } from "react-router-dom";
import { api, markDirty } from "../api.js";
import { SessionContext } from "../session.js";
@@ -6,7 +6,7 @@ import { Modal } from "./Modal.jsx";
import { MailPicker, PaperlessPicker } from "./Sources.jsx";
import { ErrorNote, ShareBox } from "./widgets.jsx";
import { ChapterForm, FileForm, NoteForm } from "./Cases.jsx";
import { ContentBoard, ObjectMenu, Placements, RecordTree, SurfaceView, Trail, WorkLists, WorkSwitch, formatDate, matterOpenHref } from "./content.jsx";
import { ContentBoard, ObjectMenu, Placements, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, formatDate, matterOpenHref, writeChapter } from "./content.jsx";
function pageContext(params) {
const kind = params.get("context_kind");
@@ -87,7 +87,10 @@ function MatterOutline({ record, inherited, chapterId, onChapter }) {
return (
<nav className="outline-nav" aria-label="Gliederung">
<h2>Gliederung</h2>
<button type="button" className={chapterId ? "quiet" : ""} onClick={() => onChapter("")}>Alle Inhalte</button>
<button type="button" className={chapterId ? "hierarchy__row" : "hierarchy__row is-current"} onClick={() => onChapter("")}>
<span className="hierarchy__kind">Überblick</span>
<strong>Alle Inhalte</strong>
</button>
{hasParent ? (
<p className="hierarchy__parent">Übergeordnet: <Link to={`/matters/${record.parent_matter_id}${matterQuery}`}>Vorgang {record.parent_title}</Link></p>
) : null}
@@ -128,7 +131,7 @@ function MatterOutline({ record, inherited, chapterId, onChapter }) {
<ul className="hierarchy">
{record.chapters.map((chapter) => (
<li key={chapter.id}>
<button type="button" className={chapterId === chapter.id ? "hierarchy__row" : "hierarchy__row quiet"} onClick={() => onChapter(chapter.id)}>
<button type="button" className={chapterId === chapter.id ? "hierarchy__row is-current" : "hierarchy__row"} onClick={() => onChapter(chapter.id)}>
<span className="hierarchy__kind">Kapitel</span>
<strong>{chapter.title}</strong>
</button>
@@ -143,32 +146,69 @@ function MatterOutline({ record, inherited, chapterId, onChapter }) {
export function MatterDetail() {
const { id } = useParams();
const [params] = useSearchParams();
const [params, setParams] = useSearchParams();
const inherited = pageContext(params);
const chapterId = params.get("kapitel") || "";
const [record, setRecord] = useState(null);
const [error, setError] = useState("");
const [modal, setModal] = useState("");
const rightsContext = inherited || { kind: "matter", id };
const placement = inherited?.kind === "case" ? { kind: "matter", id } : null;
const [view, setView] = useState("contents");
const [chapterId, setChapterId] = useState("");
const [outlineOpen, setOutlineOpen] = useState(false);
const pendingChapter = useRef("");
async function load() {
const query = inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : "";
const detail = await api(`/api/v1/matters/${id}${query}`);
pendingChapter.current = "";
setRecord(detail);
return detail;
}
useEffect(() => {
let alive = true;
setRecord(null);
load().catch((err) => setError(err.message));
setError("");
setView("contents");
setModal("");
setOutlineOpen(false);
const query = inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : "";
api(`/api/v1/matters/${id}${query}`).then((detail) => {
if (!alive) return;
pendingChapter.current = "";
setRecord(detail);
}).catch((err) => {
if (alive) setError(err.message);
});
return () => { alive = false; };
}, [id, inherited?.kind, inherited?.id]);
useEffect(() => {
if (!record || record.id !== id) return;
const known = (record.chapters || []).some((chapter) => chapter.id === chapterId);
if (chapterId && !known && pendingChapter.current === chapterId) return;
if (chapterId && !known) writeChapter(params, setParams, "");
if (params.get("bereich")) {
const next = new URLSearchParams(params);
next.delete("bereich");
setParams(next, { replace: true });
}
}, [record, id, chapterId, params, setParams]);
function chooseChapter(next) {
writeChapter(params, setParams, next);
setView("contents");
setOutlineOpen(false);
}
if (error && !record) return <main className="page"><ErrorNote error={error} /></main>;
if (!record) return <main className="page"><p className="muted">Vorgang wird geladen …</p></main>;
const query = inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : "";
const targetLabel = `${record.kind_label || "Vorgang"} ${record.title}`;
const activeChapter = (record.chapters || []).find((chapter) => chapter.id === chapterId) || null;
const canEdit = Boolean(record.rights?.edit);
return (
<main className="page">
@@ -181,11 +221,12 @@ export function MatterDetail() {
<p className="muted">{record.status === "open" ? "Offen" : "Geschlossen"}</p>
</div>
<div className="row">
{record.rights.edit ? <button type="button" onClick={() => setModal("add")}>Inhalt hinzufügen</button> : null}
{canEdit ? <button type="button" onClick={() => setModal("add")}>Inhalt hinzufügen</button> : null}
<ObjectMenu view={view} onView={setView}>
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("submatter")}>Teilvorgang anlegen</button> : null}
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("cross")}>Querverweis</button> : null}
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("chapter")}>Kapitel anlegen</button> : null}
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("submatter")}>Teilvorgang anlegen</button> : null}
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("cross")}>Querverweis</button> : null}
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("chapter")}>Kapitel hinzufügen</button> : null}
{!canEdit ? <p className="muted">In {targetLabel} fehlt das Bearbeitungsrecht.</p> : null}
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
</ObjectMenu>
</div>
@@ -195,21 +236,32 @@ export function MatterDetail() {
<aside className={outlineOpen ? "outline is-open" : "outline"}>
<button type="button" className="outline__toggle" onClick={() => setOutlineOpen((open) => !open)}>{outlineOpen ? "Bereiche schließen" : "Bereiche"}</button>
<div className="outline__body">
<MatterOutline record={record} inherited={inherited} chapterId={chapterId} onChapter={(next) => { setChapterId(next); setView("contents"); setOutlineOpen(false); }} />
<MatterOutline record={record} inherited={inherited} chapterId={chapterId} onChapter={chooseChapter} />
</div>
</aside>
<div className="record-main">
<WorkSwitch view={view} onView={setView} />
{view === "contents" ? (
<ContentBoard
record={record}
context={inherited}
containerKind="matter"
containerId={id}
onlyChapter={chapterId}
onChange={load}
itemHref={(binding) => `/matters/${id}/items/${binding.id}${query}`}
/>
<>
<p className="target-line">
Bearbeitet wird <strong>{targetLabel}</strong>
{activeChapter ? <> · Kapitel <strong>{activeChapter.title}</strong></> : null}
</p>
<ContentBoard
record={record}
context={inherited}
containerKind="matter"
containerId={id}
onlyChapter={chapterId}
onChange={load}
itemHref={(binding) => {
const search = new URLSearchParams(query.replace(/^\?/, ""));
if (chapterId) search.set("kapitel", chapterId);
const next = search.toString();
return `/matters/${id}/items/${binding.id}${next ? `?${next}` : ""}`;
}}
/>
</>
) : null}
{view === "work" ? (
<div className="stack">
@@ -237,7 +289,8 @@ export function MatterDetail() {
<Modal open={modal === "work"} title="Aufgabe oder Frist" onClose={() => setModal("")}>
<WorkForms matterId={id} context={inherited} tasks={record.tasks} onChange={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "add"} title="Hinzufügen" onClose={() => setModal("")}>
<Modal open={modal === "add"} title={`Hinzufügen in ${targetLabel}`} onClose={() => setModal("")}>
<TargetLine label={targetLabel} chapters={record.chapters} chapterId={activeChapter?.id || ""} />
<div className="choice">
<button type="button" onClick={() => setModal("note")}>Notiz</button>
<button type="button" onClick={() => setModal("file")}>Datei</button>
@@ -246,16 +299,16 @@ export function MatterDetail() {
</div>
</Modal>
<Modal open={modal === "note"} title="Notiz" onClose={() => setModal("")}>
<NoteForm context={rightsContext} placement={placement} chapters={record.chapters} onChange={() => { setModal(""); load(); }} />
<NoteForm context={rightsContext} placement={placement} chapters={record.chapters} initialChapter={activeChapter?.id || ""} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "file"} title="Datei" onClose={() => setModal("")}>
<FileForm context={rightsContext} placement={placement} chapters={record.chapters} onChange={() => { setModal(""); load(); }} />
<FileForm context={rightsContext} placement={placement} chapters={record.chapters} initialChapter={activeChapter?.id || ""} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "paperless"} title="Aus Paperless" onClose={() => setModal("")}>
<PaperlessPicker context={rightsContext} placement={placement} onDone={() => { setModal(""); load(); }} />
<PaperlessPicker context={rightsContext} placement={placement} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter?.title || ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "mail"} title="E-Mail verbinden" wide onClose={() => setModal("")}>
<MailPicker context={rightsContext} placement={placement} onDone={() => { setModal(""); load(); }} />
<MailPicker context={rightsContext} placement={placement} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter?.title || ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "submatter"} title="Teilvorgang anlegen" onClose={() => setModal("")}>
<SubmatterForm parentId={id} context={inherited} onChange={() => { setModal(""); load(); }} />
@@ -263,8 +316,18 @@ export function MatterDetail() {
<Modal open={modal === "cross"} title="Querverweis" onClose={() => setModal("")}>
<CrossLinkForm matterId={id} context={inherited} onChange={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "chapter"} title="Kapitel anlegen" onClose={() => setModal("")}>
<ChapterForm path={`/api/v1/matters/${id}/chapters${inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : ""}`} onChange={() => { setModal(""); load(); }} />
<Modal open={modal === "chapter"} title={`Kapitel in ${targetLabel} hinzufügen`} onClose={() => setModal("")}>
<ChapterForm
path={`/api/v1/matters/${id}/chapters${inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : ""}`}
onChange={(created) => {
setModal("");
if (created?.id) {
pendingChapter.current = created.id;
writeChapter(params, setParams, created.id);
}
load();
}}
/>
</Modal>
<Modal open={modal === "share"} title="Teilen" onClose={() => setModal("")}>
<ShareBox path={`/api/v1/matters/${id}/grants`} grants={record.grants || []} onChange={load} />