Lege Anlagen und Belege an der Markierung ab, damit die Zeile schlank bleibt und das Verschieben seine eigene Linie behaelt.
Deploy Development / deploy (push) Successful in 26s
Test Suite / pytest-backend (push) Successful in 2m0s
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 11:03:01 +02:00
1 parent c774fb7206
commit be027a1025
3 files changed
+512 -307

No files matched your search

+122 -64
View File
@@ -18,14 +18,13 @@ import {
siblingChapterIds,
} from "./chapters.js";
import {
AttachDialog,
Chronology,
DispatchDialog,
EvidenceDialog,
hostMark,
restoreFold,
scopeBody,
unitMarks,
StructureAssignDialog,
UnitDetail,
writeAssign,
} from "./correspondence.jsx";
@@ -455,7 +454,7 @@ function MenuPopover({ open, anchorRef, onClose, label, children, sheet = false
);
}
export function DirectionControl({ direction = "", title, disabled = false, onChange }) {
export function DirectionControl({ direction = "", title, disabled = false, onChange, dropId = "" }) {
const anchorRef = useRef(null);
const [open, setOpen] = useState(false);
const known = directionWord(direction);
@@ -467,11 +466,12 @@ export function DirectionControl({ direction = "", title, disabled = false, onCh
anchorRef.current?.focus();
}
return (
<span className={`direction-column${direction === "local" ? " direction-column--local" : ""}`}>
<span className={`direction-column${direction === "local" ? " direction-column--local" : ""}`} data-use-drop={dropId || undefined}>
<button
ref={anchorRef}
type="button"
className="direction-trigger"
data-use-drop={dropId || undefined}
aria-label={name}
aria-haspopup="dialog"
aria-expanded={open}
@@ -772,7 +772,6 @@ function EntryActions({
onPlaceChapter,
onAttach,
onDispatch,
onEvidence,
}) {
const anchorRef = useRef(null);
const [open, setOpen] = useState(false);
@@ -840,9 +839,8 @@ function EntryActions({
) : null}
{canSort && custom ? <button type="button" disabled={pending || index === 0} onClick={() => { close(); onMove(binding.id, -1); }}>Nach oben</button> : null}
{canSort && custom ? <button type="button" disabled={pending || index === lastIndex} onClick={() => { close(); onMove(binding.id, 1); }}>Nach unten</button> : null}
{canEdit && onAttach ? <button type="button" onClick={() => { close(); onAttach(binding); }}>Anlage aus der Liste wählen</button> : null}
{canEdit && onAttach ? <button type="button" onClick={() => { close(); onAttach(binding); }}>Anlagen und Belege zuordnen</button> : null}
{canEdit && onDispatch ? <button type="button" onClick={() => { close(); onDispatch(binding); }}>Versand dokumentieren</button> : null}
{canEdit && onEvidence ? <button type="button" onClick={() => { close(); onEvidence(binding); }}>Als Beleg zuordnen …</button> : null}
{canEdit ? <button type="button" onClick={() => { close(); onRemove(binding, false); }}>Aus diesem Zusammenhang entfernen</button> : null}
{canEdit && canDestroy ? <button type="button" className="danger" onClick={() => { close(); onRemove(binding, true); }}>Überall löschen</button> : null}
</MenuPopover>
@@ -863,7 +861,11 @@ function TypeGlyph({ name, tone, size = 28 }) {
);
}
function EntryMark({ element, context, assignable = false, onAssignStart, onAssignEnd }) {
function useDropId(node) {
return node?.closest?.("[data-use-drop]")?.getAttribute("data-use-drop") || "";
}
function EntryMark({ element, context, assignable = false, dropId = "", onAssignStart, onAssignEnd }) {
const symbol = elementSymbol(element);
const photo = symbol === "image" && Boolean(element.preview?.available);
const [url, setUrl] = useState("");
@@ -887,6 +889,7 @@ function EntryMark({ element, context, assignable = false, onAssignStart, onAssi
return (
<span
className={url ? "entry-mark entry-mark--photo" : "entry-mark"}
data-use-drop={dropId || undefined}
draggable={assignable}
role={assignable ? "button" : undefined}
tabIndex={assignable ? 0 : undefined}
@@ -950,7 +953,6 @@ export function ContentBoard({
const [pending, setPending] = useState(false);
const [dialog, setDialog] = useState(null);
const [draggingId, setDraggingId] = useState("");
const [carry, setCarry] = useState(null);
const [indicator, setIndicator] = useState(null);
const [folded, setFolded] = useState(() => new Set());
const [picking, setPicking] = useState(false);
@@ -959,6 +961,7 @@ export function ContentBoard({
const dragRef = useRef(null);
const carryRef = useRef(null);
const releaseRef = useRef(null);
const placeUseRef = useRef(null);
const rootRef = useRef(null);
const savingDirection = useRef(false);
const custom = record?.content_order === "position";
@@ -1093,34 +1096,46 @@ export function ContentBoard({
const node = rootRef.current;
if (!node) return undefined;
function place(event) {
if (carryRef.current) {
const carried = carryRef.current;
if (carried) {
event.preventDefault();
const useId = useDropId(event.target);
if (useId && useId !== carried.bindingId) setIndicator({ kind: "use", bindingId: useId });
else setIndicator(null);
return;
}
const drag = dragRef.current;
if (!drag?.html5) return;
event.preventDefault();
if (drag.kind === "chapter") {
drag.useBindingId = null;
drag.index = chapterUnder(event.clientY, drag.parentId);
setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter", parentId: drag.parentId || "" });
return;
}
const useId = useDropId(event.target);
if (useId && useId !== drag.bindingId) {
drag.useBindingId = useId;
drag.index = null;
setIndicator({ kind: "use", bindingId: useId });
return;
}
drag.useBindingId = null;
const sectionId = event.target?.closest?.("[data-section]")?.getAttribute("data-section");
if (!sectionId) return;
drag.targetSectionId = sectionId;
drag.index = indexAt(sectionId, event.clientY);
setIndicator({ sectionId, index: drag.index });
setIndicator({ sectionId, index: drag.index, kind: "order" });
}
function drop(event) {
const carried = carryRef.current;
if (carried) {
if (event.target?.closest?.(".drop-well")) return;
if (carried.source === "attachment" || carried.source === "evidence") {
event.preventDefault();
releaseRef.current?.(carried);
}
const useId = useDropId(event.target);
event.preventDefault();
carryRef.current = null;
setCarry(null);
setIndicator(null);
if (useId) placeUseRef.current?.(useId, carried);
else if (carried.source === "attachment" || carried.source === "evidence") releaseRef.current?.(carried);
return;
}
if (!dragRef.current?.html5) return;
@@ -1384,6 +1399,24 @@ export function ContentBoard({
dragRef.current = null;
setDraggingId("");
setIndicator(null);
if (drag?.useBindingId && drag.bindingId && drag.useBindingId !== drag.bindingId) {
const host = source.find((item) => item.id === drag.useBindingId);
const item = source.find((item) => item.id === drag.bindingId);
if (host && item && host.element.id !== item.element.id) {
setDialog({
type: "place-use",
host,
binding: item,
payload: {
source: "list",
elementId: item.element.id,
bindingId: item.id,
title: item.element.title,
},
});
}
return;
}
if (!drag || !drag.moved || drag.index == null) return;
if (drag.kind === "chapter") {
const ids = siblingChapterIds(chapters, drag.chapterId);
@@ -1434,13 +1467,23 @@ export function ContentBoard({
if (event.clientY < 72) window.scrollBy(0, -16);
if (event.clientY > window.innerHeight - 72) window.scrollBy(0, 16);
if (drag.kind === "chapter") {
drag.useBindingId = null;
drag.index = chapterUnder(event.clientY, drag.parentId);
setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter", parentId: drag.parentId || "" });
return;
}
const useId = useDropId(document.elementFromPoint(event.clientX, event.clientY));
if (useId && useId !== drag.bindingId) {
drag.useBindingId = useId;
drag.index = null;
drag.moved = true;
setIndicator({ kind: "use", bindingId: useId });
return;
}
drag.useBindingId = null;
drag.targetSectionId = sectionUnder(event.clientY) || drag.sectionId;
drag.index = indexAt(drag.targetSectionId, event.clientY);
setIndicator({ sectionId: drag.targetSectionId, index: drag.index });
setIndicator({ sectionId: drag.targetSectionId, index: drag.index, kind: "order" });
}
function release(event) {
@@ -1485,12 +1528,11 @@ export function ContentBoard({
function beginCarry(payload) {
carryRef.current = payload;
setCarry(payload);
}
function endCarry() {
carryRef.current = null;
setCarry(null);
setIndicator(null);
}
function bindingByElement(elementId) {
@@ -1586,22 +1628,25 @@ export function ContentBoard({
}
}
function dropReceipt(hostBinding, payload, dispatch) {
if (!payload || payload.elementId === hostBinding.element.id) return;
if (payload.source === "evidence" && dispatch && payload.dispatchId === dispatch.id) return;
function openPlace(hostBindingId, payload) {
const host = source.find((item) => item.id === hostBindingId);
if (!host || !payload || host.element.id === payload.elementId) return;
if (payload.source === "attachment" && payload.hostElementId === host.element.id) return;
if (payload.source === "evidence") {
const found = dispatchOf(payload.dispatchId);
if (found?.host?.element.id === host.element.id) return;
}
const item = bindingByElement(payload.elementId);
const found = payload.source === "evidence" ? dispatchOf(payload.dispatchId) : null;
setDialog({
type: "evidence",
type: "place-use",
host,
binding: item || { element: { id: payload.elementId, title: payload.title || "Unterlage", version: 1 } },
hosts: [hostBinding],
dispatchId: dispatch ? dispatch.id : "",
replace: found && (!dispatch || found.dispatch.id !== dispatch.id)
? { dispatchId: found.dispatch.id, version: found.dispatch.version }
: null,
payload,
});
}
placeUseRef.current = openPlace;
function beginDrag(event, drag) {
if (pending || (event.button != null && event.button !== 0)) return;
event.preventDefault();
@@ -1666,7 +1711,7 @@ export function ContentBoard({
) : (
<p className="muted">Noch keine Unterlage und keine Notiz.</p>
)}
<Modal open={dialog?.type === "attach" || dialog?.type === "bulk"} title="Anlagen" onClose={() => setDialog(null)}>
<Modal wide open={dialog?.type === "attach" || dialog?.type === "bulk"} title={dialog?.type === "attach" ? "Anlagen und Belege" : "Anlagen"} onClose={() => setDialog(null)}>
{dialog?.type === "bulk" && !dialog.host ? (
<form className="stack" onSubmit={async (event) => {
event.preventDefault();
@@ -1707,9 +1752,10 @@ export function ContentBoard({
</form>
) : null}
{dialog?.type === "attach" && dialog.host ? (
<AttachDialog
<StructureAssignDialog
host={source.find((item) => item.id === dialog.host.id) || dialog.host}
candidates={source.filter((item) => item.element.id !== (source.find((entry) => entry.id === dialog.host.id) || dialog.host).element.id)}
bindings={source}
chapters={chapters}
scope={scopeBody(actionContext(), containerKind, containerId)}
pending={pending}
onClose={() => setDialog(null)}
@@ -1728,24 +1774,44 @@ export function ContentBoard({
/>
) : null}
</Modal>
<Modal open={dialog?.type === "receipt-source"} title="Beleg wählen" onClose={() => setDialog(null)}>
{dialog?.type === "receipt-source" ? (
<Modal open={dialog?.type === "place-use"} title="Ablegen" onClose={() => setDialog(null)}>
{dialog?.type === "place-use" ? (
<div className="stack">
<p>Unterlage aus diesem Vorgang als Beleg von <strong>{dialog.host.element.title}</strong>.</p>
<ul className="choice-list choice-list--scroll">
{source.filter((item) => item.element.id !== dialog.host.element.id).map((item) => (
<li key={item.id}>
<span>{item.element.title}</span>
<button type="button" onClick={() => setDialog({
type: "evidence",
binding: item,
hosts: [dialog.host],
dispatchId: dialog.dispatchId,
})}>Als Beleg</button>
</li>
))}
</ul>
{!source.filter((item) => item.element.id !== dialog.host.element.id).length ? <p className="muted">Keine weitere Unterlage.</p> : null}
<p><strong>{dialog.payload.title || dialog.binding.element.title}</strong> an <strong>{dialog.host.element.title}</strong></p>
<button type="button" disabled={pending} onClick={async () => {
await dropAttachment(dialog.host, dialog.payload);
setDialog(null);
}}>Als Anlage</button>
<button type="button" disabled={pending} onClick={async () => {
const payload = dialog.payload;
if (payload.source === "attachment") {
const from = bindingByElement(payload.hostElementId);
if (from) {
setPending(true);
setError("");
try {
await api(`/api/v1/elements/${from.element.id}/attachments/${payload.elementId}/detach`, {
method: "POST",
body: { expected_version: from.element.version, ...correspondenceScope() },
});
} catch (err) {
setError(err.message);
setPending(false);
return;
}
setPending(false);
}
}
const found = payload.source === "evidence" ? dispatchOf(payload.dispatchId) : null;
setDialog({
type: "evidence",
binding: dialog.binding,
hosts: [dialog.host],
dispatchId: dialog.host.correspondence?.dispatches?.[0]?.id || "",
replace: found ? { dispatchId: found.dispatch.id, version: found.dispatch.version } : null,
});
}}>Als Beleg</button>
<button type="button" className="quiet" onClick={() => setDialog(null)}>Abbrechen</button>
</div>
) : null}
</Modal>
@@ -1871,7 +1937,7 @@ export function ContentBoard({
const sourceSymbol = contentSourceSymbol(element);
const way = directionWord(binding.communication?.direction) || "Keine Angabe";
const party = counterpartLabel(element, binding.communication?.direction);
const facts = [party, formatDate(fachDate(element)), sourceLabel(element), way, unitMarks(binding)].filter(Boolean).join(" · ");
const facts = [party, formatDate(fachDate(element)), sourceLabel(element), way].filter(Boolean).join(" · ");
const samePiece = hostMark(binding);
const originText = binding.origin && section.title && !binding.origin.includes(section.title)
? `${binding.origin}${binding.shared ? " · weitere Einbindung" : ""}`
@@ -1881,6 +1947,7 @@ export function ContentBoard({
const rowClass = [
"preview-row",
draggingId === binding.id ? "is-dragging" : "",
indicator?.kind === "use" && indicator.bindingId === binding.id ? "is-use-target" : "",
selectedId === binding.id ? "is-selected" : "",
picking && picked.has(binding.id) ? "is-picked" : "",
picking ? "preview-row--picking" : "",
@@ -1893,7 +1960,7 @@ export function ContentBoard({
}
return (
<li key={binding.id} data-binding={binding.id} className={rowClass}>
{indicator?.sectionId === section.id && indicator?.kind !== "chapter" && indicator.index === index ? <div className="insert-line" /> : null}
{indicator?.kind === "order" && indicator?.sectionId === section.id && indicator.index === index ? <div className="insert-line" /> : null}
{picking ? (
<label className="pick-box">
<input
@@ -1914,6 +1981,7 @@ export function ContentBoard({
direction={directionValue(binding.communication)}
title={element.title}
disabled={pending}
dropId={binding.id}
onChange={(value) => saveRowDirection(binding, value)}
/>
) : (
@@ -1941,6 +2009,7 @@ export function ContentBoard({
<EntryMark
element={element}
context={context}
dropId={canEdit ? binding.id : ""}
assignable={canEdit && !pending && !picking}
onAssignStart={(event) => {
event.stopPropagation();
@@ -1988,7 +2057,6 @@ export function ContentBoard({
binding={binding}
canEdit={canEdit}
pending={pending}
carry={carry}
scope={scopeBody(actionContext(), containerKind, containerId)}
onCarryStart={beginCarry}
onCarryEnd={endCarry}
@@ -1996,15 +2064,6 @@ export function ContentBoard({
const found = source.find((item) => item.element?.id === elementId);
if (found) onOpen?.(found);
}}
onDropAttachment={(payload) => dropAttachment(binding, payload)}
onDropReceipt={(payload, dispatch) => dropReceipt(binding, payload, dispatch)}
onPickAttachments={() => setDialog({ type: "attach", host: binding })}
onPickReceipt={(dispatch) => setDialog({
type: "receipt-source",
host: binding,
dispatchId: dispatch ? dispatch.id : "",
})}
onDocumentDispatch={() => setDialog({ type: "dispatch", host: binding })}
onDetach={(elementId) => releaseToList({
source: "attachment",
elementId,
@@ -2051,12 +2110,11 @@ export function ContentBoard({
onPlaceChapter={placeChapter}
onAttach={(row) => setDialog({ type: "attach", host: row })}
onDispatch={(row) => setDialog({ type: "dispatch", host: row })}
onEvidence={(row) => setDialog({ type: "evidence", binding: row })}
/>
</li>
);
})}
{indicator?.sectionId === section.id && indicator?.kind !== "chapter" && indicator.index === section.items.length ? <li className="insert-line" aria-hidden="true" /> : null}
{indicator?.kind === "order" && indicator?.sectionId === section.id && indicator.index === section.items.length ? <li className="insert-line" aria-hidden="true" /> : null}
</ol> : null}
{expanded && section.children?.length ? (
<div className="chapter-children">