Zeige im Breadcrumb die Aktenstruktur und lass Kapitel samt Inhalt an ihren Ort ziehen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
cafa4e8b92
commit
7ef73ad500
12 files changed
+627
-93
No files matched your search
@@ -314,22 +314,20 @@ export function CaseDetail() {
|
||||
<main className="page">
|
||||
<header className="page-head">
|
||||
<div>
|
||||
<Trail items={record.trail} />
|
||||
<Trail items={caseTrail(record, id, group, scope, activeChapter)} />
|
||||
<p className="eyebrow">{record.kind_label || "Akte"} · {record.home_scope_name}</p>
|
||||
<h1>{record.title}</h1>
|
||||
<p className="muted">{record.status === "open" ? "Offen" : "Geschlossen"}</p>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="page-actions">
|
||||
{target?.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}
|
||||
{target?.edit ? <button type="button" className="quiet" onClick={() => setModal("chapter")}>Kapitel hinzufügen</button> : null}
|
||||
{!target ? <p className="muted">Für ein Kapitel zuerst einen Bereich wählen.</p> : null}
|
||||
{target && !target.edit ? <p className="muted">In {target.label} fehlt das Bearbeitungsrecht.</p> : null}
|
||||
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
|
||||
</ObjectMenu>
|
||||
{target && !target.edit ? <p className="muted">In {target.label} fehlt das Bearbeitungsrecht.</p> : null}
|
||||
</div>
|
||||
</header>
|
||||
<ErrorNote error={error} />
|
||||
@@ -420,7 +418,8 @@ export function CaseDetail() {
|
||||
</Modal>
|
||||
<Modal open={modal === "add" && Boolean(target)} title={target ? `Hinzufügen in ${target.label}` : "Hinzufügen"} onClose={() => setModal("")}>
|
||||
<TargetLine label={target?.label} chapters={target?.chapters} chapterId={activeChapter?.id || ""} />
|
||||
<div className="choice">
|
||||
<div className="add-choices">
|
||||
<button type="button" onClick={() => setModal("chapter")}>Kapitel</button>
|
||||
<button type="button" onClick={() => setModal("note")}>Notiz</button>
|
||||
<button type="button" onClick={() => setModal("file")}>Datei</button>
|
||||
<button type="button" onClick={() => setModal("paperless")}>Paperless</button>
|
||||
@@ -600,16 +599,33 @@ function NewSubcase({ parentId, onChange }) {
|
||||
);
|
||||
}
|
||||
|
||||
function caseTrail(record, caseId, group, scope, chapter) {
|
||||
const extended = Boolean(group) || (scope === "direct" && chapter);
|
||||
const items = (record.trail || []).map((item, index, all) => (
|
||||
extended && index === all.length - 1 ? { ...item, href: `/cases/${caseId}` } : item
|
||||
));
|
||||
if (group) {
|
||||
items.push({
|
||||
label: `${group.kind_label || "Vorgang"} ${group.title}`,
|
||||
href: chapter ? `/cases/${caseId}?bereich=${group.matter_id}` : null,
|
||||
});
|
||||
}
|
||||
if (chapter && (group || scope === "direct")) items.push({ label: `Kapitel ${chapter.title}`, href: null });
|
||||
return items;
|
||||
}
|
||||
|
||||
export function ChapterForm({ path, onChange }) {
|
||||
const [title, setTitle] = useState("");
|
||||
const [dated, setDated] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function submit(event) {
|
||||
event.preventDefault();
|
||||
setError("");
|
||||
try {
|
||||
const created = await api(path, { method: "POST", body: { title } });
|
||||
const created = await api(path, { method: "POST", body: { title, ...(dated ? { document_on: dated } : {}) } });
|
||||
setTitle("");
|
||||
setDated("");
|
||||
onChange(created);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
@@ -617,8 +633,9 @@ export function ChapterForm({ path, onChange }) {
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={submit} className="inline">
|
||||
<input value={title} onChange={(event) => setTitle(event.target.value)} placeholder="Kapitel" required />
|
||||
<form onSubmit={submit} className="stack compact">
|
||||
<label>Titel <input value={title} onChange={(event) => setTitle(event.target.value)} placeholder="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} />
|
||||
</form>
|
||||
|
||||
@@ -79,6 +79,15 @@ export function MatterList() {
|
||||
);
|
||||
}
|
||||
|
||||
function matterTrail(record, chapter, href) {
|
||||
if (!chapter) return record.trail;
|
||||
const items = (record.trail || []).map((item, index, all) => (
|
||||
index === all.length - 1 ? { ...item, href } : item
|
||||
));
|
||||
items.push({ label: `Kapitel ${chapter.title}`, href: null });
|
||||
return items;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -214,21 +223,20 @@ export function MatterDetail() {
|
||||
<main className="page">
|
||||
<header className="page-head">
|
||||
<div>
|
||||
<Trail items={record.trail} />
|
||||
<Trail items={matterTrail(record, activeChapter, `/matters/${id}${query}`)} />
|
||||
<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>
|
||||
<div className="row">
|
||||
<div className="page-actions">
|
||||
{canEdit ? <button type="button" onClick={() => setModal("add")}>Inhalt hinzufügen</button> : null}
|
||||
<ObjectMenu view={view} onView={setView}>
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("submatter")}>Teilvorgang anlegen</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("cross")}>Querverweis</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("chapter")}>Kapitel hinzufügen</button> : null}
|
||||
{!canEdit ? <p className="muted">In {targetLabel} fehlt das Bearbeitungsrecht.</p> : null}
|
||||
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
|
||||
</ObjectMenu>
|
||||
{!canEdit ? <p className="muted">In {targetLabel} fehlt das Bearbeitungsrecht.</p> : null}
|
||||
</div>
|
||||
</header>
|
||||
<ErrorNote error={error} />
|
||||
@@ -291,7 +299,8 @@ export function MatterDetail() {
|
||||
</Modal>
|
||||
<Modal open={modal === "add"} title={`Hinzufügen in ${targetLabel}`} onClose={() => setModal("")}>
|
||||
<TargetLine label={targetLabel} chapters={record.chapters} chapterId={activeChapter?.id || ""} />
|
||||
<div className="choice">
|
||||
<div className="add-choices">
|
||||
<button type="button" onClick={() => setModal("chapter")}>Kapitel</button>
|
||||
<button type="button" onClick={() => setModal("note")}>Notiz</button>
|
||||
<button type="button" onClick={() => setModal("file")}>Datei</button>
|
||||
<button type="button" onClick={() => setModal("paperless")}>Paperless</button>
|
||||
|
||||
@@ -197,6 +197,86 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
);
|
||||
}
|
||||
|
||||
function folderTree(folders) {
|
||||
const roots = [];
|
||||
const stack = [];
|
||||
for (const folder of folders) {
|
||||
const node = { ...folder, children: [] };
|
||||
while (stack.length && stack[stack.length - 1].depth >= folder.depth) stack.pop();
|
||||
if (stack.length) stack[stack.length - 1].node.children.push(node);
|
||||
else roots.push(node);
|
||||
stack.push({ depth: folder.depth, node });
|
||||
}
|
||||
return roots;
|
||||
}
|
||||
|
||||
function ancestorNames(folders, name) {
|
||||
const folder = folders.find((item) => item.name === name);
|
||||
if (!folder?.delimiter || !name.includes(folder.delimiter)) return [];
|
||||
const parts = name.split(folder.delimiter);
|
||||
const names = [];
|
||||
for (let index = 1; index < parts.length; index += 1) names.push(parts.slice(0, index).join(folder.delimiter));
|
||||
return names;
|
||||
}
|
||||
|
||||
function FolderBranch({ node, mailbox, expanded, onToggle, onSelect }) {
|
||||
const open = expanded.has(node.name);
|
||||
const current = node.name === mailbox;
|
||||
return (
|
||||
<li>
|
||||
<div className={current ? "folder-row is-current" : "folder-row"}>
|
||||
{node.children.length ? (
|
||||
<button type="button" className="folder-twist" aria-expanded={open} aria-label={open ? `${node.label} zuklappen` : `${node.label} aufklappen`} onClick={() => onToggle(node.name)}>
|
||||
{open ? "▾" : "▸"}
|
||||
</button>
|
||||
) : <span className="folder-twist" aria-hidden="true" />}
|
||||
{node.selectable ? (
|
||||
<button type="button" className="folder-name" aria-current={current ? "true" : undefined} onClick={() => onSelect(node.name)}>{node.label}</button>
|
||||
) : (
|
||||
<span className="folder-name">{node.label}</span>
|
||||
)}
|
||||
</div>
|
||||
{node.children.length && open ? (
|
||||
<ul>
|
||||
{node.children.map((child) => (
|
||||
<FolderBranch key={child.name} node={child} mailbox={mailbox} expanded={expanded} onToggle={onToggle} onSelect={onSelect} />
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function FolderTree({ folders, mailbox, onSelect }) {
|
||||
const [expanded, setExpanded] = useState(() => new Set());
|
||||
useEffect(() => {
|
||||
setExpanded((current) => {
|
||||
const next = new Set(current);
|
||||
for (const name of ancestorNames(folders, mailbox)) next.add(name);
|
||||
return next;
|
||||
});
|
||||
}, [folders, mailbox]);
|
||||
const roots = folderTree(folders);
|
||||
function toggle(name) {
|
||||
setExpanded((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(name)) next.delete(name);
|
||||
else next.add(name);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
if (!roots.length) return <p className="muted">Keine Fächer.</p>;
|
||||
return (
|
||||
<nav className="mailbox__folders" aria-label="Fächer">
|
||||
<ul className="folder-tree">
|
||||
{roots.map((node) => (
|
||||
<FolderBranch key={node.name} node={node} mailbox={mailbox} expanded={expanded} onToggle={toggle} onSelect={onSelect} />
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
export function MailPicker({ context, placement, chapterId = "", chapterTitle = "", targetLabel = "", onDone }) {
|
||||
const [accounts, setAccounts] = useState([]);
|
||||
const [accountId, setAccountId] = useState("");
|
||||
@@ -346,24 +426,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
</label>
|
||||
{!accounts.length ? <p className="muted">Lege zuerst ein E-Mail-Konto unter <Link to="/sources">Quellen</Link> an.</p> : null}
|
||||
<div className="mailbox">
|
||||
<nav className="mailbox__folders" aria-label="Fächer">
|
||||
{folders.map((folder) => (
|
||||
folder.selectable ? (
|
||||
<button
|
||||
key={folder.name}
|
||||
type="button"
|
||||
className={folder.name === mailbox ? "" : "quiet"}
|
||||
style={{ paddingLeft: 12 + folder.depth * 14 }}
|
||||
aria-current={folder.name === mailbox ? "true" : undefined}
|
||||
onClick={() => setMailbox(folder.name)}
|
||||
>
|
||||
{folder.label}
|
||||
</button>
|
||||
) : (
|
||||
<span key={folder.name} className="mailbox__group" style={{ paddingLeft: 12 + folder.depth * 14 }}>{folder.label}</span>
|
||||
)
|
||||
))}
|
||||
</nav>
|
||||
<FolderTree folders={folders} mailbox={mailbox} onSelect={setMailbox} />
|
||||
<div className="mailbox__messages">
|
||||
<form onSubmit={search} className="inline">
|
||||
<input value={draft} onChange={(event) => setDraft(event.target.value)} placeholder="Im gewählten Fach suchen" aria-label="Im gewählten Fach suchen" />
|
||||
|
||||
+198
-24
@@ -152,12 +152,13 @@ function sectionsOf(chapters, bindings) {
|
||||
const sections = (chapters || []).map((chapter) => ({
|
||||
id: chapter.id,
|
||||
title: chapter.title,
|
||||
documentOn: chapter.document_on || "",
|
||||
items: buckets.get(chapter.id) || [],
|
||||
}));
|
||||
if (sections.length && loose.length) {
|
||||
sections.push({ id: "loose", title: "Ohne Kapitel", items: loose });
|
||||
sections.push({ id: "loose", title: "Ohne Kapitel", documentOn: "", items: loose });
|
||||
} else if (!sections.length) {
|
||||
sections.push({ id: "loose", title: "", items: loose });
|
||||
sections.push({ id: "loose", title: "", documentOn: "", items: loose });
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
@@ -195,8 +196,8 @@ export function ObjectMenu({ view, onView, children }) {
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<button type="button" className="quiet" onClick={() => setOpen(true)}>Menü</button>
|
||||
<Modal open={open} title="Menü" onClose={() => setOpen(false)}>
|
||||
<button type="button" className="quiet" onClick={() => setOpen(true)}>Aktionen</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>
|
||||
<button type="button" className={view === "audit" ? "" : "quiet"} onClick={() => choose("audit")}>Änderungsprotokoll</button>
|
||||
@@ -319,14 +320,14 @@ export function ContentBoard({
|
||||
}
|
||||
}
|
||||
|
||||
async function persist(next) {
|
||||
async function persist(next, version = record.version) {
|
||||
setError("");
|
||||
setPending(true);
|
||||
try {
|
||||
await api(`${orderPath}/bindings/order`, {
|
||||
method: "POST",
|
||||
body: {
|
||||
expected_version: record.version,
|
||||
expected_version: version,
|
||||
binding_ids: next.flatMap((section) => section.items.map((item) => item.id)),
|
||||
...orderContext,
|
||||
},
|
||||
@@ -339,6 +340,48 @@ export function ContentBoard({
|
||||
}
|
||||
}
|
||||
|
||||
async function reorderChapters(ids) {
|
||||
setError("");
|
||||
setPending(true);
|
||||
try {
|
||||
await api(`${orderPath}/chapters/order`, {
|
||||
method: "POST",
|
||||
body: { expected_version: record.version, chapter_ids: ids, ...orderContext },
|
||||
});
|
||||
onChange();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}
|
||||
|
||||
function moveChapter(chapterId, delta) {
|
||||
const ids = chapters.map((chapter) => chapter.id);
|
||||
const index = ids.indexOf(chapterId);
|
||||
const target = index + delta;
|
||||
if (index < 0 || target < 0 || target >= ids.length) return;
|
||||
const [id] = ids.splice(index, 1);
|
||||
ids.splice(target, 0, id);
|
||||
reorderChapters(ids);
|
||||
}
|
||||
|
||||
async function saveChapterDate(chapterId, value) {
|
||||
setError("");
|
||||
setPending(true);
|
||||
try {
|
||||
await api(`/api/v1/chapters/${chapterId}`, {
|
||||
method: "PATCH",
|
||||
body: { expected_version: record.version, document_on: value || null, ...orderContext },
|
||||
});
|
||||
onChange();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function move(bindingId, delta) {
|
||||
const next = sections.map((section) => ({ ...section, items: [...section.items] }));
|
||||
let moved = false;
|
||||
@@ -379,24 +422,73 @@ export function ContentBoard({
|
||||
return rows.length;
|
||||
}
|
||||
|
||||
function sectionUnder(clientY) {
|
||||
const nodes = [...(rootRef.current?.querySelectorAll("[data-section]") || [])];
|
||||
const hit = nodes.find((node) => {
|
||||
const rect = node.getBoundingClientRect();
|
||||
return clientY >= rect.top && clientY <= rect.bottom;
|
||||
});
|
||||
return hit?.getAttribute("data-section") || null;
|
||||
}
|
||||
|
||||
function chapterIndexAt(clientY) {
|
||||
const nodes = [...(rootRef.current?.querySelectorAll("[data-chapter]") || [])];
|
||||
for (let i = 0; i < nodes.length; i += 1) {
|
||||
const rect = nodes[i].getBoundingClientRect();
|
||||
if (clientY < rect.top + rect.height / 2) return i;
|
||||
}
|
||||
return nodes.length;
|
||||
}
|
||||
|
||||
function finishDrag(drag) {
|
||||
dragRef.current = null;
|
||||
setDraggingId("");
|
||||
setIndicator(null);
|
||||
if (!drag || !drag.moved || drag.index == null) return;
|
||||
if (drag.kind === "chapter") {
|
||||
const ids = chapters.map((chapter) => chapter.id);
|
||||
const from = ids.indexOf(drag.chapterId);
|
||||
if (from < 0) return;
|
||||
let target = drag.index;
|
||||
if (from < target) target -= 1;
|
||||
if (target < 0) target = 0;
|
||||
if (target > ids.length - 1) target = ids.length - 1;
|
||||
if (target === from) return;
|
||||
const [id] = ids.splice(from, 1);
|
||||
ids.splice(target, 0, id);
|
||||
reorderChapters(ids);
|
||||
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);
|
||||
const source = next.find((item) => item.id === drag.sectionId);
|
||||
const targetSection = next.find((item) => item.id === (drag.targetSectionId || drag.sectionId));
|
||||
if (!source || !targetSection) return;
|
||||
const from = source.items.findIndex((item) => item.id === drag.bindingId);
|
||||
if (from < 0) return;
|
||||
let target = drag.index;
|
||||
if (from < target) target -= 1;
|
||||
if (source.id === targetSection.id && 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);
|
||||
if (target > targetSection.items.length) target = targetSection.items.length;
|
||||
if (source.id === targetSection.id && target === from) return;
|
||||
const [item] = source.items.splice(from, 1);
|
||||
const nextChapter = targetSection.id === "loose" ? null : targetSection.id;
|
||||
const changed = (item.chapter_id || null) !== nextChapter;
|
||||
item.chapter_id = nextChapter;
|
||||
const insertAt = source.id === targetSection.id ? target : Math.min(target, targetSection.items.length);
|
||||
targetSection.items.splice(insertAt, 0, item);
|
||||
if (!changed) {
|
||||
persist(next);
|
||||
return;
|
||||
}
|
||||
setPending(true);
|
||||
setError("");
|
||||
api(`/api/v1/bindings/${item.id}/chapter`, {
|
||||
method: "PATCH",
|
||||
body: { expected_version: record.version, chapter_id: nextChapter, ...orderContext },
|
||||
}).then((moved) => persist(next, moved.version)).catch((err) => {
|
||||
setError(err.message);
|
||||
setPending(false);
|
||||
});
|
||||
}
|
||||
|
||||
function track(event) {
|
||||
@@ -405,8 +497,14 @@ export function ContentBoard({
|
||||
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 });
|
||||
if (drag.kind === "chapter") {
|
||||
drag.index = chapterIndexAt(event.clientY);
|
||||
setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter" });
|
||||
return;
|
||||
}
|
||||
drag.targetSectionId = sectionUnder(event.clientY) || drag.sectionId;
|
||||
drag.index = indexAt(drag.targetSectionId, event.clientY);
|
||||
setIndicator({ sectionId: drag.targetSectionId, index: drag.index });
|
||||
}
|
||||
|
||||
function release(event) {
|
||||
@@ -439,26 +537,51 @@ export function ContentBoard({
|
||||
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 };
|
||||
dragRef.current = { pointerId: "html5", bindingId, sectionId, targetSectionId: sectionId, startY: event.clientY, moved: true, index: null, html5: true };
|
||||
setDraggingId(bindingId);
|
||||
}
|
||||
|
||||
function onChapterDragStart(event, chapterId) {
|
||||
event.dataTransfer.effectAllowed = "move";
|
||||
event.dataTransfer.setData("text/plain", chapterId);
|
||||
dragRef.current = { kind: "chapter", pointerId: "html5", chapterId, startY: event.clientY, moved: true, index: null, html5: true };
|
||||
setDraggingId(chapterId);
|
||||
}
|
||||
|
||||
function onDragOver(event, sectionId) {
|
||||
const drag = dragRef.current;
|
||||
if (!drag?.html5 || drag.sectionId !== sectionId) return;
|
||||
if (!drag?.html5 || drag.kind === "chapter") return;
|
||||
event.preventDefault();
|
||||
drag.targetSectionId = sectionId;
|
||||
drag.index = indexAt(sectionId, event.clientY);
|
||||
setIndicator({ sectionId, index: drag.index });
|
||||
}
|
||||
|
||||
function onChapterDragOver(event) {
|
||||
const drag = dragRef.current;
|
||||
if (!drag?.html5 || drag.kind !== "chapter") return;
|
||||
event.preventDefault();
|
||||
drag.index = chapterIndexAt(event.clientY);
|
||||
setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter" });
|
||||
}
|
||||
|
||||
function onDrop(event, sectionId) {
|
||||
const drag = dragRef.current;
|
||||
if (!drag?.html5 || drag.sectionId !== sectionId) return;
|
||||
if (!drag?.html5 || drag.kind === "chapter") return;
|
||||
event.preventDefault();
|
||||
drag.targetSectionId = sectionId;
|
||||
drag.index = indexAt(sectionId, event.clientY);
|
||||
finishDrag(drag);
|
||||
}
|
||||
|
||||
function onChapterDrop(event) {
|
||||
const drag = dragRef.current;
|
||||
if (!drag?.html5 || drag.kind !== "chapter") return;
|
||||
event.preventDefault();
|
||||
drag.index = chapterIndexAt(event.clientY);
|
||||
finishDrag(drag);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="contents" ref={rootRef}>
|
||||
{canSort ? (
|
||||
@@ -478,12 +601,63 @@ export function ContentBoard({
|
||||
visibleSections.map((section) => (
|
||||
<section
|
||||
key={section.id}
|
||||
className="content-section"
|
||||
className={indicator?.kind === "chapter" && indicator.index === chapters.findIndex((chapter) => chapter.id === section.id) ? "content-section is-chapter-target" : "content-section"}
|
||||
data-section={section.id}
|
||||
onDragOver={(event) => onDragOver(event, section.id)}
|
||||
onDrop={(event) => onDrop(event, section.id)}
|
||||
data-chapter={section.id === "loose" ? undefined : section.id}
|
||||
onDragOver={(event) => {
|
||||
if (dragRef.current?.kind === "chapter") onChapterDragOver(event);
|
||||
else onDragOver(event, section.id);
|
||||
}}
|
||||
onDrop={(event) => {
|
||||
if (dragRef.current?.kind === "chapter") onChapterDrop(event);
|
||||
else onDrop(event, section.id);
|
||||
}}
|
||||
>
|
||||
{section.title ? <h3 className="chapter-title">{section.title}</h3> : null}
|
||||
{section.title ? (
|
||||
<div className="chapter-head">
|
||||
{canSort && custom && section.id !== "loose" && !onlyChapter ? (
|
||||
<button
|
||||
type="button"
|
||||
className="handle"
|
||||
aria-label={`${section.title} verschieben`}
|
||||
draggable={!pending}
|
||||
disabled={pending}
|
||||
onPointerDown={(event) => {
|
||||
if (event.button != null && event.button !== 0) return;
|
||||
dragRef.current = { kind: "chapter", pointerId: event.pointerId, chapterId: section.id, startY: event.clientY, moved: false, index: null };
|
||||
setDraggingId(section.id);
|
||||
window.addEventListener("pointermove", track);
|
||||
window.addEventListener("pointerup", release);
|
||||
window.addEventListener("pointercancel", cancel);
|
||||
}}
|
||||
onDragStart={(event) => onChapterDragStart(event, section.id)}
|
||||
onDragEnd={cancel}
|
||||
>
|
||||
<span className="handle__grip" aria-hidden="true" />
|
||||
</button>
|
||||
) : null}
|
||||
<h3 className="chapter-title">{section.title}</h3>
|
||||
{section.documentOn ? <span className="muted">{formatDate(section.documentOn)}</span> : null}
|
||||
{canSort && custom && section.id !== "loose" && !onlyChapter ? (
|
||||
<span className="chapter-move">
|
||||
<button type="button" className="quiet" aria-label={`${section.title} nach oben`} disabled={pending || chapters[0]?.id === section.id} onClick={() => moveChapter(section.id, -1)}>Nach oben</button>
|
||||
<button type="button" className="quiet" aria-label={`${section.title} nach unten`} disabled={pending || chapters[chapters.length - 1]?.id === section.id} onClick={() => moveChapter(section.id, 1)}>Nach unten</button>
|
||||
</span>
|
||||
) : null}
|
||||
{canSort && section.id !== "loose" ? (
|
||||
<label className="chapter-date">
|
||||
Datum
|
||||
<input
|
||||
type="date"
|
||||
aria-label={`Datum für ${section.title}`}
|
||||
value={section.documentOn || ""}
|
||||
disabled={pending}
|
||||
onChange={(event) => saveChapterDate(section.id, event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{section.title && !section.items.length ? <p className="muted">Noch nichts in diesem Kapitel.</p> : null}
|
||||
<ol className="preview-list">
|
||||
{section.items.map((binding, index) => {
|
||||
|
||||
+27
-10
@@ -405,7 +405,8 @@ 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: 15px; margin-bottom: 10px; }
|
||||
.trail { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-size: 15px; margin-bottom: 10px; }
|
||||
.trail > span { display: inline-flex; gap: 6px; align-items: center; }
|
||||
.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: 2px; }
|
||||
@@ -413,9 +414,12 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
.hierarchy__line { display: flex; align-items: center; gap: 8px; }
|
||||
.hierarchy__line .hierarchy__row { flex: 1; }
|
||||
.hierarchy__open { flex: 0 0 auto; font-size: 13px; }
|
||||
.hierarchy__row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; min-height: 34px; padding: 6px 8px; text-decoration: none; color: inherit; border-radius: 8px; }
|
||||
.hierarchy__row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 8px; align-items: baseline; min-height: 32px; padding: 5px 8px; text-decoration: none; color: inherit; border-radius: 8px; }
|
||||
.hierarchy__row.is-current { background: var(--accent-light); box-shadow: inset 3px 0 0 var(--accent); }
|
||||
.hierarchy__kind { min-width: 5.6rem; color: var(--accent-dark); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
|
||||
.hierarchy__kind { color: var(--text3); font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
|
||||
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
|
||||
.add-choices { display: grid; gap: 8px; }
|
||||
.add-choices button { min-height: 44px; justify-content: flex-start; }
|
||||
.hierarchy__parent { margin-bottom: 8px; }
|
||||
.order-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
|
||||
.order-bar button { min-height: 44px; }
|
||||
@@ -435,7 +439,21 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
.content-row__title { font-weight: 650; }
|
||||
.content-row__kind { color: var(--text3); font-size: 13px; }
|
||||
.content-row__move { display: flex; gap: 4px; }
|
||||
.chapter-title { margin: 22px 0 4px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text3); }
|
||||
.chapter-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 18px; }
|
||||
.chapter-title { margin: 22px 0 4px; font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--text1); font-weight: 700; }
|
||||
.chapter-head .chapter-title { margin: 0; flex: 1 1 8rem; }
|
||||
.chapter-date { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text3); font-size: 13px; }
|
||||
.chapter-date input { width: auto; }
|
||||
.chapter-move { display: flex; gap: 4px; }
|
||||
.chapter-move button { min-height: 32px; padding: 4px 8px; font-size: 13px; }
|
||||
.content-section.is-chapter-target { box-shadow: inset 0 3px 0 var(--accent); }
|
||||
.folder-tree, .folder-tree ul { list-style: none; margin: 0; padding: 0; }
|
||||
.folder-tree ul { margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--border); }
|
||||
.folder-row { display: flex; align-items: center; gap: 2px; min-height: 32px; border-radius: 6px; }
|
||||
.folder-row.is-current { background: var(--accent-light); }
|
||||
.folder-twist, .folder-name { background: transparent; border: 0; color: inherit; min-height: 32px; padding: 0; }
|
||||
.folder-twist { width: 28px; }
|
||||
.folder-name { flex: 1; text-align: left; padding: 4px 8px; font: inherit; font-weight: 600; cursor: pointer; }
|
||||
.order-choice { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; max-width: 36rem; font-size: 14px; }
|
||||
.order-choice select { width: auto; min-width: 16rem; flex: 1; }
|
||||
.target-line { margin: 0; color: var(--text2); overflow-wrap: break-word; }
|
||||
@@ -571,9 +589,9 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
.menu-list button { width: 100%; justify-content: flex-start; }
|
||||
.placements { margin: 4px 0 0; overflow-wrap: anywhere; }
|
||||
.reader-preview { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); }
|
||||
.mailbox { display: grid; grid-template-columns: minmax(9rem, 14rem) minmax(0, 1fr); gap: 16px; align-items: start; }
|
||||
.mailbox__folders { display: grid; gap: 6px; align-content: start; }
|
||||
.mailbox__folders button { justify-content: flex-start; text-align: left; width: 100%; }
|
||||
.mailbox { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 16px; align-items: stretch; min-height: 420px; }
|
||||
.mailbox__folders { border-right: 1px solid var(--border); padding-right: 8px; max-height: 60vh; overflow: auto; }
|
||||
.mailbox__folders { display: block; }
|
||||
.mailbox__group { min-height: 32px; display: flex; align-items: center; color: var(--text3); font-size: 13px; font-weight: 650; }
|
||||
.mailbox__messages { display: grid; gap: 10px; min-width: 0; }
|
||||
.mail-list { display: grid; }
|
||||
@@ -614,9 +632,8 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
.outline__body { display: none; }
|
||||
.outline.is-open .outline__body { display: block; }
|
||||
.outline__toggle { display: inline-flex; margin-bottom: 8px; }
|
||||
.mailbox { grid-template-columns: 1fr; }
|
||||
.mailbox__folders { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-bottom: 4px; }
|
||||
.mailbox__folders button, .mailbox__group { width: auto; }
|
||||
.mailbox { grid-template-columns: 1fr; min-height: 0; }
|
||||
.mailbox__folders { display: block; max-height: 240px; overflow: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 8px; }
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
|
||||
Reference in new issue
Block a user