Oeffne Kapitel und Dokument auf derselben Arbeitsflaeche, damit Pfad, Rechte und eigene Reihenfolge beim Lesen erhalten bleiben.
Deploy Development / deploy (push) Successful in 33s
Test Suite / pytest-backend (push) Successful in 56s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 9s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-17 14:19:06 +02:00
1 parent 94ef46d8eb
commit 448e9a06ff
34 files changed
+2998 -696

No files matched your search

+93 -19
View File
@@ -1,5 +1,6 @@
import { useEffect, useRef, useState } from "react";
import { Link } from "react-router-dom";
import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";
import { api, fetchFile, fetchPaperless } from "../api.js";
import { Modal } from "./Modal.jsx";
import { ErrorNote } from "./widgets.jsx";
@@ -180,7 +181,7 @@ export function Placements({ items }) {
{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>
<Link to={item.href} aria-current={item.current ? "true" : undefined}>{item.label.replaceAll("Unterakte ", "").replaceAll("Akte ", "").replaceAll(" → ", " / ")}</Link>
</span>
))}
{current ? <span className="muted"> · aktueller Handlungskontext</span> : <span className="muted"> · Handlungskontext direkt, solange keine Akte gewählt ist</span>}
@@ -196,7 +197,7 @@ export function ObjectMenu({ view, onView, children }) {
}
return (
<>
<button type="button" className="quiet" onClick={() => setOpen(true)}>Aktionen</button>
<button type="button" className="icon-button" aria-label="Aktionen" onClick={() => setOpen(true)}>⋯</button>
<Modal open={open} title="Aktionen" onClose={() => setOpen(false)}>
<div className="menu-list" onClick={() => setOpen(false)}>
<button type="button" className={view === "course" ? "" : "quiet"} onClick={() => choose("course")}>Fachlicher Verlauf</button>
@@ -211,7 +212,7 @@ export function ObjectMenu({ view, onView, children }) {
export function WorkSwitch({ view, onView }) {
return (
<div className="order-bar" role="tablist" aria-label="Arbeitsfläche">
<div className="surface-tabs" 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" ? (
@@ -234,6 +235,39 @@ function blurb(element) {
return element.summary || element.excerpt || "";
}
function PdfThumb({ url, title }) {
const canvasRef = useRef(null);
const [failed, setFailed] = useState(false);
useEffect(() => {
let alive = true;
let doc;
(async () => {
try {
const pdfjs = await import("pdfjs-dist");
pdfjs.GlobalWorkerOptions.workerSrc = workerSrc;
const bytes = await fetch(url).then((response) => response.arrayBuffer());
doc = await pdfjs.getDocument({ data: bytes }).promise;
const pdfPage = await doc.getPage(1);
if (!alive || !canvasRef.current) return;
const base = pdfPage.getViewport({ scale: 1 });
const viewport = pdfPage.getViewport({ scale: 148 / base.width });
const canvas = canvasRef.current;
canvas.width = viewport.width;
canvas.height = viewport.height;
await pdfPage.render({ canvasContext: canvas.getContext("2d"), viewport }).promise;
} catch {
if (alive) setFailed(true);
}
})();
return () => {
alive = false;
doc?.destroy?.();
};
}, [url]);
if (failed) return <span className="thumb thumb--empty">Vorschau nicht verfügbar</span>;
return <canvas ref={canvasRef} className="thumb thumb--pdf" aria-label={`Vorschau ${title}`} />;
}
function Thumb({ element, context }) {
const [url, setUrl] = useState("");
const [media, setMedia] = useState("");
@@ -260,12 +294,30 @@ function Thumb({ element, context }) {
}, [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 (url && media === "pdf") return <PdfThumb url={url} title={element.title} />;
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 async function saveChapterOrder({ containerKind, containerId, record, context, ids }) {
const orderPath = `/api/v1/${containerKind === "case" ? "cases" : "matters"}/${containerId}`;
const orderContext = context && containerKind === "matter" ? { context } : {};
let version = record.version;
const direction = record?.content_order_dir === "desc" ? "desc" : "asc";
if (record?.content_order !== "position") {
const switched = await api(`${orderPath}/content-order`, {
method: "PATCH",
body: { expected_version: version, mode: "position", direction, ...orderContext },
});
version = switched.version;
}
await api(`${orderPath}/chapters/order`, {
method: "POST",
body: { expected_version: version, chapter_ids: ids, ...orderContext },
});
}
export function ContentBoard({
record,
bindings,
@@ -276,6 +328,9 @@ export function ContentBoard({
onChange,
itemHref,
onlyChapter = "",
selectedId = "",
onOpen,
listTitle = "",
}) {
const source = bindings || record?.bindings || [];
const chapters = record?.chapters || [];
@@ -288,7 +343,8 @@ export function ContentBoard({
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 !== "loose") : sections;
const visibleSections = onlyChapter ? sections.filter((section) => section.id === onlyChapter) : sections;
const shownCount = onlyChapter ? (visibleSections[0]?.items.length || 0) : source.length;
const canSort = sortable && record?.rights?.edit;
const canMoveChapters = Boolean(canSort && chapters.length > 1);
const orderPath = `/api/v1/${containerKind === "case" ? "cases" : "matters"}/${containerId}`;
@@ -605,17 +661,23 @@ export function ContentBoard({
return (
<div className="contents" ref={rootRef}>
{canSort ? (
<OrderChoice
mode={custom ? "position" : "date"}
direction={direction}
disabled={pending}
allowPosition
onChange={saveMode}
/>
) : sortable ? (
<p className="muted">{custom ? "Eigene Reihenfolge" : `Fachliches Datum, ${direction === "desc" ? "absteigend" : "aufsteigend"}`}</p>
) : null}
<div className="content-toolbar">
<div>
<h2>{onlyChapter ? (visibleSections[0]?.title || listTitle || "Kapitel") : (listTitle || "Inhalte")}</h2>
<p className="muted">{shownCount} {shownCount === 1 ? "Eintrag" : "Einträge"}</p>
</div>
{canSort ? (
<OrderChoice
mode={custom ? "position" : "date"}
direction={direction}
disabled={pending}
allowPosition
onChange={saveMode}
/>
) : sortable ? (
<p className="muted">{custom ? "Eigene Reihenfolge" : `Fachliches Datum, ${direction === "desc" ? "absteigend" : "aufsteigend"}`}</p>
) : null}
</div>
{pending ? <p className="muted">Ordnung wird gespeichert …</p> : null}
<ErrorNote error={error} />
{source.length || chapters.length ? (
@@ -637,7 +699,7 @@ export function ContentBoard({
data-chapter={section.id === "loose" ? undefined : section.id}
>
{insertBefore ? <div className="insert-line" aria-hidden="true" /> : null}
{section.title ? (
{section.title && !onlyChapter ? (
<div
className={movable ? "chapter-head is-movable" : "chapter-head"}
draggable={movable && !pending}
@@ -692,7 +754,7 @@ export function ContentBoard({
const href = itemHref(binding);
const text = blurb(element);
return (
<li key={binding.id} data-binding={binding.id} className={draggingId === binding.id ? "preview-row is-dragging" : "preview-row"}>
<li key={binding.id} data-binding={binding.id} className={`preview-row${draggingId === binding.id ? " is-dragging" : ""}${selectedId === binding.id ? " is-selected" : ""}`}>
{indicator?.sectionId === section.id && indicator?.kind !== "chapter" && indicator.index === index ? <div className="insert-line" /> : null}
{canSort && custom ? (
<button
@@ -714,11 +776,23 @@ export function ContentBoard({
</button>
) : null}
<Thumb element={element} context={context} />
<Link className="preview-row__main" to={href}>
<Link
className="preview-row__main"
to={href}
aria-current={selectedId === binding.id ? "true" : undefined}
onClick={(event) => {
if (!onOpen || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) return;
event.preventDefault();
onOpen(binding);
}}
>
<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}
{!onlyChapter && !binding.origin && binding.chapter_id ? (
<span className="preview-row__origin">Kapitel {(chapters.find((chapter) => chapter.id === binding.chapter_id)?.title) || ""}</span>
) : null}
</Link>
{(canSort && custom) || (canSort && chapters.length) ? (
<div className="preview-row__actions">