Mache die Inhaltsliste zur einen Arbeitsflaeche mit Vorschauzeilen, damit Pfad, Herkunft und eigene Reihenfolge im Alltag erhalten bleiben.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
52bda91aad
commit
3465ed57f6
16 files changed
+1375
-314
No files matched your search
+196
-65
@@ -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(); }} />
|
||||
|
||||
Reference in new issue
Block a user