Vereine Ablage, Akte und Vorgang in einem Navigationsbaum mit Fokus und Nachladen.
Der Baum Meine Ablage steht jetzt auch auf den Seiten von Akte und Vorgang und ersetzt die Spalte Struktur. Ein Klick öffnet den Eintrag und klappt seine Struktur auf: Überblick, Kapitel und Unterkapitel, Unterakten, Vorgänge und Teilvorgänge. Der Pfad bleibt offen, die aktuelle Zeile ist hervorgehoben und nach dem Neuladen stimmt der Fokus wieder. Ein Vorgang steht unter jeder Akte, in der er liegt, und unter Vorgänge; ein Klick unter einer Akte öffnet ihn in diesem Aktenkontext. So wechselt man direkt von Vorgang zu Vorgang. Kapitel anlegen und verschieben geht im Baum. Die Struktur eines Knotens kommt aus neuen schlanken Endpunkten (cases und matters outline), die nur Lesbares liefern, und wird beim Aufklappen einmal nachgeladen. Die Zweispaltenansicht mit dem Lesebereich beginnt erst, wenn neben dem Baum genug Platz bleibt. Im Browser gegen die lokale Umgebung durchgespielt (Akte, Vorgang unter der Akte, Wechsel zwischen Vorgängen, Kapitel anlegen, Neuladen, Vorgang ohne Akte, Handy, Hell und Dunkel). Die Backend-Suite läuft mit 149 Tests grün, der Frontend-Build und 37 Node-Tests ebenfalls. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
322ad491c1
commit
5f60e1fe40
15 files changed
+688
-471
No files matched your search
+22
-194
@@ -11,106 +11,11 @@ import { RoomShare } from "../admin/RoomShare.jsx";
|
||||
import { writableRooms } from "../admin/admin-core.js";
|
||||
import { ContentBoard, DateField, DirectionChoice, MarkdownEditor, ObjectMenu, OrderChoice, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, saveChapterOrder, writeSelection } from "./content.jsx";
|
||||
import { ReadingPane } from "./ReadingPane.jsx";
|
||||
import { StructureNavigator, Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||
import { Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||
import { useLibraryFocus } from "../library/LibraryLayout.jsx";
|
||||
import { outlineSignature } from "../library/library-core.js";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
|
||||
function OutlineLink({ kind, title, to }) {
|
||||
return (
|
||||
<Link className="hierarchy__row" to={to}>
|
||||
<span className="hierarchy__kind">{kind}</span>
|
||||
<strong>{title}</strong>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function matterChapters(record, matterId) {
|
||||
return (record.contained || []).find((item) => item.matter_id === matterId)?.chapters || [];
|
||||
}
|
||||
|
||||
function ChapterLinks({ chapters, scopeId, scope, chapterId, onChapter }) {
|
||||
if (!chapters.length) return null;
|
||||
return (
|
||||
<ul>
|
||||
{chapters.map((chapter) => (
|
||||
<li key={chapter.id}>
|
||||
<button
|
||||
type="button"
|
||||
className={scope === scopeId && chapterId === chapter.id ? "hierarchy__row is-current" : "hierarchy__row"}
|
||||
onClick={() => onChapter(scopeId, chapter.id)}
|
||||
>
|
||||
<span className="hierarchy__kind">Kapitel</span>
|
||||
<strong>{chapter.title}</strong>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function MatterBranch({ matter, caseId, scope, chapterId, record, onScope, onChapter }) {
|
||||
const selected = scope === matter.id && !chapterId;
|
||||
return (
|
||||
<li>
|
||||
<div className="hierarchy__line">
|
||||
<button type="button" className={selected ? "hierarchy__row is-current" : "hierarchy__row"} onClick={() => onScope(matter.id)}>
|
||||
<span className="hierarchy__kind">{matter.kind_label || "Vorgang"}</span>
|
||||
<strong>{matter.title}</strong>
|
||||
</button>
|
||||
<Link className="hierarchy__open" to={`/matters/${matter.id}?context_kind=case&context_id=${caseId}`}>Öffnen</Link>
|
||||
</div>
|
||||
<ChapterLinks chapters={matterChapters(record, matter.id)} scopeId={matter.id} scope={scope} chapterId={chapterId} onChapter={onChapter} />
|
||||
{matter.children?.length ? (
|
||||
<ul>
|
||||
{matter.children.map((child) => (
|
||||
<MatterBranch key={child.id} matter={child} caseId={caseId} scope={scope} chapterId={chapterId} record={record} onScope={onScope} onChapter={onChapter} />
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
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" ? "hierarchy__row is-current" : "hierarchy__row"} onClick={() => onScope("all")}>
|
||||
<span className="hierarchy__kind">Überblick</span>
|
||||
<strong>Alle Inhalte</strong>
|
||||
</button>
|
||||
<button type="button" className={scope === "direct" && !chapterId ? "hierarchy__row is-current" : "hierarchy__row"} onClick={() => onScope("direct")}>
|
||||
<span className="hierarchy__kind">Akte</span>
|
||||
<strong>Direkt in dieser Akte</strong>
|
||||
</button>
|
||||
<ChapterLinks chapters={record.chapters || []} scopeId="direct" scope={scope} chapterId={chapterId} onChapter={onChapter} />
|
||||
{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) => (
|
||||
<MatterBranch key={matter.id} matter={matter} caseId={caseId} scope={scope} chapterId={chapterId} record={record} onScope={onScope} onChapter={onChapter} />
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function matterOrigin(group) {
|
||||
const kind = group.kind_label === "Teilvorgang" ? "Teilvorgang" : "Vorgang";
|
||||
const parent = group.parent_title ? ` · Vorgang ${group.parent_title}` : "";
|
||||
@@ -146,59 +51,6 @@ function mergedCaseItems(record, direction, caseId) {
|
||||
return [...dated, ...undated];
|
||||
}
|
||||
|
||||
function matterNode(matter, caseId) {
|
||||
const query = `?context_kind=case&context_id=${caseId}`;
|
||||
return {
|
||||
id: matter.id,
|
||||
title: matter.title,
|
||||
kind: matter.kind_label || "Vorgang",
|
||||
href: `/matters/${matter.id}${query}`,
|
||||
current: false,
|
||||
children: (matter.children || []).map((child) => matterNode(child, caseId)),
|
||||
};
|
||||
}
|
||||
|
||||
function caseNodes(record, parentRecord) {
|
||||
const self = {
|
||||
id: record.id,
|
||||
title: record.title,
|
||||
kind: record.kind_label || "Akte",
|
||||
href: null,
|
||||
current: true,
|
||||
children: [
|
||||
...(record.subcases || []).map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
kind: "Unterakte",
|
||||
href: `/cases/${item.id}`,
|
||||
current: false,
|
||||
children: [],
|
||||
})),
|
||||
...(record.matters || []).map((matter) => matterNode(matter, record.id)),
|
||||
],
|
||||
};
|
||||
if (!parentRecord) return [self];
|
||||
const siblings = (parentRecord.subcases || []).map((item) => (item.id === record.id ? self : {
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
kind: "Unterakte",
|
||||
href: `/cases/${item.id}`,
|
||||
current: false,
|
||||
children: [],
|
||||
}));
|
||||
return [{
|
||||
id: parentRecord.id,
|
||||
title: parentRecord.title,
|
||||
kind: "Akte",
|
||||
href: `/cases/${parentRecord.id}`,
|
||||
current: false,
|
||||
children: [
|
||||
...(siblings.length ? siblings : [self]),
|
||||
...(parentRecord.matters || []).map((matter) => matterNode(matter, parentRecord.id)),
|
||||
],
|
||||
}];
|
||||
}
|
||||
|
||||
export function CaseDetail() {
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
@@ -208,7 +60,6 @@ export function CaseDetail() {
|
||||
const chapterId = overview ? "" : (params.get("kapitel") || "");
|
||||
const entryId = params.get("eintrag") || "";
|
||||
const [record, setRecord] = useState(null);
|
||||
const [parentTree, setParentTree] = useState(null);
|
||||
const [error, setError] = useState("");
|
||||
const [modal, setModal] = useState("");
|
||||
const [chapterParentId, setChapterParentId] = useState("");
|
||||
@@ -269,7 +120,6 @@ export function CaseDetail() {
|
||||
setModal("");
|
||||
setDateDir("asc");
|
||||
setStructureOpen(false);
|
||||
setParentTree(null);
|
||||
api(`/api/v1/cases/${id}`).then((detail) => {
|
||||
if (!alive) return;
|
||||
pendingChapter.current = "";
|
||||
@@ -280,19 +130,6 @@ export function CaseDetail() {
|
||||
return () => { alive = false; };
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!record || record.id !== id || !record.parent_case_id) return undefined;
|
||||
let alive = true;
|
||||
api(`/api/v1/cases/${record.parent_case_id}`).then((parent) => {
|
||||
if (alive) setParentTree(parent);
|
||||
}).catch(() => {
|
||||
if (alive) setParentTree(null);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [record, id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!record || record.id !== id) return;
|
||||
const matterId = rawScope && !["all", "ueberblick", "direkt", "direct"].includes(rawScope) ? rawScope : "";
|
||||
@@ -385,6 +222,25 @@ export function CaseDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
useLibraryFocus(
|
||||
record && record.id === id
|
||||
? {
|
||||
kind: "case",
|
||||
id,
|
||||
chapterId: overview ? "" : chapterId,
|
||||
overview,
|
||||
canEdit: Boolean(record.rights?.edit),
|
||||
canReorder: Boolean(record.rights?.edit) && (record.chapters || []).length > 1,
|
||||
stamp: outlineSignature(record),
|
||||
}
|
||||
: null,
|
||||
{ addChapter: (parentId) => openChapter(parentId), moveChapter },
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setView("contents");
|
||||
}, [chapterId, overview]);
|
||||
|
||||
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>;
|
||||
|
||||
@@ -396,10 +252,6 @@ export function CaseDetail() {
|
||||
count: (record.bindings || []).filter((item) => item.chapter_id === chapter.id).length,
|
||||
}));
|
||||
const merged = mergedCaseItems(record, dateDir, id);
|
||||
const contexts = [
|
||||
...(parentTree ? [{ id: parentTree.id, label: parentTree.title }] : []),
|
||||
{ id: record.id, label: record.title },
|
||||
];
|
||||
const entry = overview ? null : ((record.bindings || []).find((item) => item.id === entryId) || null);
|
||||
const hasContained = Boolean(record.contained?.length);
|
||||
|
||||
@@ -411,29 +263,6 @@ export function CaseDetail() {
|
||||
setStructureOpen={setStructureOpen}
|
||||
hasEntry={Boolean(entry) && !overview}
|
||||
listRef={listRef}
|
||||
nav={(
|
||||
<StructureNavigator
|
||||
contexts={contexts}
|
||||
contextValue={id}
|
||||
onContext={parentTree ? ((next) => { if (next !== id) navigate(`/cases/${next}`); }) : null}
|
||||
nodes={caseNodes(record, parentTree)}
|
||||
allLabel="Direkt in dieser Akte"
|
||||
chapters={chapters}
|
||||
chapterId={overview ? "" : chapterId}
|
||||
allCount={(record.bindings || []).length}
|
||||
overview={hasContained ? { active: overview, count: merged.length, onSelect: showOverview } : null}
|
||||
chapterHeading={`Kapitel in ${record.title}`}
|
||||
onChapter={chooseChapter}
|
||||
onAddChapter={canEdit ? () => openChapter(chapterId) : null}
|
||||
onAddRootChapter={canEdit ? () => openChapter("") : null}
|
||||
canAddChapter={canEdit}
|
||||
onMoveChapter={moveChapter}
|
||||
canReorder={canEdit && chapters.length > 1}
|
||||
links={[]}
|
||||
onNavigate={() => setStructureOpen(false)}
|
||||
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
||||
/>
|
||||
)}
|
||||
reader={entry ? (
|
||||
<ReadingPane
|
||||
binding={entry}
|
||||
@@ -459,7 +288,6 @@ export function CaseDetail() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="page-actions">
|
||||
{width < 1500 ? <button type="button" className="quiet" onClick={() => setStructureOpen(true)}>Struktur</button> : null}
|
||||
{canEdit ? (
|
||||
<button type="button" className="desktop-add" onClick={() => openAdd(chapterId)}>
|
||||
<NavIcon name="plus" /> Inhalt hinzufügen
|
||||
|
||||
Reference in new issue
Block a user