Lege einen Beleg ohne Versandfassung ab und markiere das Zurueckziehen, damit der Drop an der Markierung ankommt und ein Nachweis kein E-Mail-Versand wird.
Deploy Development / deploy (push) Successful in 28s
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 12:01:19 +02:00
1 parent 9f5327f3be
commit 7846830765
6 files changed
+241 -158

No files matched your search

+44 -64
View File
@@ -45,18 +45,6 @@ export function hostMark(binding) {
return `Dieselbe Unterlage · Anlage zu ${hosts.map((item) => item.title).join(", ")}`;
}
function snapshotHref(dispatchId, itemId, scope) {
const search = new URLSearchParams({
context_kind: scope.context.kind,
context_id: scope.context.id,
});
if (scope.placement) {
search.set("placement_kind", scope.placement.kind);
search.set("placement_id", scope.placement.id);
}
return `/api/v1/dispatches/${dispatchId}/items/${itemId}/content?${search}`;
}
function fieldBody(scope, extra) {
const body = { ...extra, context: scope.context };
if (scope.placement) body.placement = scope.placement;
@@ -76,6 +64,25 @@ export function receiptRoleLabel(role, fallback = "") {
return RECEIPT_ROLES.find((item) => item[0] === role)?.[1] || fallback || role;
}
function receiptCaption(proof) {
if (proof.role === "email" && proof.kind === "file") return "Beleg";
return receiptRoleLabel(proof.role, proof.role_label);
}
function isShipment(item) {
const proofs = item.evidence || [];
if (item.channel === "other") return false;
if (proofs.length > 0 && proofs.every((proof) => proof.kind === "file")) return false;
return (item.items || []).length > 0;
}
function receiptHeading(item) {
const who = item.counterpart ? ` · ${item.counterpart}` : "";
if (!isShipment(item)) return `${item.sent_on ? formatDate(item.sent_on) : "Beleg"}${who}`;
const when = item.undated ? "undatiert" : formatDate(item.sent_on);
return `Versand ${when} · ${item.channel_label}${who}`;
}
export function writeAssign(event, payload) {
event.dataTransfer.effectAllowed = "copyMove";
event.dataTransfer.setData(ASSIGN_MIME, JSON.stringify(payload));
@@ -145,10 +152,10 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
const [query, setQuery] = useState("");
const [selected, setSelected] = useState(() => new Set());
const [step, setStep] = useState("pick");
const [role, setRole] = useState("email");
const [role, setRole] = useState("other");
const [fold, setFold] = useState("evidence");
const [dispatchId, setDispatchId] = useState(host.correspondence?.dispatches?.[0]?.id || "");
const [channel, setChannel] = useState("email");
const [channel, setChannel] = useState("other");
const [sentOn, setSentOn] = useState("");
const [counterpart, setCounterpart] = useState("");
const [error, setError] = useState("");
@@ -241,9 +248,10 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
channel,
sent_on: sentOn || null,
counterpart: counterpart.trim() || null,
attachment_element_ids: (host.correspondence?.attachments || []).map((item) => item.element_id),
attachment_element_ids: [],
evidence: ids.map((id) => ({ element_id: id, role, fold })),
historical_gap: false,
capture_editions: false,
}),
});
} else {
@@ -565,9 +573,9 @@ export function EvidenceDialog({ element, hosts, scope, pending, presetDispatchI
const [dispatchId, setDispatchId] = useState(
presetDispatchId !== undefined ? presetDispatchId : (host?.correspondence?.dispatches?.[0]?.id || ""),
);
const [role, setRole] = useState("email");
const [role, setRole] = useState("other");
const [fold, setFold] = useState("evidence");
const [channel, setChannel] = useState("email");
const [channel, setChannel] = useState("other");
const [sentOn, setSentOn] = useState("");
const [counterpart, setCounterpart] = useState("");
const [result, setResult] = useState(null);
@@ -593,9 +601,10 @@ export function EvidenceDialog({ element, hosts, scope, pending, presetDispatchI
channel,
sent_on: sentOn || null,
counterpart: counterpart.trim() || null,
attachment_element_ids: (host.correspondence?.attachments || []).map((item) => item.element_id),
attachment_element_ids: [],
evidence: [{ element_id: element.id, role, fold }],
historical_gap: false,
capture_editions: false,
}),
});
const proof = (created.evidence || []).find((item) => item.element_id === element.id);
@@ -698,23 +707,11 @@ export function ComparisonList({ comparisons = [], state, reason }) {
);
}
function chipDrag(enabled, payload, onCarryStart, onCarryEnd) {
function chipPointer(enabled, payload, onCarryStart) {
if (!enabled) return {};
return {
draggable: enabled,
onDragStart(event) {
if (event.target.closest("button, a")) {
event.preventDefault();
return;
}
event.stopPropagation();
payload.anchorX = event.clientX;
payload.anchorY = event.clientY;
event.currentTarget.dataset.dragged = "1";
writeAssign(event, payload);
onCarryStart?.(payload);
},
onDragEnd(event) {
onCarryEnd?.(event);
onPointerDown(event) {
onCarryStart?.(event, payload);
},
};
}
@@ -743,13 +740,11 @@ export function UnitDetail({
binding,
canEdit,
pending,
scope,
onOpen,
onDetach,
onDetachEvidence,
onUnfold,
onCarryStart,
onCarryEnd,
children,
}) {
const pack = binding.correspondence || {};
@@ -761,12 +756,14 @@ export function UnitDetail({
return typeof children === "function" ? children(null, null) : null;
}
const evidenceCount = dispatches.reduce((sum, item) => sum + (item.evidence || []).length, 0);
const shipmentCount = dispatches.filter(isShipment).length;
const attachmentLabel = attachments.length === 1 ? "1 Anlage" : `${attachments.length} Anlagen`;
const receiptParts = [];
if (dispatches.length === 1) receiptParts.push("1 Versand");
else if (dispatches.length > 1) receiptParts.push(`${dispatches.length} Versände`);
if (shipmentCount === 1) receiptParts.push("1 Versand");
else if (shipmentCount > 1) receiptParts.push(`${shipmentCount} Versände`);
if (evidenceCount === 1) receiptParts.push("1 Beleg");
else if (evidenceCount > 1) receiptParts.push(`${evidenceCount} Belege`);
const receiptLabel = receiptParts.join(" · ");
const switches = (
<span className="unit-switches">
{attachments.length ? (
@@ -776,7 +773,7 @@ export function UnitDetail({
) : null}
{dispatches.length ? (
<button type="button" className="unit-switch" aria-expanded={receiptsOpen} onClick={() => setReceiptsOpen((value) => !value)}>
{receiptParts.join(" · ") || "Belege"}
{receiptLabel || "Belege"}
</button>
) : null}
</span>
@@ -792,13 +789,13 @@ export function UnitDetail({
key={item.id}
className="use-chip"
data-carry={`attachment:${item.element_id}`}
{...(canEdit ? chipDrag(!pending, {
{...chipPointer(canEdit && !pending, {
source: "attachment",
elementId: item.element_id,
hostElementId: binding.element.id,
bindingId: item.binding_id || "",
title: item.title,
}, onCarryStart, onCarryEnd) : {})}
}, onCarryStart)}
>
{canEdit ? <span className="use-chip__grip" aria-hidden="true" /> : null}
<span className="use-chip__title" {...openTitleProps(() => onOpen(item.element_id))}>
@@ -815,10 +812,7 @@ export function UnitDetail({
) : null}
{receiptsOpen ? dispatches.map((item) => (
<section key={item.id}>
<h4>
Versand {item.undated ? "undatiert" : formatDate(item.sent_on)} · {item.channel_label}
{item.counterpart ? ` · ${item.counterpart}` : ""}
</h4>
<h4>{receiptHeading(item)}</h4>
{item.evidence?.length ? (
<ul>
{item.evidence.map((proof) => (
@@ -826,18 +820,18 @@ export function UnitDetail({
key={proof.id}
className="use-chip"
data-carry={`evidence:${proof.element_id}`}
{...(canEdit ? chipDrag(!pending, {
{...chipPointer(canEdit && !pending, {
source: "evidence",
elementId: proof.element_id,
dispatchId: item.id,
hostElementId: binding.element.id,
version: item.version,
title: proof.title,
}, onCarryStart, onCarryEnd) : {})}
}, onCarryStart)}
>
{canEdit ? <span className="use-chip__grip" aria-hidden="true" /> : null}
<span className="use-chip__title" {...openTitleProps(() => onOpen(proof.element_id))}>
{receiptRoleLabel(proof.role, proof.role_label)}: {proof.title}
{receiptCaption(proof)}: {proof.title}
</span>
<span className="muted">{formatDate(proof.document_on)}</span>
{proof.source_state === "gap" ? <span>Lücke: {proof.gap_reason}</span> : null}
@@ -854,21 +848,7 @@ export function UnitDetail({
</li>
))}
</ul>
) : <p className="muted">Ohne Beleg</p>}
<details className="use-editions">
<summary>Gesicherte Fassung</summary>
<ol>
{item.items.map((part) => (
<li key={part.id}>
<span>{part.role === "host" ? "Schreiben" : "Anlage"}: {part.title}</span>
<span className="muted">{formatDate(part.document_on)}</span>
{part.source_state === "gap" ? <span>Lücke: {part.gap_reason}</span> : scope ? (
<a href={snapshotHref(item.id, part.id, scope)}>Öffnen</a>
) : <span>Gesichert</span>}
</li>
))}
</ol>
</details>
) : <p className="muted">Ohne Beleg</p>}
</section>
)) : null}
</div>
@@ -899,7 +879,7 @@ export function Chronology({ bindings, direction, itemHref, selectedId, onOpen }
events.push({
key: `send-${dispatch.id}`,
date: dispatch.sent_on || "",
label: "Versand",
label: isShipment(dispatch) ? "Versand" : "Beleg",
title: binding.element?.title || "",
detail: [
dispatch.undated ? "Versand undatiert" : `Versanddatum ${formatDate(dispatch.sent_on)}`,