Verkuerze die Inhaltsliste und fuehre Unterkapitel ein, damit Richtung, Bezuge und Struktur ohne Zusatzzeilen bedienbar bleiben.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
eeeb81148a
commit
e4380261fc
30 files changed
+2384
-430
No files matched your search
@@ -2,13 +2,14 @@ import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { Link, useNavigate, useParams, useSearchParams } from "react-router-dom";
|
||||
import { api, markDirty, textToDocument } from "../api.js";
|
||||
import { SessionContext } from "../session.js";
|
||||
import { chapterPathLabel, siblingChapterIds, trailWithChapter } from "./chapters.js";
|
||||
import { Modal } from "./Modal.jsx";
|
||||
import { MailPicker, PaperlessPicker } from "./Sources.jsx";
|
||||
import { ErrorNote, ShareBox } from "./widgets.jsx";
|
||||
import { ContentBoard, DirectionChoice, MarkdownEditor, ObjectMenu, OrderChoice, RecordTree, 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 { IconButton, NavIcon } from "./icons.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
|
||||
export function CaseList() {
|
||||
const { session } = useContext(SessionContext);
|
||||
@@ -202,8 +203,8 @@ function matterOrigin(group) {
|
||||
}
|
||||
|
||||
function chapterOrigin(base, chapters, chapterId) {
|
||||
const title = (chapters || []).find((chapter) => chapter.id === chapterId)?.title;
|
||||
return title ? `${base} · Kapitel ${title}` : base;
|
||||
const path = chapterPathLabel(chapters, chapterId);
|
||||
return path ? `${base} · ${path}` : base;
|
||||
}
|
||||
|
||||
function mergedCaseItems(record, direction, caseId) {
|
||||
@@ -295,6 +296,7 @@ export function CaseDetail() {
|
||||
const [parentTree, setParentTree] = useState(null);
|
||||
const [error, setError] = useState("");
|
||||
const [modal, setModal] = useState("");
|
||||
const [chapterParentId, setChapterParentId] = useState("");
|
||||
const [view, setView] = useState("contents");
|
||||
const [dateDir, setDateDir] = useState("asc");
|
||||
const { width, structureOpen, setStructureOpen } = useWorkspaceLayout();
|
||||
@@ -434,8 +436,13 @@ export function CaseDetail() {
|
||||
setParams(updated, { replace: true });
|
||||
}
|
||||
|
||||
function openChapter(parentId = "") {
|
||||
setChapterParentId(parentId || "");
|
||||
setModal("chapter");
|
||||
}
|
||||
|
||||
async function moveChapter(chapterIdToMove, delta) {
|
||||
const ids = (record?.chapters || []).map((chapter) => chapter.id);
|
||||
const ids = siblingChapterIds(record?.chapters || [], chapterIdToMove);
|
||||
const index = ids.indexOf(chapterIdToMove);
|
||||
const target = index + delta;
|
||||
if (!record || index < 0 || target < 0 || target >= ids.length) return;
|
||||
@@ -488,7 +495,8 @@ export function CaseDetail() {
|
||||
overview={hasContained ? { active: overview, count: merged.length, onSelect: showOverview } : null}
|
||||
chapterHeading={`Kapitel in ${record.title}`}
|
||||
onChapter={chooseChapter}
|
||||
onAddChapter={canEdit ? () => setModal("chapter") : null}
|
||||
onAddChapter={canEdit ? () => openChapter(chapterId) : null}
|
||||
onAddRootChapter={canEdit ? () => openChapter("") : null}
|
||||
canAddChapter={canEdit}
|
||||
onMoveChapter={moveChapter}
|
||||
canReorder={canEdit && chapters.length > 1}
|
||||
@@ -515,17 +523,10 @@ export function CaseDetail() {
|
||||
>
|
||||
<header className="workspace-head">
|
||||
<div>
|
||||
<Trail items={record.trail} />
|
||||
<Trail items={trailWithChapter(record.trail, record.chapters, overview ? "" : chapterId, `/cases/${id}`)} />
|
||||
<div className="title-row">
|
||||
<h1>{record.title}</h1>
|
||||
<span className={record.status === "open" ? "status-pill" : "status-pill is-closed"}>{record.status === "open" ? "Offen" : "Geschlossen"}</span>
|
||||
{record.rights.edit ? (
|
||||
<span className="record-tools">
|
||||
<IconButton name="pencil" label="Umbenennen" onClick={renameCase} />
|
||||
<IconButton name={record.status === "closed" ? "restore" : "archive"} label={record.status === "closed" ? "Wieder öffnen" : "Archivieren"} onClick={archiveCase} />
|
||||
<IconButton name="trash" label="Löschen" onClick={deleteCase} />
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="page-actions">
|
||||
@@ -536,6 +537,9 @@ export function CaseDetail() {
|
||||
</button>
|
||||
) : null}
|
||||
<ObjectMenu view={view} onView={setView}>
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={renameCase}>Umbenennen</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={archiveCase}>{record.status === "closed" ? "Wieder öffnen" : "Archivieren"}</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="danger" onClick={deleteCase}>Löschen</button> : null}
|
||||
{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}
|
||||
@@ -569,7 +573,8 @@ export function CaseDetail() {
|
||||
containerId={id}
|
||||
onlyChapter={chapterId}
|
||||
selectedId={entryId}
|
||||
listTitle={activeChapter ? activeChapter.title : "Direkt in dieser Akte"}
|
||||
listTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : "Direkt in dieser Akte"}
|
||||
onAddSubchapter={canEdit ? openChapter : null}
|
||||
context={context}
|
||||
onOpen={openEntry}
|
||||
onChange={load}
|
||||
@@ -611,7 +616,8 @@ export function CaseDetail() {
|
||||
<p className="muted">Dieser Inhalt liegt direkt in der Akte. Er erscheint unter „Direkt in dieser Akte“ und im Überblick, nicht in einem Vorgang.</p>
|
||||
<TargetLine label={targetLabel} chapters={record.chapters} chapterId={activeChapter?.id || ""} />
|
||||
<div className="add-choices">
|
||||
<button type="button" onClick={() => setModal("chapter")}>Kapitel</button>
|
||||
<button type="button" onClick={() => openChapter(activeChapter?.id || "")}>{activeChapter ? "Unterkapitel" : "Kapitel"}</button>
|
||||
{activeChapter ? <button type="button" onClick={() => openChapter("")}>Kapitel auf oberster Ebene</button> : null}
|
||||
<button type="button" onClick={() => setModal("note")}>Notiz</button>
|
||||
<button type="button" onClick={() => setModal("file")}>Datei</button>
|
||||
<button type="button" onClick={() => setModal("paperless")}>Paperless</button>
|
||||
@@ -625,17 +631,19 @@ export function CaseDetail() {
|
||||
<FileForm context={context} chapters={record.chapters} initialChapter={activeChapter?.id || ""} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "paperless"} title="Aus Paperless" onClose={() => setModal("")}>
|
||||
<PaperlessPicker context={context} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter?.title || ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
<PaperlessPicker context={context} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "mail"} title="E-Mail verbinden" wide split onClose={() => setModal("")}>
|
||||
<MailPicker context={context} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter?.title || ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
<MailPicker context={context} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "subcase"} title="Unterakte anlegen" onClose={() => setModal("")}>
|
||||
<NewSubcase parentId={id} onChange={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "chapter"} title={`Kapitel in ${targetLabel} hinzufügen`} onClose={() => setModal("")}>
|
||||
<Modal open={modal === "chapter"} title={chapterParentId ? `Unterkapitel in ${targetLabel}` : `Kapitel in ${targetLabel}`} onClose={() => setModal("")}>
|
||||
<ChapterForm
|
||||
path={`/api/v1/cases/${id}/chapters`}
|
||||
targetLabel={targetLabel}
|
||||
parentChapter={chapterParentId ? { id: chapterParentId, title: chapterPathLabel(record.chapters, chapterParentId) } : null}
|
||||
onChange={(created) => {
|
||||
setModal("");
|
||||
if (created?.id) {
|
||||
@@ -802,11 +810,11 @@ function caseTrail(record, caseId, group, scope, chapter) {
|
||||
href: chapter ? `/cases/${caseId}?bereich=${group.matter_id}` : null,
|
||||
});
|
||||
}
|
||||
if (chapter && (group || scope === "direct")) items.push({ label: `Kapitel ${chapter.title}`, href: null });
|
||||
if (chapter && (group || scope === "direct")) items.push({ label: chapter.title, href: null });
|
||||
return items;
|
||||
}
|
||||
|
||||
export function ChapterForm({ path, onChange }) {
|
||||
export function ChapterForm({ path, onChange, targetLabel = "", parentChapter = null }) {
|
||||
const [title, setTitle] = useState("");
|
||||
const [dated, setDated] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
@@ -815,7 +823,14 @@ export function ChapterForm({ path, onChange }) {
|
||||
event.preventDefault();
|
||||
setError("");
|
||||
try {
|
||||
const created = await api(path, { method: "POST", body: { title, ...(dated ? { document_on: dated } : {}) } });
|
||||
const created = await api(path, {
|
||||
method: "POST",
|
||||
body: {
|
||||
title,
|
||||
...(dated ? { document_on: dated } : {}),
|
||||
...(parentChapter?.id ? { parent_chapter_id: parentChapter.id } : {}),
|
||||
},
|
||||
});
|
||||
setTitle("");
|
||||
setDated("");
|
||||
onChange(created);
|
||||
@@ -826,7 +841,11 @@ export function ChapterForm({ path, onChange }) {
|
||||
|
||||
return (
|
||||
<form onSubmit={submit} className="stack compact">
|
||||
<label>Titel <input value={title} onChange={(event) => setTitle(event.target.value)} placeholder="Kapitel" required /></label>
|
||||
{targetLabel ? <p className="target-line">Ziel: <strong>{targetLabel}</strong></p> : null}
|
||||
<p className="target-line">
|
||||
{parentChapter ? <>Elternkapitel: <strong>{parentChapter.title}</strong></> : <>Ebene: <strong>oberste Kapitel</strong></>}
|
||||
</p>
|
||||
<label>Titel <input value={title} onChange={(event) => setTitle(event.target.value)} placeholder={parentChapter ? "Unterkapitel" : "Kapitel"} required /></label>
|
||||
<label>Fachliches Datum, optional <input type="date" value={dated} onChange={(event) => setDated(event.target.value)} /></label>
|
||||
<button type="submit">Hinzufügen</button>
|
||||
<ErrorNote error={error} />
|
||||
@@ -852,7 +871,7 @@ function chapterSelect(chapters, value, setValue) {
|
||||
<select value={value} onChange={(event) => setValue(event.target.value)}>
|
||||
<option value="">Ohne Kapitel</option>
|
||||
{chapters.map((chapter) => (
|
||||
<option key={chapter.id} value={chapter.id}>{chapter.title}</option>
|
||||
<option key={chapter.id} value={chapter.id}>{chapterPathLabel(chapters, chapter.id)}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
Reference in new issue
Block a user