Zeige den Bezug zwischen Schreiben und lies eine E-Mail vor dem Uebernehmen.
Deploy Development / deploy (push) Successful in 27s
Test Suite / pytest-backend (push) Successful in 1m10s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 8s

Die Liste behaelt die Schreiben dazwischen. Richtung, Absender, Empfaenger und Anhaenge bleiben an der Nachricht erkennbar.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-17 17:27:17 +02:00
1 parent 97bffc6175
commit f27df3ff35
19 files changed
+1049 -49

No files matched your search

+132 -2
View File
@@ -250,10 +250,81 @@ function sourceLabel(element) {
return type;
}
export function mailFacts(element) {
if (element?.external?.source !== "imap") return "";
const detail = element.external.detail || {};
const way = detail.direction === "out" ? "Ausgang" : "Eingang";
const from = detail.message_from ? `von ${detail.message_from}` : "";
const to = detail.message_to ? `an ${detail.message_to}` : "";
const count = Array.isArray(detail.attachments) ? detail.attachments.length : 0;
const files = count ? `${count} ${count === 1 ? "Anhang" : "Anhänge"}` : "";
return [way, from, to, files].filter(Boolean).join(" · ");
}
function dateFlow(element) {
if (element?.external?.source === "imap") return "";
const dates = element?.dates || {};
if (dates.sent_on && dates.received_on) return "Eingang · Ausgang";
if (dates.sent_on) return "Ausgang";
if (dates.received_on) return "Eingang";
return "";
}
export function elementFacts(element) {
const type = sourceLabel(element);
const mail = mailFacts(element);
const flow = dateFlow(element);
return [type, mail, flow].filter(Boolean).join(" · ");
}
function directionMark(direction) {
if (direction === "out") return "Ausgang";
if (direction === "in") return "Eingang";
return "";
}
function blurb(element) {
return element.summary || element.excerpt || "";
}
function BezugLines({ element, source, onOpen, itemHref }) {
const refers = element.refers_to || [];
const replies = element.referred_by || [];
if (!refers.length && !replies.length) return null;
return (
<div className="bezug">
{refers.map((item) => (
<BezugLink key={`to-${item.id}`} item={item} label="Bezug auf" source={source} onOpen={onOpen} itemHref={itemHref} />
))}
{replies.map((item) => (
<BezugLink key={`by-${item.id}`} item={item} label="Darauf bezogen" source={source} onOpen={onOpen} itemHref={itemHref} reply />
))}
</div>
);
}
function BezugLink({ item, label, source, onOpen, itemHref, reply = false }) {
const found = source.find((entry) => entry.element?.id === item.id);
const href = found && itemHref ? itemHref(found) : "";
const className = reply ? "bezug__link bezug__link--reply" : "bezug__link";
const body = (
<>
<span>{label}</span>
<strong>{formatDate(item.document_on)} · {item.title}</strong>
{directionMark(item.direction) ? <em>{directionMark(item.direction)}</em> : null}
</>
);
if (found && onOpen) {
return (
<button type="button" className={className} onClick={() => onOpen(found)}>
{body}
</button>
);
}
if (href) return <Link className={className} to={href}>{body}</Link>;
return <p className={className}>{body}</p>;
}
function TypeGlyph({ name, tone, size = 28 }) {
return (
<img
@@ -355,6 +426,42 @@ export function ContentBoard({
const canDestroy = Boolean(record?.is_owner);
const canMoveChapters = Boolean(canSort && chapters.length > 1);
function actionContext() {
return context || (containerKind === "case" ? { kind: "case", id: containerId } : { kind: "matter", id: containerId });
}
async function setBezug(elementId, refersToId) {
if (!refersToId) return;
setPending(true);
setError("");
try {
await api(`/api/v1/elements/${elementId}/references`, {
method: "POST",
body: { refers_to_element_id: refersToId, context: actionContext() },
});
await onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}
async function clearBezug(elementId, refersToId) {
setPending(true);
setError("");
try {
const action = actionContext();
const search = new URLSearchParams({ context_kind: action.kind, context_id: action.id });
await api(`/api/v1/elements/${elementId}/references/${refersToId}?${search}`, { method: "DELETE" });
await onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}
async function removeBinding(binding, everywhere) {
const element = binding.element;
if (everywhere) {
@@ -781,8 +888,9 @@ export function ContentBoard({
const href = itemHref(binding);
const text = blurb(element);
const sourceSymbol = contentSourceSymbol(element);
const linked = (element.refers_to || []).length || (element.referred_by || []).length;
return (
<li key={binding.id} data-binding={binding.id} className={`preview-row${draggingId === binding.id ? " is-dragging" : ""}${selectedId === binding.id ? " is-selected" : ""}`}>
<li key={binding.id} data-binding={binding.id} className={`preview-row${linked ? " preview-row--linked" : ""}${draggingId === binding.id ? " is-dragging" : ""}${selectedId === binding.id ? " is-selected" : ""}`}>
{indicator?.sectionId === section.id && indicator?.kind !== "chapter" && indicator.index === index ? <div className="insert-line" /> : null}
{canSort && custom ? (
<button
@@ -822,7 +930,7 @@ export function ContentBoard({
<TypeGlyph name={sourceSymbol} tone="dark" size={16} />
</span>
) : null}
{formatDate(fachDate(element))} · {sourceLabel(element)}
{formatDate(fachDate(element))} · {elementFacts(element)}
</span>
{text ? <span className="preview-row__text">{text}</span> : null}
{binding.origin ? <span className="preview-row__origin">{binding.origin}{binding.shared ? " · weitere Einbindung" : ""}</span> : null}
@@ -830,8 +938,30 @@ export function ContentBoard({
<span className="preview-row__origin">Kapitel {(chapters.find((chapter) => chapter.id === binding.chapter_id)?.title) || ""}</span>
) : null}
</Link>
<BezugLines element={element} source={source} onOpen={onOpen} itemHref={itemHref} />
{(canEdit || (canSort && custom) || (canSort && chapters.length)) ? (
<div className="preview-row__actions">
{canEdit ? (
<details className="row-menu">
<summary>Bezug</summary>
<label>
Bezug auf
<select value="" disabled={pending} onChange={(event) => setBezug(element.id, event.target.value)}>
<option value="">Unterlage wählen</option>
{source.filter((item) => item.element?.id && item.element.id !== element.id).map((item) => (
<option key={item.element.id} value={item.element.id}>
{formatDate(item.element.dates?.document_on)} · {item.element.title}
</option>
))}
</select>
</label>
{(element.refers_to || []).map((item) => (
<button key={item.id} type="button" onClick={() => clearBezug(element.id, item.id)}>
Bezug auf {item.title} lösen
</button>
))}
</details>
) : null}
{canEdit ? (
<details className="row-menu">
<summary>Entfernen</summary>