Ziehe die Struktur enger und merke die Paperless-Auswahl, damit Kapitel ohne Extraeintrag zuklappbar bleiben.
Deploy Development / deploy (push) Successful in 26s
Test Suite / pytest-backend (push) Successful in 1m23s
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 23:07:14 +02:00
1 parent deb5d662fe
commit f21c64a944
5 files changed
+97 -34

No files matched your search

+1
View File
@@ -445,6 +445,7 @@ export function MatterDetail() {
nodes={nodes}
chapters={chapters}
chapterId={chapterId}
allLabel=""
allCount={(record.bindings || []).length}
chapterHeading={`Kapitel in ${record.title}`}
onChapter={chooseChapter}
+24 -13
View File
@@ -135,17 +135,21 @@ function MailForm({ onSaved, onError }) {
);
}
function paperlessLabel(item) {
const dated = formatDate(item.document_on);
return dated !== "Ohne Datum" ? `${dated} · ${item.title}` : item.title;
}
export function PaperlessPicker({ context, placement, chapterId = "", chapterTitle = "", targetLabel = "", onDone, onInserted }) {
const [query, setQuery] = useState("");
const [items, setItems] = useState([]);
const [picked, setPicked] = useState(() => new Set());
const [picked, setPicked] = useState(() => new Map());
const [pending, setPending] = useState(false);
const [error, setError] = useState("");
async function search(event) {
event.preventDefault();
setError("");
setPicked(new Set());
try {
const data = await api(`/api/v1/sources/paperless/documents?q=${encodeURIComponent(query)}`);
setItems(data.items);
@@ -154,17 +158,18 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
}
}
function toggle(id) {
function toggle(item) {
const key = String(item.id);
setPicked((current) => {
const next = new Set(current);
if (next.has(id)) next.delete(id);
else next.add(id);
const next = new Map(current);
if (next.has(key)) next.delete(key);
else next.set(key, item);
return next;
});
}
async function linkMany() {
const chosen = items.filter((item) => picked.has(item.id));
const chosen = [...picked.values()];
if (!chosen.length) return;
setError("");
setPending(true);
@@ -191,7 +196,7 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
: {}),
},
});
inserted.push(item.id);
inserted.push(String(item.id));
}
} catch (err) {
setError(err.message);
@@ -199,9 +204,9 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
setPending(false);
}
if (inserted.length) {
setItems((current) => current.filter((item) => !inserted.includes(item.id)));
setItems((current) => current.filter((item) => !inserted.includes(String(item.id))));
setPicked((current) => {
const next = new Set(current);
const next = new Map(current);
inserted.forEach((id) => next.delete(id));
return next;
});
@@ -219,16 +224,22 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
</form>
<ErrorNote error={error} />
<p className="muted">Die Verbindung richtest du unter <Link to="/sources">Quellen</Link> ein. Mehrere Treffer lassen sich zusammen einfügen.</p>
{items.length ? (
{items.length || picked.size ? (
<button type="button" disabled={pending || picked.size === 0} onClick={linkMany}>
{picked.size ? `${picked.size} Belege einfügen` : "Belege auswählen"}
</button>
) : null}
<div className="stack">
{[...picked.values()].filter((item) => !items.some((entry) => String(entry.id) === String(item.id))).map((item) => (
<label key={`held-${item.id}`} className="paperless-pick">
<input type="checkbox" checked disabled={pending} onChange={() => toggle(item)} />
<span>{paperlessLabel(item)}</span>
</label>
))}
{items.map((item) => (
<label key={item.id} className="paperless-pick">
<input type="checkbox" checked={picked.has(item.id)} disabled={pending} onChange={() => toggle(item.id)} />
<span>{formatDate(item.document_on) !== "Ohne Datum" ? `${formatDate(item.document_on)} · ` : ""}{item.title}</span>
<input type="checkbox" checked={picked.has(String(item.id))} disabled={pending} onChange={() => toggle(item)} />
<span>{paperlessLabel(item)}</span>
</label>
))}
</div>
+14
View File
@@ -640,6 +640,20 @@ function ChapterHeading({
}
return (
<>
{real ? (
<button
type="button"
className="chapter-fold"
aria-expanded={expanded}
aria-label={expanded ? `${section.title} einklappen` : `${section.title} ausklappen`}
onClick={(event) => {
event.stopPropagation();
onToggle();
}}
>
{expanded ? "▾" : "▸"}
</button>
) : null}
<h3 className={`chapter-title${section.parentId ? " is-nested" : ""}`}>
{real ? <NavIcon name="chapter" /> : null}
<span>{section.title}</span>
+23 -13
View File
@@ -159,13 +159,15 @@ function scopeContents({ chapters, chapterId, allLabel, overview, onChapter, can
onSelect: overview.onSelect,
});
}
items.push({
id: "all-contents",
title: allLabel,
kind: "Inhalte",
current: !chapterId && !overview?.active,
onSelect: () => onChapter?.(""),
});
if (allLabel) {
items.push({
id: "all-contents",
title: allLabel,
kind: "Inhalte",
current: !chapterId && !overview?.active,
onSelect: () => onChapter?.(""),
});
}
const byParent = new Map();
chapters.forEach((chapter) => {
const key = chapter.parent_chapter_id || "";
@@ -192,16 +194,23 @@ function scopeContents({ chapters, chapterId, allLabel, overview, onChapter, can
return items;
}
function attachScope(nodes, extras) {
function attachScope(nodes, extras, onContainerSelect) {
return (nodes || []).map((node) => {
const children = attachScope(node.children, extras);
const children = attachScope(node.children, extras, onContainerSelect);
if (!node.current) return { ...node, children };
return { ...node, children: [...extras, ...children] };
const nested = [...extras, ...children];
const childCurrent = Boolean(onContainerSelect) && nested.some(branchHasCurrent);
return {
...node,
current: onContainerSelect ? !childCurrent : node.current,
...(onContainerSelect ? { onSelect: onContainerSelect } : {}),
children: nested,
};
});
}
function treeWithScope(nodes, extras) {
const attached = attachScope(nodes, extras);
function treeWithScope(nodes, extras, onContainerSelect) {
const attached = attachScope(nodes, extras, onContainerSelect);
if (attached.some(branchHasCurrent)) return attached;
return [...extras, ...attached];
}
@@ -224,7 +233,8 @@ export function StructureNavigator({
}) {
const [opened, setOpened] = useState(() => new Set());
const [closed, setClosed] = useState(() => new Set());
const tree = treeWithScope(nodes, scopeContents({ chapters, chapterId, allLabel, overview, onChapter, canReorder, onMoveChapter }));
const extras = scopeContents({ chapters, chapterId, allLabel, overview, onChapter, canReorder, onMoveChapter });
const tree = treeWithScope(nodes, extras, allLabel ? null : () => onChapter?.(""));
function isOpen(node, unfold) {
if (!node.children?.length) return false;
+35 -8
View File
@@ -581,6 +581,24 @@ button.nav-item:active { transform: none; }
border-radius: 8px;
}
.chapter-plus svg { width: 18px; height: 18px; }
.chapter-fold {
width: 28px;
min-width: 28px;
height: 28px;
min-height: 28px;
padding: 0;
display: inline-flex;
align-items: center;
justify-content: center;
flex: none;
border: 0;
border-radius: 6px;
background: transparent;
color: var(--brand);
font-size: 16px;
line-height: 1;
}
.chapter-fold:hover, .chapter-fold:focus-visible { background: var(--accent-light); }
.chapter-menu, .record-tools, .chapter-move { display: inline-flex; gap: 0; flex: 0 0 auto; align-items: center; }
.icon-button--compact { width: 32px; min-width: 32px; height: 32px; }
.icon-button--compact svg { width: 16px; height: 16px; }
@@ -1256,25 +1274,34 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
}
.chapter-link__move { display: flex; gap: 2px; flex: none; align-items: center; }
.chapter-link__move button {
min-height: 44px;
width: 44px;
height: 44px;
min-height: 28px;
width: 28px;
height: 28px;
padding: 0;
font-size: 16px;
font-size: 14px;
font-weight: 600;
background: transparent;
color: var(--text3);
border-radius: 4px;
}
.nav-tree__toggle {
width: 44px;
min-width: 44px;
height: 44px;
width: 22px;
min-width: 22px;
height: 28px;
min-height: 28px;
padding: 0;
border: 0;
border-radius: 4px;
background: transparent;
color: var(--text2);
font-size: 16px;
font-size: 13px;
line-height: 1;
}
.structure .chapter-add {
min-height: 32px;
padding: 4px 10px;
margin-top: 6px;
font-size: 13px;
}
.nav-tree__toggle.is-empty { visibility: hidden; }
.nav-tree__kind {