Halte den Zug an der ganzen Zeile fest und zaehle im Dialog nur die sichtbaren Unterlagen, damit das Ablegen ankommt und Einzelbelege nicht doppelt erscheinen.
Deploy Development / deploy (push) Successful in 26s
Test Suite / pytest-backend (push) Successful in 1m36s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 8s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-18 12:59:52 +02:00
1 parent 20fa183c1c
commit f8cb9f8d4b
3 files changed
+174 -68

No files matched your search

+25 -10
View File
@@ -153,7 +153,14 @@ function selectionState(ids, selected) {
}
export function StructureAssignDialog({ host, bindings, chapters, scope, pending, onClose, onDone }) {
const tree = useMemo(() => buildChapterSections(chapters, bindings), [chapters, bindings]);
const visibleBindings = useMemo(
() => (bindings || []).filter((item) => !item.correspondence?.fold),
[bindings],
);
const tree = useMemo(() => buildChapterSections(chapters, visibleBindings), [chapters, visibleBindings]);
const receiptIds = useMemo(() => new Set(
(host.correspondence?.dispatches || []).flatMap((item) => (item.evidence || []).map((proof) => proof.element_id)),
), [host]);
const [opened, setOpened] = useState(() => new Set(host.chapter_id ? ancestorIds(chapters, host.chapter_id) : ["loose"]));
const [query, setQuery] = useState("");
const [selected, setSelected] = useState(() => new Set());
@@ -192,8 +199,12 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
});
}
function selectable(id) {
return id !== host.element.id && !taken.has(id) && !receiptIds.has(id);
}
function toggleChapter(section) {
toggleIds(branchItems(section).map((item) => item.element.id).filter((id) => id !== host.element.id));
toggleIds(branchItems(section).map((item) => item.element.id).filter(selectable));
}
function visibleIds() {
@@ -201,19 +212,19 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
function walk(section) {
if (!branchVisible(section, needle)) return;
for (const item of section.items || []) {
if (item.element.id !== host.element.id && titleMatches(item, needle)) ids.push(item.element.id);
if (selectable(item.element.id) && titleMatches(item, needle)) ids.push(item.element.id);
}
for (const child of section.children || []) walk(child);
}
tree.roots.forEach(walk);
for (const item of tree.loose) {
if (item.element.id !== host.element.id && titleMatches(item, needle)) ids.push(item.element.id);
if (selectable(item.element.id) && titleMatches(item, needle)) ids.push(item.element.id);
}
return ids;
}
async function saveAttachments() {
const ids = [...selected].filter((id) => id !== host.element.id && !taken.has(id));
const ids = [...selected].filter((id) => selectable(id));
if (!ids.length) {
setError("In der Auswahl ist keine neue Anlage.");
return;
@@ -241,7 +252,7 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
async function saveReceipts(event) {
event.preventDefault();
const ids = [...selected].filter((id) => id !== host.element.id);
const ids = [...selected].filter((id) => selectable(id));
if (!ids.length) return;
setBusy(true);
setError("");
@@ -298,12 +309,14 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
const notes = [
formatDate(item.element.dates?.document_on),
isHost ? "dieses Schriftstück" : "",
taken.has(id) ? "Anlage" : "",
taken.has(id) ? "bereits Anlage" : "",
receiptIds.has(id) ? "bereits Beleg" : "",
].filter(Boolean).join(" · ");
const blocked = isHost || taken.has(id) || receiptIds.has(id);
return (
<li key={item.id}>
<label className="pick-tree__row">
<PickBox checked={selected.has(id)} disabled={isHost} label={item.element.title} onChange={() => toggle(id)} />
<PickBox checked={selected.has(id)} disabled={blocked} label={item.element.title} onChange={() => toggle(id)} />
<span className="pick-tree__title">{item.element.title}</span>
<span className="pick-tree__kind">{notes}</span>
</label>
@@ -316,7 +329,7 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
const expanded = Boolean(needle) || opened.has(section.id);
const counts = sectionCounts(section);
const total = counts.direct + counts.nested;
const ids = branchItems(section).map((item) => item.element.id).filter((id) => id !== host.element.id);
const ids = branchItems(section).map((item) => item.element.id).filter(selectable);
const state = selectionState(ids, selected);
return (
<li key={section.id}>
@@ -360,7 +373,7 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
const loose = tree.loose.filter((item) => titleMatches(item, needle));
const roots = tree.roots.map((section) => renderSection(section, 0)).filter(Boolean);
const looseIds = loose.map((item) => item.element.id).filter((id) => id !== host.element.id);
const looseIds = loose.map((item) => item.element.id).filter(selectable);
const looseState = selectionState(looseIds, selected);
const looseOpen = Boolean(needle) || opened.has("loose");
@@ -799,6 +812,7 @@ export function UnitDetail({
source: "attachment",
elementId: item.element_id,
hostElementId: binding.element.id,
hostBindingId: binding.id,
bindingId: item.binding_id || "",
title: item.title,
}, onCarryStart)}
@@ -831,6 +845,7 @@ export function UnitDetail({
elementId: proof.element_id,
dispatchId: item.id,
hostElementId: binding.element.id,
hostBindingId: binding.id,
version: item.version,
title: proof.title,
}, onCarryStart)}