Mache die Inhaltsliste zur einen Arbeitsflaeche mit Vorschauzeilen, damit Pfad, Herkunft und eigene Reihenfolge im Alltag erhalten bleiben.
Deploy Development / deploy (push) Successful in 23s
Test Suite / pytest-backend (push) Successful in 47s
Test Suite / smoke-dev (push) Successful in 1s
Test Suite / frontend-build (push) Successful in 6s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-17 10:25:04 +02:00
1 parent 52bda91aad
commit 3465ed57f6
16 files changed
+1375 -314

No files matched your search

+196 -65
View File
@@ -5,7 +5,7 @@ import { SessionContext } from "../session.js";
import { Modal } from "./Modal.jsx";
import { MailPicker, PaperlessPicker } from "./Sources.jsx";
import { ErrorNote, ShareBox } from "./widgets.jsx";
import { ContentBoard, RecordTabs, Trail } from "./content.jsx";
import { ContentBoard, ObjectMenu, RecordTree, SurfaceView, Trail, WorkLists, WorkSwitch } from "./content.jsx";
export function CaseList() {
const { session } = useContext(SessionContext);
@@ -58,15 +58,11 @@ export function CaseList() {
))}
</div>
{items.filter((item) => !roomFilter || item.home_scope_id === roomFilter).length ? (
<div className="tiles">
{items.filter((item) => !roomFilter || item.home_scope_id === roomFilter).map((item) => (
<Link key={item.id} className="tile" to={`/cases/${item.id}`}>
<span className="tile__kind">{item.home_scope_name || "Akte"}</span>
<strong>{item.title}</strong>
<span>{item.status === "open" ? "Offen" : "Geschlossen"}</span>
</Link>
))}
</div>
<RecordTree
items={items.filter((item) => !roomFilter || item.home_scope_id === roomFilter)}
parentKey="parent_case_id"
hrefFor={(item) => `/cases/${item.id}`}
/>
) : (
<p className="muted">Noch keine Akte. Lege die erste an.</p>
)}
@@ -99,11 +95,116 @@ export function CaseList() {
);
}
function OutlineLink({ kind, title, to }) {
return (
<Link className="hierarchy__row" to={to}>
<span className="hierarchy__kind">{kind}</span>
<strong>{title}</strong>
</Link>
);
}
function CaseOutline({ record, caseId, scope, chapterId, onScope, onChapter }) {
const hasParent = Boolean(record.parent_case_id && record.parent_title);
return (
<nav className="outline-nav" aria-label="Gliederung">
<h2>Gliederung</h2>
<button type="button" className={scope === "all" ? "" : "quiet"} onClick={() => onScope("all")}>Alle Inhalte</button>
<button type="button" className={scope === "direct" && !chapterId ? "" : "quiet"} onClick={() => onScope("direct")}>Direkt in dieser Akte</button>
{hasParent ? (
<p className="hierarchy__parent">Übergeordnet: <Link to={`/cases/${record.parent_case_id}`}>Akte {record.parent_title}</Link></p>
) : null}
{record.subcases?.length ? (
<>
<h3>Unterakten</h3>
<ul className="hierarchy">
{record.subcases.map((item) => (
<li key={item.id}><OutlineLink kind="Unterakte" title={item.title} to={`/cases/${item.id}`} /></li>
))}
</ul>
</>
) : null}
{record.matters?.length ? (
<>
<h3>Vorgänge</h3>
<ul className="hierarchy">
{record.matters.map((matter) => (
<li key={matter.id}>
<button type="button" className={scope === matter.id ? "hierarchy__row" : "hierarchy__row quiet"} onClick={() => onScope(matter.id)}>
<span className="hierarchy__kind">{matter.kind_label || "Vorgang"}</span>
<strong>{matter.title}</strong>
</button>
<Link className="muted" to={`/matters/${matter.id}?context_kind=case&context_id=${caseId}`}>Öffnen</Link>
{matter.children?.length ? (
<ul>
{matter.children.map((child) => (
<li key={child.id}>
<button type="button" className={scope === child.id ? "hierarchy__row" : "hierarchy__row quiet"} onClick={() => onScope(child.id)}>
<span className="hierarchy__kind">Teilvorgang</span>
<strong>{child.title}</strong>
</button>
</li>
))}
</ul>
) : null}
</li>
))}
</ul>
</>
) : null}
{scope === "direct" && record.chapters?.length ? (
<>
<h3>Kapitel</h3>
<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)}>
<span className="hierarchy__kind">Kapitel</span>
<strong>{chapter.title}</strong>
</button>
</li>
))}
</ul>
</>
) : null}
</nav>
);
}
function mergedCaseItems(record, direction, caseId) {
const rows = [
...(record.bindings || []).map((binding) => ({
...binding,
origin: "Direkt in dieser Akte",
readerHref: `/cases/${caseId}/items/${binding.id}`,
})),
...(record.contained || []).flatMap((group) => (group.bindings || []).map((binding) => ({
...binding,
origin: `Aus Vorgang ${group.title}`,
readerHref: `/matters/${group.matter_id}/items/${binding.id}?context_kind=case&context_id=${caseId}`,
}))),
];
const counts = {};
for (const row of rows) counts[row.element.id] = (counts[row.element.id] || 0) + 1;
const marked = rows.map((row) => ({ ...row, shared: counts[row.element.id] > 1 }));
const dated = marked.filter((row) => row.element.dates?.document_on);
const undated = marked.filter((row) => !row.element.dates?.document_on);
dated.sort((a, b) => a.element.dates.document_on.localeCompare(b.element.dates.document_on) || a.id.localeCompare(b.id));
if (direction === "desc") dated.reverse();
undated.sort((a, b) => a.id.localeCompare(b.id));
return [...dated, ...undated];
}
export function CaseDetail() {
const { id } = useParams();
const [record, setRecord] = useState(null);
const [error, setError] = useState("");
const [modal, setModal] = useState("");
const [view, setView] = useState("contents");
const [scope, setScope] = useState("all");
const [chapterId, setChapterId] = useState("");
const [dateDir, setDateDir] = useState("asc");
const [outlineOpen, setOutlineOpen] = useState(false);
const context = { kind: "case", id };
async function load() {
@@ -118,6 +219,11 @@ export function CaseDetail() {
if (error && !record) return <main className="page"><ErrorNote error={error} /></main>;
if (!record) return <main className="page"><p className="muted">Akte wird geladen …</p></main>;
const group = (record.contained || []).find((item) => item.matter_id === scope);
const merged = mergedCaseItems(record, dateDir, id);
const addPlacement = group ? { kind: "matter", id: group.matter_id } : null;
const addChapters = group?.chapters || record.chapters;
return (
<main className="page">
<header className="page-head">
@@ -127,65 +233,90 @@ export function CaseDetail() {
<h1>{record.title}</h1>
<p className="muted">{record.status === "open" ? "Offen" : "Geschlossen"}</p>
</div>
{record.rights.edit ? <button type="button" onClick={() => setModal("add")}>Inhalt hinzufügen</button> : null}
</header>
<ErrorNote error={error} />
<section className="section">
<h2>Direkt in dieser Akte</h2>
<ContentBoard
record={record}
containerKind="case"
containerId={id}
onChange={load}
itemHref={(binding) => `/cases/${id}/items/${binding.id}`}
/>
</section>
{record.contained?.length ? (
<section className="section">
<h2>In enthaltenen Vorgängen</h2>
{record.contained.map((group) => (
<div key={group.matter_id} className="contained">
<p className="muted">Aus dem Vorgang <Link to={`/matters/${group.matter_id}?context_kind=case&context_id=${id}`}>{group.title}</Link></p>
<ContentBoard
record={{ ...record, rights: { edit: false }, bindings: group.bindings, content_order: group.content_order, content_order_dir: group.content_order_dir }}
bindings={group.bindings}
sortable={false}
containerKind="matter"
containerId={group.matter_id}
onChange={load}
itemHref={(binding) => `/matters/${group.matter_id}/items/${binding.id}?context_kind=case&context_id=${id}`}
/>
</div>
))}
</section>
) : null}
<details className="fold">
<summary>Struktur und Zuordnung</summary>
<div className="stack">
<div className="row">
<div className="row">
{record.rights.edit ? <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("matter")}>Vorgang anlegen und zuordnen</button> : null}
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("assign")}>Vorhandenen Vorgang zuordnen</button> : null}
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("subcase")}>Unterakte anlegen</button> : null}
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("chapter")}>Kapitel anlegen</button> : null}
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
</ObjectMenu>
</div>
</header>
<ErrorNote error={error} />
<div className="record-layout">
<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">
<CaseOutline
record={record}
caseId={id}
scope={scope}
chapterId={chapterId}
onScope={(next) => { setScope(next); setChapterId(""); setView("contents"); setOutlineOpen(false); }}
onChapter={(next) => { setChapterId(next); setScope("direct"); setView("contents"); setOutlineOpen(false); }}
/>
</div>
{record.matters.length ? (
<ul className="tree">
{record.matters.map((matter) => (
<li key={matter.id}><Link to={`/matters/${matter.id}?context_kind=case&context_id=${id}`}>Vorgang {matter.title}</Link></li>
))}
</ul>
) : <p className="muted">Noch kein zugeordneter Vorgang.</p>}
{record.subcases?.length ? (
<ul className="tree">
{record.subcases.map((item) => (
<li key={item.id} className="tree__child"><Link to={`/cases/${item.id}`}>Unterakte {item.title}</Link></li>
))}
</ul>
</aside>
<div className="record-main">
<WorkSwitch view={view} onView={setView} />
{view === "contents" && scope === "all" ? (
<div className="stack">
<div className="order-bar" role="group" aria-label="Lesesicht">
<button type="button" className={dateDir === "asc" ? "" : "quiet"} onClick={() => setDateDir("asc")}>Fachliches Datum, aufsteigend</button>
<button type="button" className={dateDir === "desc" ? "" : "quiet"} onClick={() => setDateDir("desc")}>Fachliches Datum, absteigend</button>
</div>
<ContentBoard
record={{ bindings: merged, chapters: [], content_order: "date", content_order_dir: dateDir, rights: { edit: false }, version: record.version }}
bindings={merged}
sortable={false}
containerKind="case"
containerId={id}
onChange={load}
itemHref={(binding) => binding.readerHref}
/>
</div>
) : null}
{view === "contents" && scope === "direct" ? (
<ContentBoard
record={record}
containerKind="case"
containerId={id}
onlyChapter={chapterId}
onChange={load}
itemHref={(binding) => `/cases/${id}/items/${binding.id}`}
/>
) : null}
{view === "contents" && group ? (
<ContentBoard
record={{ ...group, rights: group.rights, chapters: group.chapters || [] }}
bindings={group.bindings}
context={context}
containerKind="matter"
containerId={group.matter_id}
onChange={load}
itemHref={(binding) => `/matters/${group.matter_id}/items/${binding.id}?context_kind=case&context_id=${id}`}
/>
) : null}
{view === "contents" && scope !== "all" && scope !== "direct" && !group ? (
<p className="muted">Dieser Bereich hat in der Akte keine eigenen Unterlagen.</p>
) : null}
{view === "work" ? <WorkLists record={record} context={context} onChange={load} /> : null}
{view === "course" || view === "audit" ? (
<SurfaceView view={view} coursePath={`/api/v1/cases/${id}/course`} auditPath={`/api/v1/cases/${id}/chronology`} />
) : null}
{view === "links" ? (
<div className="stack">
<h2>Zuordnungen</h2>
<p className="muted">Unterakten, Vorgänge und Freigaben dieses Objekts.</p>
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("matter")}>Vorgang anlegen und zuordnen</button> : null}
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("assign")}>Vorhandenen Vorgang zuordnen</button> : null}
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("subcase")}>Unterakte anlegen</button> : null}
</div>
) : null}
</div>
</details>
<RecordTabs coursePath={`/api/v1/cases/${id}/course`} auditPath={`/api/v1/cases/${id}/chronology`} />
</div>
<Modal open={modal === "matter"} title="Vorgang anlegen und zuordnen" onClose={() => setModal("")}>
<NewMatter caseId={id} homeScopeId={record.home_scope_id} onChange={() => { setModal(""); load(); }} />
</Modal>
@@ -201,16 +332,16 @@ export function CaseDetail() {
</div>
</Modal>
<Modal open={modal === "note"} title="Notiz" onClose={() => setModal("")}>
<NoteForm context={context} chapters={record.chapters} onChange={() => { setModal(""); load(); }} />
<NoteForm context={context} placement={addPlacement} chapters={addChapters} onChange={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "file"} title="Datei" onClose={() => setModal("")}>
<FileForm context={context} chapters={record.chapters} onChange={() => { setModal(""); load(); }} />
<FileForm context={context} placement={addPlacement} chapters={addChapters} onChange={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "paperless"} title="Aus Paperless" onClose={() => setModal("")}>
<PaperlessPicker context={context} onDone={() => { setModal(""); load(); }} />
<PaperlessPicker context={context} placement={addPlacement} onDone={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "mail"} title="E-Mail verbinden" onClose={() => setModal("")}>
<MailPicker context={context} onDone={() => { setModal(""); load(); }} />
<MailPicker context={context} placement={addPlacement} onDone={() => { setModal(""); load(); }} />
</Modal>
<Modal open={modal === "subcase"} title="Unterakte anlegen" onClose={() => setModal("")}>
<NewSubcase parentId={id} onChange={() => { setModal(""); load(); }} />
+121 -129
View File
@@ -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, RecordTabs, Trail, formatDate } from "./content.jsx";
import { ContentBoard, ObjectMenu, Placements, RecordTree, SurfaceView, Trail, WorkLists, WorkSwitch, formatDate, matterOpenHref } from "./content.jsx";
function pageContext(params) {
const kind = params.get("context_kind");
@@ -45,24 +45,11 @@ export function MatterList() {
</header>
<ErrorNote error={error} />
{items === null ? <p className="muted">Vorgänge werden geladen …</p> : items.length ? (
<div className="tiles">
{items.map((item) => {
const context = item.contexts?.[0];
const params = new URLSearchParams();
if (context && context.kind !== "direct") {
params.set("context_kind", context.kind);
params.set("context_id", context.id);
}
const suffix = params.toString() ? `?${params}` : "";
return (
<Link key={item.id} className="tile" to={`/matters/${item.id}${suffix}`}>
<span className="tile__kind">{item.home_scope_name || "Vorgang"}</span>
<strong>{item.title}</strong>
<span>{item.status === "open" ? "Offen" : "Geschlossen"}</span>
</Link>
);
})}
</div>
<RecordTree
items={items}
parentKey="parent_matter_id"
hrefFor={(item) => matterOpenHref(item)}
/>
) : (
<p className="muted">Noch kein Vorgang.</p>
)}
@@ -92,6 +79,68 @@ export function MatterList() {
);
}
function MatterOutline({ record, inherited, chapterId, onChapter }) {
const matterQuery = inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : "";
const hasParent = Boolean(record.parent_matter_id && record.parent_title);
const hasChildren = Boolean(record.submatters?.length);
const hasCases = Boolean(record.placements?.length);
return (
<nav className="outline-nav" aria-label="Gliederung">
<h2>Gliederung</h2>
<button type="button" className={chapterId ? "quiet" : ""} onClick={() => onChapter("")}>Alle Inhalte</button>
{hasParent ? (
<p className="hierarchy__parent">Übergeordnet: <Link to={`/matters/${record.parent_matter_id}${matterQuery}`}>Vorgang {record.parent_title}</Link></p>
) : null}
{hasCases ? (
<>
<h3>In diesen Akten</h3>
<ul className="hierarchy">
{record.placements.map((link) => (
<li key={link.case_id}>
<Link className="hierarchy__row" to={link.href}>
<span className="hierarchy__kind">Akte</span>
<strong>{link.label.replaceAll("Unterakte ", "").replaceAll("Akte ", "")}</strong>
{link.current ? <span className="muted">aktueller Handlungskontext</span> : null}
</Link>
</li>
))}
</ul>
</>
) : null}
{hasChildren ? (
<>
<h3>Teilvorgänge</h3>
<ul className="hierarchy">
{record.submatters.map((item) => (
<li key={item.id}>
<Link className="hierarchy__row" to={`/matters/${item.id}${matterQuery}`}>
<span className="hierarchy__kind">Teilvorgang</span>
<strong>{item.title}</strong>
</Link>
</li>
))}
</ul>
</>
) : null}
{record.chapters?.length ? (
<>
<h3>Kapitel</h3>
<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)}>
<span className="hierarchy__kind">Kapitel</span>
<strong>{chapter.title}</strong>
</button>
</li>
))}
</ul>
</>
) : null}
</nav>
);
}
export function MatterDetail() {
const { id } = useParams();
const [params] = useSearchParams();
@@ -101,6 +150,9 @@ export function MatterDetail() {
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);
async function load() {
const query = inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : "";
@@ -116,77 +168,72 @@ export function MatterDetail() {
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}` : "";
return (
<main className="page">
<header className="page-head">
<div>
<Trail items={record.trail} />
<p className="eyebrow">{record.kind_label || "Vorgang"} · {record.home_scope_name}{inherited ? " · über die Akte geöffnet" : ""}</p>
<Placements items={record.placements} />
<p className="eyebrow">{record.kind_label || "Vorgang"} · {record.home_scope_name}</p>
<h1>{record.title}</h1>
<p className="muted">{record.status === "open" ? "Offen" : "Geschlossen"}</p>
</div>
{record.rights.edit ? <button type="button" onClick={() => setModal("add")}>Inhalt hinzufügen</button> : null}
</header>
<ErrorNote error={error} />
<div className="work-layout">
<section className="section">
<h2>Unterlagen und Notizen</h2>
<ContentBoard
record={record}
context={inherited}
containerKind="matter"
containerId={id}
onChange={load}
itemHref={(binding) => `/matters/${id}/items/${binding.id}${inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : ""}`}
/>
</section>
<aside className="side-work">
<div className="section-bar">
<h2>Aufgaben und Fristen</h2>
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("work")}>Hinzufügen</button> : null}
</div>
<p className="muted">Erledigen und Erfüllen bleiben getrennte Aktionen.</p>
<WorkLists record={record} context={inherited} onChange={load} />
</aside>
</div>
<details className="fold">
<summary>Struktur und Zuordnung</summary>
<div className="stack">
<div className="row">
<div className="row">
{record.rights.edit ? <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}
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
</ObjectMenu>
</div>
</header>
<ErrorNote error={error} />
<div className="record-layout">
<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); }} />
</div>
{record.case_links?.length ? (
<ul className="tree">
{record.case_links.map((link) => (
<li key={link.id}>Akte <Link to={`/cases/${link.case_id}`}>{link.title}</Link>{inherited?.id === link.case_id ? " · aktueller Weg" : ""}</li>
))}
</ul>
) : <p className="muted">Noch keiner Akte zugeordnet.</p>}
{record.submatters?.length ? (
<ul className="tree">
{record.submatters.map((item) => (
<li key={item.id} className="tree__child">
<Link to={`/matters/${item.id}${inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : ""}`}>Teilvorgang {item.title}</Link>
</li>
))}
</ul>
</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}`}
/>
) : null}
{record.cross_links?.length ? (
<ul className="tree">
{record.cross_links.map((item) => (
<li key={item.id}>Querverweis <Link to={`/matters/${item.matter_id}`}>{item.title}</Link></li>
))}
</ul>
{view === "work" ? (
<div className="stack">
{record.rights.edit ? <button type="button" onClick={() => setModal("work")}>Aufgabe oder Frist</button> : null}
<WorkLists record={record} context={inherited} onChange={load} />
</div>
) : null}
{view === "course" || view === "audit" ? (
<SurfaceView view={view} coursePath={`/api/v1/matters/${id}/course${query}`} auditPath={`/api/v1/matters/${id}/chronology${query}`} />
) : null}
{view === "links" ? (
<div className="stack">
<h2>Zuordnungen</h2>
{record.case_links?.length ? record.case_links.map((item) => (
<p key={item.id}><Link to={`/cases/${item.case_id}`}>Akte {item.title}</Link></p>
)) : <p className="muted">Noch keiner Akte zugeordnet.</p>}
{record.cross_links?.length ? record.cross_links.map((item) => (
<p key={item.id}>Querverweis <Link to={matterOpenHref({ id: item.matter_id, contexts: [] })}>{item.title}</Link></p>
)) : <p className="muted">Kein Querverweis.</p>}
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("cross")}>Querverweis</button> : null}
</div>
) : null}
</div>
</details>
<RecordTabs
coursePath={`/api/v1/matters/${id}/course${inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : ""}`}
auditPath={`/api/v1/matters/${id}/chronology${inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : ""}`}
/>
</div>
<Modal open={modal === "work"} title="Aufgabe oder Frist" onClose={() => setModal("")}>
<WorkForms matterId={id} context={inherited} tasks={record.tasks} onChange={() => { setModal(""); load(); }} />
</Modal>
@@ -226,61 +273,6 @@ export function MatterDetail() {
);
}
function WorkLists({ record, context, onChange }) {
const linked = new Set((record.task_deadline_links || []).map((item) => item.task_id));
async function complete(task) {
await api(`/api/v1/tasks/${task.id}`, {
method: "PATCH",
body: { expected_version: task.version, status: "done", ...(context ? { context } : {}) },
});
onChange();
}
async function fulfill(deadline) {
await api(`/api/v1/deadlines/${deadline.id}/fulfill`, {
method: "POST",
body: { expected_version: deadline.version, ...(context ? { context } : {}) },
});
onChange();
}
return (
<div className="stack">
<div>
<h3>Aufgaben</h3>
<ul className="work">
{record.tasks.map((task) => (
<li key={task.id}>
<div>
<strong>{task.title}</strong>
<span>{task.status === "done" ? "Erledigt" : "Offen"}{task.due_on ? ` · ${formatDate(task.due_on)}` : ""}</span>
{task.assignee_display_name ? <small>Zugewiesen: {task.assignee_display_name}</small> : null}
{linked.has(task.id) ? <small>Mit einer Frist verknüpft, ohne sie zu erfüllen.</small> : null}
</div>
{task.status === "open" ? <button type="button" onClick={() => complete(task)}>Erledigen</button> : null}
</li>
))}
</ul>
</div>
<div>
<h3>Fristen</h3>
<ul className="work">
{record.deadlines.map((deadline) => (
<li key={deadline.id}>
<div>
<strong>{deadline.title}</strong>
<span>{deadline.status === "fulfilled" ? "Erfüllt" : "Offen"} · {formatDate(deadline.due_on)}</span>
</div>
{deadline.status === "open" ? <button type="button" onClick={() => fulfill(deadline)}>Frist erfüllen</button> : null}
</li>
))}
</ul>
</div>
</div>
);
}
function WorkForms({ matterId, context, tasks, onChange }) {
const [taskTitle, setTaskTitle] = useState("");
const [taskDue, setTaskDue] = useState("");
+3 -10
View File
@@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api } from "../api.js";
import { ErrorNote, RecordLink } from "./widgets.jsx";
import { formatDate } from "./content.jsx";
import { formatDate, matterOpenHref } from "./content.jsx";
export function Overview() {
const [tasks, setTasks] = useState(null);
@@ -118,18 +118,11 @@ export function Overview() {
{recent?.length ? (
<ul className="work">
{recent.map((item) => {
const context = item.contexts?.find((entry) => entry.kind === "case") || item.contexts?.[0];
const params = new URLSearchParams();
if (context && context.kind !== "direct") {
params.set("context_kind", context.kind);
params.set("context_id", context.id);
}
const suffix = params.toString() ? `?${params}` : "";
return (
<li key={item.id}>
<div>
<strong><Link to={`/matters/${item.id}${suffix}`}>{item.title}</Link></strong>
<span>{item.status === "open" ? "Offen" : "Geschlossen"}</span>
<strong><Link to={matterOpenHref(item)}>{item.title}</Link></strong>
<span>{item.kind_label || "Vorgang"}{item.parent_title ? ` in ${item.parent_title}` : ""} · {item.status === "open" ? "Offen" : "Geschlossen"}</span>
</div>
</li>
);
+56 -1
View File
@@ -23,6 +23,8 @@ export function Reader() {
const [text, setText] = useState("");
const [note, setNote] = useState("");
const [documentOn, setDocumentOn] = useState("");
const [summary, setSummary] = useState("");
const [previewKind, setPreviewKind] = useState("");
const [notice, setNotice] = useState("");
const navigate = useNavigate();
@@ -42,6 +44,7 @@ export function Reader() {
setRecord({ ...detail, binding });
setText(binding.element.kind === "note" ? documentToText(binding.element.document) : "");
setDocumentOn(binding.element.dates?.document_on || "");
setSummary(binding.element.summary || "");
setError("");
}
@@ -58,6 +61,30 @@ export function Reader() {
if (previewUrl) URL.revokeObjectURL(previewUrl);
}, [previewUrl]);
useEffect(() => {
const element = record?.binding?.element;
if (!element || element.kind === "note") return undefined;
if (!element.preview?.available) return undefined;
let alive = true;
const load = element.kind === "external_ref" ? fetchPaperless(element.id, context) : fetchFile(element.id, context);
load.then((blob) => {
if (!alive) return;
const next = URL.createObjectURL(blob);
setPreviewUrl((current) => {
if (current) URL.revokeObjectURL(current);
return next;
});
if (blob.type.startsWith("image/")) setPreviewKind("image");
else if (blob.type.includes("pdf")) setPreviewKind("pdf");
else setPreviewKind("other");
}).catch((err) => {
if (alive) setError(err.message);
});
return () => {
alive = false;
};
}, [record?.binding?.id]);
if (error && !record?.binding) {
return <main className="page"><ErrorNote error={error} /><p><Link to={`/${kind}/${id}${query}`}>Zurück</Link></p></main>;
}
@@ -96,6 +123,21 @@ export function Reader() {
}
}
async function saveSummary(event) {
event.preventDefault();
setError("");
try {
await api(`/api/v1/elements/${element.id}/summary`, {
method: "PATCH",
body: { expected_version: element.version, summary: summary.trim() || null, context },
});
markDirty(false);
load();
} catch (err) {
setError(err.message);
}
}
async function saveDate(event) {
event.preventDefault();
setError("");
@@ -169,12 +211,25 @@ export function Reader() {
{notice ? <p className="notice">{notice}</p> : null}
{binding.rights.edit ? <button type="submit">Text speichern</button> : <p className="muted">In diesem Kontext nur lesbar.</p>}
</form>
) : previewUrl && previewKind === "image" ? (
<img className="reader-preview" alt={element.title} src={previewUrl} />
) : previewUrl ? (
<iframe className="preview" title={element.title} src={previewUrl} />
) : (
<div className="stack">
<p className="muted">{element.preview?.available ? "Vorschau wird geladen …" : "Für diesen Typ gibt es keine eingebaute Vorschau."}</p>
<button type="button" onClick={openFile}>{element.kind === "external_ref" ? "Paperless öffnen" : "Datei öffnen"}</button>
{previewUrl ? <iframe className="preview" title={element.title} src={previewUrl} /> : null}
</div>
)}
{binding.rights.edit ? (
<form className="stack" onSubmit={saveSummary}>
<label>
Kurzbeschreibung, optional
<textarea rows={2} maxLength={400} value={summary} onChange={(event) => { setSummary(event.target.value); markDirty(true); }} />
</label>
<button type="submit" className="quiet">Kurzbeschreibung speichern</button>
</form>
) : element.summary ? <p>{element.summary}</p> : null}
{binding.rights.edit ? (
<form className="stack" onSubmit={saveDate}>
<label>
+2 -10
View File
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { Link, useSearchParams } from "react-router-dom";
import { api } from "../api.js";
import { matterOpenHref } from "./content.jsx";
import { ErrorNote } from "./widgets.jsx";
export function Search() {
@@ -42,16 +43,7 @@ export function Search() {
function Result({ item }) {
if (item.kind === "case") return <Link to={`/cases/${item.id}`}>{item.title}</Link>;
if (item.kind === "matter") {
const context = item.contexts?.find((entry) => entry.kind !== "direct") || item.contexts?.[0];
const params = new URLSearchParams();
if (context && context.kind !== "direct") {
params.set("context_kind", context.kind);
params.set("context_id", context.id);
}
const suffix = params.toString() ? `?${params}` : "";
return <Link to={`/matters/${item.id}${suffix}`}>{item.title}</Link>;
}
if (item.kind === "matter") return <Link to={matterOpenHref(item)}>{item.title}</Link>;
const context = item.contexts?.[0];
if (!context) return <span>{item.title}</span>;
if (context.kind === "case") return <Link to={`/cases/${context.id}`}>{item.title}</Link>;
+442 -27
View File
@@ -1,6 +1,6 @@
import { useState } from "react";
import { useEffect, useRef, useState } from "react";
import { Link } from "react-router-dom";
import { api } from "../api.js";
import { api, fetchFile, fetchPaperless } from "../api.js";
import { ErrorNote } from "./widgets.jsx";
export function formatDate(value) {
@@ -41,6 +41,56 @@ export function Trail({ items }) {
);
}
export function nestRecords(items, parentKey) {
const ids = new Set((items || []).map((item) => item.id));
const children = new Map();
const roots = [];
for (const item of items || []) {
const parentId = item[parentKey];
if (parentId && ids.has(parentId)) {
const list = children.get(parentId) || [];
list.push(item);
children.set(parentId, list);
} else {
roots.push(item);
}
}
return { roots, children };
}
function TreeBranch({ item, children, hrefFor, nested }) {
const kids = children.get(item.id) || [];
return (
<li>
<Link className="hierarchy__row" to={hrefFor(item)}>
<span className="hierarchy__kind">{item.kind_label || "Eintrag"}</span>
<strong>{item.title}</strong>
{!nested && item.parent_title ? <span className="muted">in {item.parent_title}</span> : null}
<span className="muted">{item.status === "open" ? "Offen" : item.status === "closed" ? "Geschlossen" : ""}</span>
</Link>
{kids.length ? (
<ul>
{kids.map((child) => (
<TreeBranch key={child.id} item={child} children={children} hrefFor={hrefFor} nested />
))}
</ul>
) : null}
</li>
);
}
export function RecordTree({ items, parentKey, hrefFor }) {
const { roots, children } = nestRecords(items, parentKey);
if (!roots.length) return null;
return (
<ul className="hierarchy">
{roots.map((item) => (
<TreeBranch key={item.id} item={item} children={children} hrefFor={hrefFor} nested={false} />
))}
</ul>
);
}
function sectionsOf(chapters, bindings) {
const buckets = new Map();
const loose = [];
@@ -62,6 +112,102 @@ function sectionsOf(chapters, bindings) {
return sections;
}
export function matterOpenHref(item) {
const contexts = item?.contexts || [];
if (contexts.some((entry) => entry.kind === "direct")) return `/matters/${item.id}`;
const context = contexts.find((entry) => entry.kind === "case");
if (!context) return `/matters/${item.id}`;
return `/matters/${item.id}?context_kind=case&context_id=${context.id}`;
}
export function Placements({ items }) {
if (!items?.length) return null;
const current = items.find((item) => item.current);
return (
<p className="placements">
<span>In Akte: </span>
{items.map((item, index) => (
<span key={item.case_id}>
{index ? <span aria-hidden="true"> · </span> : null}
<Link to={item.href} aria-current={item.current ? "true" : undefined}>{item.label.replaceAll("Unterakte ", "").replaceAll("Akte ", "")}</Link>
</span>
))}
{current ? <span className="muted"> · aktueller Handlungskontext</span> : <span className="muted"> · Handlungskontext direkt, solange keine Akte gewählt ist</span>}
</p>
);
}
export function ObjectMenu({ view, onView, children }) {
return (
<details className="object-menu">
<summary>Menü</summary>
<div className="stack">
<button type="button" className={view === "course" ? "" : "quiet"} onClick={() => onView("course")}>Fachlicher Verlauf</button>
<button type="button" className={view === "audit" ? "" : "quiet"} onClick={() => onView("audit")}>Änderungsprotokoll</button>
<button type="button" className={view === "links" ? "" : "quiet"} onClick={() => onView("links")}>Zuordnungen</button>
{children}
</div>
</details>
);
}
export function WorkSwitch({ view, onView }) {
return (
<div className="order-bar" role="tablist" aria-label="Arbeitsfläche">
<button type="button" role="tab" aria-selected={view === "contents"} className={view === "contents" ? "" : "quiet"} onClick={() => onView("contents")}>Inhalte</button>
<button type="button" role="tab" aria-selected={view === "work"} className={view === "work" ? "" : "quiet"} onClick={() => onView("work")}>Aufgaben und Fristen</button>
{view !== "contents" && view !== "work" ? (
<button type="button" className="quiet" onClick={() => onView("contents")}>Zurück zu den Inhalten</button>
) : null}
</div>
);
}
function sourceLabel(element) {
if (element.kind === "note") return "Notiz";
if (element.kind === "external_ref") return element.external?.source === "paperless" ? "Paperless" : "Referenz";
if (element.file?.content_type === "application/pdf") return "PDF";
if (element.file?.content_type?.startsWith("image/")) return "Bild";
if (element.kind === "file") return "Datei";
return kindLabel(element.kind);
}
function blurb(element) {
return element.summary || element.excerpt || "";
}
function Thumb({ element, context }) {
const [url, setUrl] = useState("");
const [media, setMedia] = useState("");
const [failed, setFailed] = useState(false);
useEffect(() => {
if (!element.preview?.available) return undefined;
let alive = true;
let current = "";
const load = element.preview.source === "paperless" ? fetchPaperless(element.id, context) : fetchFile(element.id, context);
load.then((blob) => {
if (!alive) return;
current = URL.createObjectURL(blob);
setUrl(current);
if (blob.type.startsWith("image/")) setMedia("image");
else if (blob.type.includes("pdf")) setMedia("pdf");
else setMedia("other");
}).catch(() => {
if (alive) setFailed(true);
});
return () => {
alive = false;
if (current) URL.revokeObjectURL(current);
};
}, [element.id, element.preview?.available, element.preview?.source, context?.kind, context?.id]);
if (element.kind === "note") return <span className="thumb thumb--note">Notiz</span>;
if (url && media === "image") return <img className="thumb" alt="" src={url} />;
if (url && media === "pdf") return <iframe className="thumb thumb--pdf" title={`Vorschau ${element.title}`} src={url} />;
if (failed) return <span className="thumb thumb--empty">Vorschau nicht verfügbar</span>;
if (element.preview?.available) return <span className="thumb thumb--empty">Vorschau wird geladen</span>;
return <span className="thumb thumb--empty">Keine Vorschau</span>;
}
export function ContentBoard({
record,
bindings,
@@ -71,27 +217,61 @@ export function ContentBoard({
sortable = true,
onChange,
itemHref,
onlyChapter = "",
}) {
const source = bindings || record?.bindings || [];
const chapters = record?.chapters || [];
const [error, setError] = useState("");
const [pending, setPending] = useState(false);
const [draggingId, setDraggingId] = useState("");
const [indicator, setIndicator] = useState(null);
const dragRef = useRef(null);
const rootRef = useRef(null);
const custom = record?.content_order === "position";
const direction = record?.content_order_dir === "desc" ? "desc" : "asc";
const sections = sectionsOf(chapters, source);
const visibleSections = onlyChapter ? sections.filter((section) => section.id === onlyChapter) : sections;
const canSort = sortable && record?.rights?.edit;
const orderPath = `/api/v1/${containerKind === "case" ? "cases" : "matters"}/${containerId}`;
const orderContext = context && containerKind === "matter" ? { context } : {};
useEffect(() => {
function onKey(event) {
if (event.key !== "Escape" || !dragRef.current) return;
dragRef.current = null;
setDraggingId("");
setIndicator(null);
}
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, []);
async function saveMode(mode, nextDirection) {
setError("");
setPending(true);
try {
await api(`/api/v1/${containerKind === "case" ? "cases" : "matters"}/${containerId}/content-order`, {
await api(`${orderPath}/content-order`, {
method: "PATCH",
body: { expected_version: record.version, mode, direction: nextDirection, ...orderContext },
});
onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}
async function persist(next) {
setError("");
setPending(true);
try {
await api(`${orderPath}/bindings/order`, {
method: "POST",
body: {
expected_version: record.version,
mode,
direction: nextDirection,
...(context && containerKind === "matter" ? { context } : {}),
binding_ids: next.flatMap((section) => section.items.map((item) => item.id)),
...orderContext,
},
});
onChange();
@@ -114,16 +294,16 @@ export function ContentBoard({
moved = true;
}
if (!moved) return;
await persist(next);
}
async function placeChapter(bindingId, chapterId) {
setError("");
setPending(true);
try {
await api(`/api/v1/${containerKind === "case" ? "cases" : "matters"}/${containerId}/bindings/order`, {
method: "POST",
body: {
expected_version: record.version,
binding_ids: next.flatMap((section) => section.items.map((item) => item.id)),
...(context && containerKind === "matter" ? { context } : {}),
},
await api(`/api/v1/bindings/${bindingId}/chapter`, {
method: "PATCH",
body: { expected_version: record.version, chapter_id: chapterId || null, ...orderContext },
});
onChange();
} catch (err) {
@@ -133,8 +313,97 @@ export function ContentBoard({
}
}
function indexAt(sectionId, clientY) {
const rows = [...(rootRef.current?.querySelectorAll(`[data-section="${sectionId}"] [data-binding]`) || [])];
for (let i = 0; i < rows.length; i += 1) {
const rect = rows[i].getBoundingClientRect();
if (clientY < rect.top + rect.height / 2) return i;
}
return rows.length;
}
function finishDrag(drag) {
dragRef.current = null;
setDraggingId("");
setIndicator(null);
if (!drag || !drag.moved || drag.index == null) return;
const next = sections.map((section) => ({ ...section, items: [...section.items] }));
const section = next.find((item) => item.id === drag.sectionId);
if (!section) return;
const from = section.items.findIndex((item) => item.id === drag.bindingId);
if (from < 0) return;
let target = drag.index;
if (from < target) target -= 1;
if (target < 0) target = 0;
if (target > section.items.length - 1) target = section.items.length - 1;
if (target === from) return;
const [item] = section.items.splice(from, 1);
section.items.splice(target, 0, item);
persist(next);
}
function track(event) {
const drag = dragRef.current;
if (!drag || drag.pointerId !== event.pointerId) return;
if (Math.abs(event.clientY - drag.startY) > 4) drag.moved = true;
if (event.clientY < 72) window.scrollBy(0, -16);
if (event.clientY > window.innerHeight - 72) window.scrollBy(0, 16);
drag.index = indexAt(drag.sectionId, event.clientY);
setIndicator({ sectionId: drag.sectionId, index: drag.index });
}
function release(event) {
const drag = dragRef.current;
window.removeEventListener("pointermove", track);
window.removeEventListener("pointerup", release);
window.removeEventListener("pointercancel", cancel);
if (!drag || drag.html5 || drag.pointerId !== event.pointerId) return;
finishDrag(drag);
}
function cancel() {
window.removeEventListener("pointermove", track);
window.removeEventListener("pointerup", release);
window.removeEventListener("pointercancel", cancel);
dragRef.current = null;
setDraggingId("");
setIndicator(null);
}
function onHandleDown(event, bindingId, sectionId) {
if (event.button != null && event.button !== 0) return;
dragRef.current = { pointerId: event.pointerId, bindingId, sectionId, startY: event.clientY, moved: false, index: null };
setDraggingId(bindingId);
window.addEventListener("pointermove", track);
window.addEventListener("pointerup", release);
window.addEventListener("pointercancel", cancel);
}
function onDragStart(event, bindingId, sectionId) {
event.dataTransfer.effectAllowed = "move";
event.dataTransfer.setData("text/plain", bindingId);
dragRef.current = { pointerId: "html5", bindingId, sectionId, startY: event.clientY, moved: true, index: null, html5: true };
setDraggingId(bindingId);
}
function onDragOver(event, sectionId) {
const drag = dragRef.current;
if (!drag?.html5 || drag.sectionId !== sectionId) return;
event.preventDefault();
drag.index = indexAt(sectionId, event.clientY);
setIndicator({ sectionId, index: drag.index });
}
function onDrop(event, sectionId) {
const drag = dragRef.current;
if (!drag?.html5 || drag.sectionId !== sectionId) return;
event.preventDefault();
drag.index = indexAt(sectionId, event.clientY);
finishDrag(drag);
}
return (
<div className="contents">
<div className="contents" ref={rootRef}>
{canSort ? (
<div className="order-bar" role="group" aria-label="Ordnung der Inhalte">
<button type="button" className={record.content_order !== "position" && direction === "asc" ? "" : "quiet"} disabled={pending} onClick={() => saveMode("date", "asc")}>
@@ -148,33 +417,69 @@ export function ContentBoard({
</button>
</div>
) : (
<p className="muted">{custom ? "Eigene Reihenfolge" : `Fachliches Datum, ${direction === "desc" ? "absteigend" : "aufsteigend"}`}</p>
<p className="muted">{sortable ? (custom ? "Eigene Reihenfolge" : `Fachliches Datum, ${direction === "desc" ? "absteigend" : "aufsteigend"}`) : "Lesesicht nach fachlichem Datum. Zum Ordnen einen einzelnen Bereich wählen."}</p>
)}
{pending ? <p className="muted">Ordnung wird gespeichert …</p> : null}
<ErrorNote error={error} />
{source.length ? (
sections.map((section) => (
<section key={section.id} className="content-section">
visibleSections.map((section) => (
<section
key={section.id}
className="content-section"
data-section={section.id}
onDragOver={(event) => onDragOver(event, section.id)}
onDrop={(event) => onDrop(event, section.id)}
>
{section.title ? <h3 className="chapter-title">{section.title}</h3> : null}
<ol className="content-list">
<ol className="preview-list">
{section.items.map((binding, index) => {
const element = binding.element;
const href = itemHref(binding);
const text = blurb(element);
return (
<li key={binding.id} className="content-row">
<Link className="content-row__main" to={href}>
<span className="content-row__date">{formatDate(fachDate(element))}</span>
<span className="content-row__title">{element.title}</span>
<span className="content-row__kind">{kindLabel(element.kind)}</span>
<li key={binding.id} data-binding={binding.id} className={draggingId === binding.id ? "preview-row is-dragging" : "preview-row"}>
{indicator?.sectionId === section.id && indicator.index === index ? <div className="insert-line" /> : null}
{canSort && custom ? (
<button
type="button"
className="handle"
aria-label={`${element.title} ziehen`}
draggable={!pending}
disabled={pending}
onPointerDown={(event) => onHandleDown(event, binding.id, section.id)}
onDragStart={(event) => onDragStart(event, binding.id, section.id)}
onDragEnd={cancel}
>
Ziehen
</button>
) : null}
<Thumb element={element} context={context} />
<Link className="preview-row__main" to={href}>
<strong>{element.title}</strong>
<span className="preview-row__meta">{formatDate(fachDate(element))} · {sourceLabel(element)}</span>
{text ? <span className="preview-row__text">{text}</span> : null}
{binding.origin ? <span className="preview-row__origin">{binding.origin}{binding.shared ? " · weitere Einbindung" : ""}</span> : null}
</Link>
{canSort && custom ? (
<span className="content-row__move">
<button type="button" className="quiet" aria-label={`${element.title} nach oben`} disabled={pending || index === 0} onClick={() => move(binding.id, -1)}>Nach oben</button>
<button type="button" className="quiet" aria-label={`${element.title} nach unten`} disabled={pending || index === section.items.length - 1} onClick={() => move(binding.id, 1)}>Nach unten</button>
</span>
<details className="row-menu">
<summary>Ordnen</summary>
<button type="button" aria-label={`${element.title} nach oben`} disabled={pending || index === 0} onClick={() => move(binding.id, -1)}>Nach oben</button>
<button type="button" aria-label={`${element.title} nach unten`} disabled={pending || index === section.items.length - 1} onClick={() => move(binding.id, 1)}>Nach unten</button>
{chapters.length ? (
<label>
In Kapitel einordnen
<select value={binding.chapter_id || ""} disabled={pending} onChange={(event) => placeChapter(binding.id, event.target.value)}>
<option value="">Ohne Kapitel</option>
{chapters.map((chapter) => <option key={chapter.id} value={chapter.id}>{chapter.title}</option>)}
</select>
</label>
) : null}
</details>
) : null}
</li>
);
})}
{indicator?.sectionId === section.id && indicator.index === section.items.length ? <li className="insert-line" aria-hidden="true" /> : null}
</ol>
</section>
))
@@ -268,3 +573,113 @@ export function AuditLog({ items, nextCursor, onMore }) {
</div>
);
}
export function WorkLists({ record, context, onChange }) {
const linked = new Set((record.task_deadline_links || []).map((item) => item.task_id));
async function complete(task) {
const body = { expected_version: task.version, status: "done" };
const taskContext = task.action_context || context;
if (taskContext) body.context = taskContext;
await api(`/api/v1/tasks/${task.id}`, { method: "PATCH", body });
onChange();
}
async function fulfill(deadline) {
const body = { expected_version: deadline.version };
if (context) body.context = context;
await api(`/api/v1/deadlines/${deadline.id}/fulfill`, { method: "POST", body });
onChange();
}
return (
<div className="stack">
<p className="muted">Erledigen und Erfüllen bleiben getrennte Aktionen.</p>
<div>
<h3>Aufgaben</h3>
{record.tasks?.length ? (
<ul className="work">
{record.tasks.map((task) => (
<li key={task.id}>
<div>
<strong>{task.title}</strong>
<span>{task.status === "done" ? "Erledigt" : "Offen"}{task.due_on ? ` · ${formatDate(task.due_on)}` : ""}{task.matter_title ? ` · ${task.matter_title}` : ""}</span>
{linked.has(task.id) ? <small>Mit einer Frist verknüpft, ohne sie zu erfüllen.</small> : null}
</div>
{task.status === "open" && task.rights?.edit !== false ? <button type="button" onClick={() => complete(task)}>Erledigen</button> : null}
</li>
))}
</ul>
) : <p className="muted">Keine Aufgabe.</p>}
</div>
<div>
<h3>Fristen</h3>
{record.deadlines?.length ? (
<ul className="work">
{record.deadlines.map((deadline) => (
<li key={deadline.id}>
<div>
<strong>{deadline.title}</strong>
<span>{deadline.status === "fulfilled" ? "Erfüllt" : "Offen"} · {formatDate(deadline.due_on)}{deadline.matter_title ? ` · ${deadline.matter_title}` : ""}</span>
</div>
{deadline.status === "open" ? <button type="button" onClick={() => fulfill(deadline)}>Frist erfüllen</button> : null}
</li>
))}
</ul>
) : <p className="muted">Keine Frist.</p>}
</div>
</div>
);
}
export function SurfaceView({ view, coursePath, auditPath }) {
const [course, setCourse] = useState(null);
const [audit, setAudit] = useState(null);
const [cursor, setCursor] = useState(null);
const [error, setError] = useState("");
useEffect(() => {
setCourse(null);
setAudit(null);
setCursor(null);
}, [coursePath, auditPath]);
useEffect(() => {
if (view !== "course") return undefined;
let alive = true;
api(coursePath).then((data) => {
if (alive) setCourse(data.items);
}).catch((err) => {
if (alive) setError(err.message);
});
return () => {
alive = false;
};
}, [view, coursePath]);
async function showAudit(nextCursor) {
const joiner = auditPath.includes("?") ? "&" : "?";
const data = await api(`${auditPath}${nextCursor ? `${joiner}cursor=${encodeURIComponent(nextCursor)}` : ""}`);
setAudit((current) => (nextCursor ? [...(current || []), ...data.items] : data.items));
setCursor(data.next_cursor);
}
useEffect(() => {
if (view !== "audit") return undefined;
let alive = true;
showAudit("").catch((err) => {
if (alive) setError(err.message);
});
return () => {
alive = false;
};
}, [view, auditPath]);
if (view !== "course" && view !== "audit") return null;
return (
<div>
<ErrorNote error={error} />
{view === "course" ? <CourseList items={course} /> : <AuditLog items={audit} nextCursor={cursor} onMore={() => showAudit(cursor).catch((err) => setError(err.message))} />}
</div>
);
}
+71 -2
View File
@@ -363,7 +363,9 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
.modal h3 { font-size: 13px; }
.page { display: grid; gap: 16px; }
.page-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.page-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; flex-wrap: wrap; }
.page-head > * { min-width: 0; }
.page-head > :first-child { flex: 1 1 16rem; }
.split, .forms { display: grid; gap: 12px; }
.forms > form {
background: var(--surface);
@@ -403,8 +405,14 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
.timeline time { color: var(--text3); font-size: 13px; }
.timeline div { display: grid; }
.trail { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.trail { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 15px; margin-bottom: 10px; }
.trail a, .trail [aria-current="page"] { font-weight: 700; }
.trail__sep { color: var(--text3); }
.hierarchy { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.hierarchy ul { list-style: none; margin: 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--border); display: grid; gap: 4px; }
.hierarchy__row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; min-height: 44px; padding: 4px 0; text-decoration: none; color: inherit; }
.hierarchy__kind { min-width: 7.2rem; color: var(--accent-dark); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.hierarchy__parent { margin-bottom: 8px; }
.order-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.order-bar button { min-height: 44px; }
.content-list { list-style: none; margin: 0; padding: 0; display: grid; }
@@ -466,7 +474,68 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
.timeline li, .item-head, .index li, .work li { display: grid; }
}
.record-layout { display: grid; gap: 20px; align-items: start; }
.outline-nav { display: grid; gap: 8px; }
.outline-nav h2, .outline-nav h3 { margin: 8px 0 0; }
.outline__toggle { display: none; }
button.hierarchy__row { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; cursor: pointer; }
.preview-list { list-style: none; margin: 0; padding: 0; }
.preview-row {
display: flex;
gap: 10px;
align-items: flex-start;
padding: 10px 0;
border-top: 1px solid var(--border);
position: relative;
}
.preview-row.is-dragging { opacity: 0.4; }
.preview-row__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; color: inherit; text-decoration: none; }
.preview-row__meta, .preview-row__origin { color: var(--text2); font-size: 13px; }
.preview-row__text {
color: var(--text);
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.thumb {
width: 72px;
height: 96px;
flex: 0 0 72px;
object-fit: cover;
border: 1px solid var(--border);
border-radius: 6px;
background: #fff;
}
.thumb--note, .thumb--empty {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
padding: 6px;
font-size: 12px;
color: var(--text2);
}
.thumb--pdf { pointer-events: none; }
.handle { min-width: 44px; min-height: 44px; cursor: grab; touch-action: none; }
.insert-line { height: 4px; background: var(--accent); border-radius: 2px; list-style: none; margin: 2px 0; }
.row-menu, .object-menu { font-size: 14px; }
.object-menu .stack, .row-menu { display: grid; gap: 6px; padding-top: 6px; }
.placements { margin: 4px 0 0; overflow-wrap: anywhere; }
.reader-preview { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); }
@media (min-width: 900px) {
.record-layout { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 899px) {
.outline__body { display: none; }
.outline.is-open .outline__body { display: block; }
.outline__toggle { display: inline-flex; margin-bottom: 8px; }
}
@media (prefers-color-scheme: dark) {
button.danger { background: rgba(216, 90, 48, 0.16); }
.notice { color: var(--accent-dark); }
.thumb { background: #1c1c1c; }
}