Zeige den Bezug zwischen Schreiben und lies eine E-Mail vor dem Uebernehmen.
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:
1 parent
97bffc6175
commit
f27df3ff35
19 files changed
+1049
-49
No files matched your search
@@ -469,6 +469,10 @@ export function CaseDetail() {
|
||||
onReload={load}
|
||||
canDetach={canEdit}
|
||||
canDestroy={Boolean(record.is_owner)}
|
||||
onOpenRelated={(elementId) => {
|
||||
const found = (record.bindings || []).find((item) => item.element?.id === elementId);
|
||||
if (found) openEntry(found);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
>
|
||||
@@ -815,6 +819,8 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = "
|
||||
const [title, setTitle] = useState("");
|
||||
const [text, setText] = useState("");
|
||||
const [documentOn, setDocumentOn] = useState("");
|
||||
const [sentOn, setSentOn] = useState("");
|
||||
const [receivedOn, setReceivedOn] = useState("");
|
||||
const [chapterId, setChapterId] = useState(initialChapter);
|
||||
const [error, setError] = useState("");
|
||||
const [pending, setPending] = useState(false);
|
||||
@@ -835,12 +841,20 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = "
|
||||
context,
|
||||
...(placement ? { placement } : {}),
|
||||
...(chapterId ? { chapter_id: chapterId } : {}),
|
||||
...(documentOn ? { dates: { document_on: documentOn } } : {}),
|
||||
...(documentOn || sentOn || receivedOn ? {
|
||||
dates: {
|
||||
document_on: documentOn || null,
|
||||
sent_on: sentOn || null,
|
||||
received_on: receivedOn || null,
|
||||
},
|
||||
} : {}),
|
||||
},
|
||||
});
|
||||
setTitle("");
|
||||
setText("");
|
||||
setDocumentOn("");
|
||||
setSentOn("");
|
||||
setReceivedOn("");
|
||||
markDirty(false);
|
||||
onChange();
|
||||
} catch (err) {
|
||||
@@ -857,6 +871,8 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = "
|
||||
<label>Titel <input value={title} onChange={(event) => { setTitle(event.target.value); markDirty(true); }} required /></label>
|
||||
<label>Gemeinsamer Text <textarea rows={4} value={text} onChange={(event) => { setText(event.target.value); markDirty(true); }} /></label>
|
||||
<label>Bezugsdatum, optional <input type="date" value={documentOn} onChange={(event) => setDocumentOn(event.target.value)} /></label>
|
||||
<label>Versand, optional <input type="date" value={sentOn} onChange={(event) => setSentOn(event.target.value)} /></label>
|
||||
<label>Zugang, optional <input type="date" value={receivedOn} onChange={(event) => setReceivedOn(event.target.value)} /></label>
|
||||
{chapterSelect(chapters, chapterId, setChapterId)}
|
||||
<button type="submit" disabled={pending}>{pending ? "Wird angelegt …" : "Notiz anlegen"}</button>
|
||||
<ErrorNote error={error} />
|
||||
|
||||
@@ -408,6 +408,10 @@ export function MatterDetail() {
|
||||
onReload={load}
|
||||
canDetach={canEdit}
|
||||
canDestroy={Boolean(record.is_owner)}
|
||||
onOpenRelated={(elementId) => {
|
||||
const found = (record.bindings || []).find((item) => item.element?.id === elementId);
|
||||
if (found) openEntry(found);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
>
|
||||
|
||||
@@ -1,13 +1,62 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { documentToText, fetchFile, fetchPaperless, markDirty, textToDocument, api } from "../api.js";
|
||||
import { ErrorNote } from "./widgets.jsx";
|
||||
import { formatDate, kindLabel } from "./content.jsx";
|
||||
import { elementFacts, formatDate } from "./content.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
||||
|
||||
const SCALES = [0.75, 1, 1.25, 1.5, 2];
|
||||
|
||||
export function ReadingPane({ binding, context, backLabel, onClose, onReload, canDetach, canDestroy }) {
|
||||
function MailAttachments({ files }) {
|
||||
if (!files?.length) return <p className="muted">Keine Anhänge.</p>;
|
||||
return (
|
||||
<ul className="mail-files">
|
||||
{files.map((file) => <li key={file.filename}>{file.filename}</li>)}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function Correspondence({ element, onOpenRelated }) {
|
||||
const refers = element.refers_to || [];
|
||||
const replies = element.referred_by || [];
|
||||
if (!refers.length && !replies.length) return null;
|
||||
const current = {
|
||||
id: element.id,
|
||||
title: element.title,
|
||||
document_on: element.dates?.document_on || null,
|
||||
direction: element.external?.detail?.direction || (element.dates?.sent_on && !element.dates?.received_on ? "out" : element.dates?.received_on && !element.dates?.sent_on ? "in" : null),
|
||||
current: true,
|
||||
};
|
||||
const seen = new Set();
|
||||
const items = [];
|
||||
for (const item of [...refers, current, ...replies]) {
|
||||
if (seen.has(item.id)) continue;
|
||||
seen.add(item.id);
|
||||
items.push({ ...item, current: item.id === element.id });
|
||||
}
|
||||
items.sort((left, right) => String(left.document_on || "9999-99-99").localeCompare(String(right.document_on || "9999-99-99")));
|
||||
return (
|
||||
<section className="schriftwechsel" aria-label="Schriftwechsel">
|
||||
<h3>Schriftwechsel</h3>
|
||||
<p>Verbundene Schreiben bleiben als Bezug sichtbar. Weitere Schreiben, die dazwischen ein- oder ausgegangen sind, bleiben in der Liste an ihrer eigenen Stelle.</p>
|
||||
{items.map((item) => (
|
||||
<button
|
||||
key={item.id}
|
||||
type="button"
|
||||
className={item.current ? "schriftwechsel__item is-current" : "schriftwechsel__item"}
|
||||
disabled={item.current || !onOpenRelated}
|
||||
onClick={() => onOpenRelated?.(item.id)}
|
||||
>
|
||||
<span>{formatDate(item.document_on)}</span>
|
||||
<strong>{item.current ? `${item.title} · diese Unterlage` : item.title}</strong>
|
||||
<em>{item.direction === "out" ? "Ausgang" : item.direction === "in" ? "Eingang" : ""}</em>
|
||||
</button>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function ReadingPane({ binding, context, backLabel, onClose, onReload, canDetach, canDestroy, onOpenRelated }) {
|
||||
const element = binding?.element;
|
||||
const [error, setError] = useState("");
|
||||
const [phase, setPhase] = useState("idle");
|
||||
@@ -21,8 +70,11 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
const [note, setNote] = useState("");
|
||||
const [summary, setSummary] = useState("");
|
||||
const [documentOn, setDocumentOn] = useState("");
|
||||
const [sentOn, setSentOn] = useState("");
|
||||
const [receivedOn, setReceivedOn] = useState("");
|
||||
const [notice, setNotice] = useState("");
|
||||
const [annotate, setAnnotate] = useState(false);
|
||||
const [letter, setLetter] = useState(null);
|
||||
const canvasRef = useRef(null);
|
||||
const closeRef = useRef(null);
|
||||
|
||||
@@ -34,6 +86,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
if (!element) return undefined;
|
||||
setText(element.kind === "note" ? documentToText(element.document) : "");
|
||||
setDocumentOn(element.dates?.document_on || "");
|
||||
setSentOn(element.dates?.sent_on || "");
|
||||
setReceivedOn(element.dates?.received_on || "");
|
||||
setSummary(element.summary || "");
|
||||
setError("");
|
||||
setNotice("");
|
||||
@@ -41,16 +95,18 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
setPdf(null);
|
||||
setPages(0);
|
||||
setMedia("");
|
||||
setPhase(element.kind === "note" ? "ready" : element.preview?.available ? "loading" : "missing");
|
||||
setLetter(null);
|
||||
const mail = element.external?.source === "imap";
|
||||
setPhase(element.kind === "note" || mail ? "ready" : element.preview?.available ? "loading" : "missing");
|
||||
return undefined;
|
||||
}, [element?.id, element?.version]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!element || element.kind === "note" || !element.preview?.available) return undefined;
|
||||
if (!element || element.kind === "note" || element.external?.source === "imap" || !element.preview?.available) return undefined;
|
||||
let alive = true;
|
||||
let url = "";
|
||||
setPhase("loading");
|
||||
const load = element.kind === "external_ref" ? fetchPaperless(element.id, context) : fetchFile(element.id, context);
|
||||
const load = element.external?.source === "paperless" ? fetchPaperless(element.id, context) : fetchFile(element.id, context);
|
||||
load.then(async (blob) => {
|
||||
if (!alive) return;
|
||||
url = URL.createObjectURL(blob);
|
||||
@@ -93,7 +149,27 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
alive = false;
|
||||
if (url) URL.revokeObjectURL(url);
|
||||
};
|
||||
}, [element?.id, element?.preview?.available, context?.kind, context?.id]);
|
||||
}, [element?.id, element?.kind, element?.external?.source, element?.preview?.available, context?.kind, context?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!element || element.external?.source !== "imap") return undefined;
|
||||
let alive = true;
|
||||
const params = new URLSearchParams();
|
||||
if (context?.kind && context?.id) {
|
||||
params.set("context_kind", context.kind);
|
||||
params.set("context_id", context.id);
|
||||
}
|
||||
api(`/api/v1/external-refs/${element.id}/mail?${params}`)
|
||||
.then((data) => {
|
||||
if (alive) setLetter(data);
|
||||
})
|
||||
.catch(() => {
|
||||
if (alive) setLetter(null);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [element?.id, element?.external?.source, context?.kind, context?.id]);
|
||||
|
||||
useEffect(() => () => {
|
||||
pdf?.destroy?.();
|
||||
@@ -143,7 +219,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
async function openOriginal() {
|
||||
setError("");
|
||||
try {
|
||||
const blob = element.kind === "external_ref"
|
||||
const blob = element.external?.source === "paperless"
|
||||
? await fetchPaperless(element.id, context)
|
||||
: await fetchFile(element.id, context);
|
||||
const url = URL.createObjectURL(blob);
|
||||
@@ -194,8 +270,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
body: {
|
||||
expected_version: element.version,
|
||||
document_on: documentOn || null,
|
||||
sent_on: element.dates?.sent_on || null,
|
||||
received_on: element.dates?.received_on || null,
|
||||
sent_on: sentOn || null,
|
||||
received_on: receivedOn || null,
|
||||
context,
|
||||
},
|
||||
});
|
||||
@@ -249,11 +325,9 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
);
|
||||
}
|
||||
|
||||
const typeLabel = element.kind === "file" && element.file?.content_type === "application/pdf"
|
||||
? "PDF"
|
||||
: element.kind === "external_ref"
|
||||
? (element.external?.source === "imap" ? "E-Mail" : kindLabel(element.kind))
|
||||
: kindLabel(element.kind);
|
||||
const typeLabel = elementFacts(element);
|
||||
const isMail = element.external?.source === "imap";
|
||||
const mailDetail = letter || element.external?.detail || {};
|
||||
|
||||
return (
|
||||
<section className="reader-pane" aria-label="Leser">
|
||||
@@ -266,7 +340,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
<p>{formatDate(element.dates?.document_on)} · {typeLabel}</p>
|
||||
</div>
|
||||
<div className="reader-pane__tools">
|
||||
{element.kind !== "note" ? (
|
||||
{element.kind !== "note" && !isMail ? (
|
||||
<button type="button" className="icon-button" aria-label="Original öffnen" onClick={openOriginal}>
|
||||
<NavIcon name="link" />
|
||||
</button>
|
||||
@@ -278,6 +352,19 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
</header>
|
||||
<div className="reader-pane__stage">
|
||||
<ErrorNote error={error} />
|
||||
<Correspondence element={element} onOpenRelated={onOpenRelated} />
|
||||
{isMail ? (
|
||||
<article className="mail-letter">
|
||||
<p>{mailDetail.direction === "out" ? "Ausgang" : "Eingang"}</p>
|
||||
<p><span>Von</span> {mailDetail.message_from || "Ohne Absender"}</p>
|
||||
<p><span>An</span> {mailDetail.message_to || "Ohne Empfänger"}</p>
|
||||
{mailDetail.message_cc ? <p><span>Kopie</span> {mailDetail.message_cc}</p> : null}
|
||||
<MailAttachments files={mailDetail.attachments} />
|
||||
{letter?.text ? <pre className="mail-letter__body">{letter.text}</pre> : (
|
||||
<p className="muted">Der Text wird aus dem Postfach geladen, sobald das Konto erreichbar ist. Absender und Empfänger bleiben an der E-Mail gespeichert.</p>
|
||||
)}
|
||||
</article>
|
||||
) : null}
|
||||
{element.kind === "note" ? (
|
||||
<form className="reader-note" onSubmit={saveNote}>
|
||||
<label>
|
||||
@@ -368,6 +455,14 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
{element.kind === "note" ? "Bezugsdatum, optional" : "Dokumentdatum, optional"}
|
||||
<input type="date" value={documentOn} onChange={(event) => { setDocumentOn(event.target.value); markDirty(true); }} />
|
||||
</label>
|
||||
<label>
|
||||
Versand, optional
|
||||
<input type="date" value={sentOn} onChange={(event) => { setSentOn(event.target.value); markDirty(true); }} />
|
||||
</label>
|
||||
<label>
|
||||
Zugang, optional
|
||||
<input type="date" value={receivedOn} onChange={(event) => { setReceivedOn(event.target.value); markDirty(true); }} />
|
||||
</label>
|
||||
<button type="submit" className="quiet">Datum speichern</button>
|
||||
</form>
|
||||
) : null}
|
||||
|
||||
+101
-10
@@ -251,6 +251,15 @@ function FolderBranch({ node, mailbox, expanded, onToggle, onSelect }) {
|
||||
);
|
||||
}
|
||||
|
||||
function MailFiles({ files }) {
|
||||
if (!files?.length) return <p className="muted">Keine Anhänge.</p>;
|
||||
return (
|
||||
<ul className="mail-files">
|
||||
{files.map((file) => <li key={file.filename}>{file.filename}</li>)}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function FolderTree({ folders, mailbox, onSelect }) {
|
||||
const [expanded, setExpanded] = useState(() => new Set());
|
||||
useEffect(() => {
|
||||
@@ -290,6 +299,9 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
const [query, setQuery] = useState("");
|
||||
const [items, setItems] = useState([]);
|
||||
const [nextBefore, setNextBefore] = useState(null);
|
||||
const [selectedKey, setSelectedKey] = useState("");
|
||||
const [preview, setPreview] = useState(null);
|
||||
const [previewError, setPreviewError] = useState("");
|
||||
const [loading, setLoading] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
|
||||
@@ -338,6 +350,9 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
setDraft("");
|
||||
setItems([]);
|
||||
setNextBefore(null);
|
||||
setSelectedKey("");
|
||||
setPreview(null);
|
||||
setPreviewError("");
|
||||
setError("");
|
||||
setLoading("Nachrichten werden gelesen …");
|
||||
const params = new URLSearchParams({ connector_id: accountId, mailbox });
|
||||
@@ -370,6 +385,9 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
setQuery(draft.trim());
|
||||
setItems(data.items || []);
|
||||
setNextBefore(data.next_before ?? null);
|
||||
setSelectedKey("");
|
||||
setPreview(null);
|
||||
setPreviewError("");
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
@@ -394,8 +412,46 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
}
|
||||
}
|
||||
|
||||
function choose(item) {
|
||||
const key = `${mailbox}:${item.uid || item.id}`;
|
||||
setSelectedKey(key);
|
||||
setPreview(null);
|
||||
setPreviewError("");
|
||||
if (!item.uid) {
|
||||
setPreviewError("Diese Nachricht lässt sich nicht öffnen.");
|
||||
return;
|
||||
}
|
||||
const params = new URLSearchParams({ connector_id: accountId, mailbox, uid: String(item.uid) });
|
||||
api(`/api/v1/sources/imap/message?${params}`)
|
||||
.then((data) => {
|
||||
setPreview(data);
|
||||
})
|
||||
.catch((err) => setPreviewError(err.message));
|
||||
}
|
||||
|
||||
async function link(item) {
|
||||
setError("");
|
||||
const letter = preview && preview.uid === item.uid ? preview : null;
|
||||
const direction = (letter?.direction || item.direction) === "out" ? "out" : "in";
|
||||
const attachments = (letter?.attachments || item.attachments || [])
|
||||
.filter((file) => file?.filename)
|
||||
.map((file) => ({
|
||||
filename: file.filename,
|
||||
...(file.content_type ? { content_type: file.content_type } : {}),
|
||||
}));
|
||||
const detail = {
|
||||
direction,
|
||||
mailbox,
|
||||
connector_id: accountId,
|
||||
uid: item.uid,
|
||||
};
|
||||
const from = letter?.message_from || item.message_from;
|
||||
const to = letter?.message_to || item.message_to;
|
||||
const cc = letter?.message_cc || item.message_cc;
|
||||
if (from) detail.message_from = from;
|
||||
if (to) detail.message_to = to;
|
||||
if (cc) detail.message_cc = cc;
|
||||
if (attachments.length) detail.attachments = attachments;
|
||||
try {
|
||||
await api("/api/v1/external-refs", {
|
||||
method: "POST",
|
||||
@@ -406,8 +462,14 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
context,
|
||||
...(placement ? { placement } : {}),
|
||||
...(chapterId ? { chapter_id: chapterId } : {}),
|
||||
...(item.document_on ? { dates: { document_on: item.document_on, sent_on: null, received_on: null } } : {}),
|
||||
...(item.message_from ? { detail: { message_from: item.message_from } } : {}),
|
||||
...(item.document_on ? {
|
||||
dates: {
|
||||
document_on: item.document_on,
|
||||
sent_on: direction === "out" ? item.document_on : null,
|
||||
received_on: direction === "in" ? item.document_on : null,
|
||||
},
|
||||
} : {}),
|
||||
detail,
|
||||
},
|
||||
});
|
||||
onDone();
|
||||
@@ -416,6 +478,8 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
}
|
||||
}
|
||||
|
||||
const selected = items.find((item) => `${mailbox}:${item.uid || item.id}` === selectedKey) || null;
|
||||
|
||||
return (
|
||||
<div className="stack">
|
||||
<TargetLine label={targetLabel} chapterId={chapterId} chapterTitle={chapterTitle} />
|
||||
@@ -429,7 +493,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
</select>
|
||||
</label>
|
||||
{!accounts.length ? <p className="muted">Lege zuerst ein E-Mail-Konto unter <Link to="/sources">Quellen</Link> an.</p> : null}
|
||||
<div className="mailbox">
|
||||
<div className="mailbox mailbox--read">
|
||||
<FolderTree folders={folders} mailbox={mailbox} onSelect={setMailbox} />
|
||||
<div className="mailbox__messages">
|
||||
<form onSubmit={search} className="inline">
|
||||
@@ -443,16 +507,43 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
<p className="muted">{query ? "In diesem Fach gibt es dazu keine Nachricht." : "In diesem Fach gibt es keine Nachricht."}</p>
|
||||
) : null}
|
||||
<div className="mail-list">
|
||||
{items.map((item) => (
|
||||
<button key={`${mailbox}:${item.uid || item.id}`} type="button" className="mail-row" onClick={() => link(item)}>
|
||||
<span>{formatDate(item.document_on)}</span>
|
||||
<strong>{item.title}</strong>
|
||||
<span>{item.message_from || "Ohne Absender"}</span>
|
||||
</button>
|
||||
))}
|
||||
{items.map((item) => {
|
||||
const key = `${mailbox}:${item.uid || item.id}`;
|
||||
const outgoing = item.direction === "out";
|
||||
const who = outgoing ? (item.message_to ? `an ${item.message_to}` : "Ausgang") : (item.message_from || "Ohne Absender");
|
||||
const files = item.attachments?.length || 0;
|
||||
return (
|
||||
<button key={key} type="button" className={key === selectedKey ? "mail-row is-current" : "mail-row"} aria-current={key === selectedKey ? "true" : undefined} onClick={() => choose(item)}>
|
||||
<span className="mail-row__date">{formatDate(item.document_on)}</span>
|
||||
<span className="mail-row__main">
|
||||
<strong>{item.title}</strong>
|
||||
<span>{outgoing ? "Ausgang" : "Eingang"} · {who}</span>
|
||||
</span>
|
||||
{files ? <span className="mail-row__files" aria-label={`${files} ${files === 1 ? "Anhang" : "Anhänge"}`}>{files}</span> : null}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{nextBefore ? <button type="button" className="quiet" onClick={older} disabled={!!loading}>Ältere laden</button> : null}
|
||||
</div>
|
||||
<aside className="mail-preview" aria-label="E-Mail-Vorschau">
|
||||
{!selected ? <p className="muted">Wähle eine Nachricht, um Absender, Empfänger und Inhalt zu prüfen.</p> : (
|
||||
<>
|
||||
<h3>{preview?.title || selected.title}</h3>
|
||||
<p className="mail-preview__party">{(preview?.direction || selected.direction) === "out" ? "Ausgang" : "Eingang"}</p>
|
||||
<p><span>Von</span> {preview?.message_from || selected.message_from || "Ohne Absender"}</p>
|
||||
<p><span>An</span> {preview?.message_to || selected.message_to || "Ohne Empfänger"}</p>
|
||||
{(preview?.message_cc || selected.message_cc) ? <p><span>Kopie</span> {preview?.message_cc || selected.message_cc}</p> : null}
|
||||
<p><span>Datum</span> {formatDate(preview?.document_on || selected.document_on)}</p>
|
||||
<MailFiles files={preview?.attachments || selected.attachments || []} />
|
||||
{previewError ? <p className="error">{previewError}</p> : null}
|
||||
{selected && !preview && !previewError ? <p className="muted">Vorschau wird geladen …</p> : null}
|
||||
{preview?.text ? <pre className="mail-letter__body">{preview.text}</pre> : null}
|
||||
{preview && !preview.text ? <p className="muted">Diese Nachricht hat keinen lesbaren Text.</p> : null}
|
||||
<button type="button" onClick={() => link(selected)} disabled={!selected.uid}>Übernehmen</button>
|
||||
</>
|
||||
)}
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -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>
|
||||
|
||||
+116
-13
@@ -366,6 +366,7 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
}
|
||||
.modal__bar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
|
||||
.modal.modal--wide { width: min(960px, 100%); }
|
||||
.modal.modal--wide.modal--split { width: min(1120px, 100%); }
|
||||
.modal h2 { font-size: 18px; color: var(--text1); text-transform: none; letter-spacing: 0; margin: 0; }
|
||||
.modal h3 { font-size: 13px; }
|
||||
|
||||
@@ -468,10 +469,11 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
.folder-tree ul { margin-left: 11px; padding-left: 8px; border-left: 1px solid var(--border); }
|
||||
.folder-row { display: flex; align-items: center; gap: 0; min-height: 28px; border-radius: 4px; }
|
||||
.folder-row.is-current { background: var(--accent-light); }
|
||||
.folder-twist, .folder-name { background: transparent; border: 0; color: inherit; min-height: 28px; padding: 0; }
|
||||
.folder-twist, .folder-name { background: transparent; border: 0; color: inherit; min-height: 28px; padding: 0; justify-content: flex-start; text-align: left; }
|
||||
.folder-twist { width: 22px; flex: none; }
|
||||
.folder-name { flex: 1; display: flex; align-items: center; gap: 6px; text-align: left; padding: 2px 6px; font: inherit; font-weight: 500; cursor: pointer; min-width: 0; }
|
||||
.folder-name svg { width: 16px; height: 16px; flex: none; }
|
||||
.folder-name { flex: 1; display: flex; align-items: flex-start; gap: 6px; text-align: left; padding: 2px 6px; font: inherit; font-weight: 500; cursor: pointer; min-width: 0; line-height: 1.3; }
|
||||
.folder-name span { flex: 1; min-width: 0; overflow-wrap: anywhere; text-align: left; }
|
||||
.folder-name svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
|
||||
.order-choice { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; max-width: 36rem; font-size: 14px; }
|
||||
.order-choice select { width: auto; min-width: 16rem; flex: 1; }
|
||||
.target-line { margin: 0; color: var(--text2); overflow-wrap: break-word; }
|
||||
@@ -614,7 +616,8 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
.menu-list button { width: 100%; justify-content: flex-start; }
|
||||
.placements { margin: 4px 0 0; overflow-wrap: anywhere; }
|
||||
.reader-preview { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); }
|
||||
.mailbox { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 12px; align-items: stretch; min-height: 0; }
|
||||
.mailbox { display: grid; grid-template-columns: minmax(180px, 220px) minmax(0, 1fr); gap: 12px; align-items: stretch; min-height: 0; }
|
||||
.mailbox.mailbox--read { grid-template-columns: minmax(160px, 200px) minmax(220px, 0.9fr) minmax(260px, 1.15fr); }
|
||||
.mailbox__folders { border-right: 1px solid var(--border); padding-right: 8px; overflow: auto; min-height: 0; }
|
||||
.mailbox__folders { display: block; }
|
||||
.modal.modal--split {
|
||||
@@ -631,11 +634,13 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
.mail-list { display: grid; }
|
||||
.mail-row {
|
||||
display: grid;
|
||||
grid-template-columns: 6.5rem minmax(0, 1fr);
|
||||
gap: 2px 12px;
|
||||
grid-template-columns: 4.6rem minmax(0, 1fr) auto;
|
||||
gap: 1px 8px;
|
||||
align-items: start;
|
||||
justify-content: stretch;
|
||||
width: 100%;
|
||||
min-height: 58px;
|
||||
padding: 8px 10px;
|
||||
min-height: 0;
|
||||
padding: 5px 8px;
|
||||
border: 0;
|
||||
border-top: 1px solid var(--border);
|
||||
border-radius: 0;
|
||||
@@ -643,10 +648,106 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
color: inherit;
|
||||
text-align: left;
|
||||
font-weight: 500;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.mail-row.is-current { background: var(--accent-light); }
|
||||
.mail-row__date { color: var(--text2); font-size: 12px; font-variant-numeric: tabular-nums; }
|
||||
.mail-row__main { display: grid; min-width: 0; text-align: left; }
|
||||
.mail-row__main strong, .mail-row__main span { overflow-wrap: anywhere; text-align: left; }
|
||||
.mail-row__main span { color: var(--text2); font-size: 12px; font-weight: 500; }
|
||||
.mail-row__files {
|
||||
min-width: 1.4rem;
|
||||
padding: 0 5px;
|
||||
border-radius: 999px;
|
||||
background: var(--surface2);
|
||||
color: var(--text2);
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
.mail-preview {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
border-left: 1px solid var(--border);
|
||||
padding-left: 12px;
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 6px;
|
||||
}
|
||||
.mail-preview h3 { font-size: 16px; }
|
||||
.mail-preview p, .mail-letter p { margin: 0; overflow-wrap: anywhere; }
|
||||
.mail-preview p span, .mail-letter p span { display: inline-block; min-width: 3.2rem; color: var(--text3); font-size: 12px; font-weight: 700; }
|
||||
.mail-preview__party { font-weight: 700; }
|
||||
.mail-files { margin: 0; padding-left: 1.1rem; }
|
||||
.preview-row--linked { box-shadow: inset 3px 0 0 var(--accent); }
|
||||
.bezug { flex: 1 1 100%; display: grid; gap: 2px; min-width: 0; }
|
||||
.bezug__link, a.bezug__link, p.bezug__link {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
margin: 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
border: 0;
|
||||
border-left: 2px solid var(--accent);
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--text2);
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.bezug__link--reply, a.bezug__link--reply { border-left-color: var(--border2); }
|
||||
p.bezug__link { cursor: default; }
|
||||
.bezug__link span { color: var(--text3); font-size: 12px; font-weight: 700; }
|
||||
.bezug__link strong { color: var(--text1); font-weight: 650; overflow-wrap: anywhere; }
|
||||
.bezug__link em { font-style: normal; color: var(--text3); }
|
||||
.schriftwechsel {
|
||||
display: grid;
|
||||
gap: 0;
|
||||
margin: 0 0 14px;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
background: var(--surface);
|
||||
}
|
||||
.schriftwechsel h3 { margin: 0 0 4px; font-size: 13px; }
|
||||
.schriftwechsel > p { margin: 0 0 8px; color: var(--text3); font-size: 12px; line-height: 1.4; }
|
||||
.schriftwechsel__item {
|
||||
display: grid;
|
||||
grid-template-columns: 6.4rem minmax(0, 1fr) auto;
|
||||
gap: 8px;
|
||||
align-items: baseline;
|
||||
justify-content: start;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
padding: 5px 0 5px 10px;
|
||||
border: 0;
|
||||
border-left: 2px solid var(--border2);
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
}
|
||||
.schriftwechsel__item.is-current { border-left-color: var(--accent); font-weight: 700; cursor: default; }
|
||||
.schriftwechsel__item span, .schriftwechsel__item em { color: var(--text3); font-style: normal; font-size: 12px; font-weight: 600; }
|
||||
.schriftwechsel__item strong { overflow-wrap: anywhere; font-weight: inherit; }
|
||||
.mail-letter { display: grid; gap: 6px; align-content: start; }
|
||||
.mail-letter__body {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
font: inherit;
|
||||
color: var(--text1);
|
||||
}
|
||||
.mail-row strong { grid-column: 2; grid-row: 1; overflow-wrap: anywhere; }
|
||||
.mail-row span:first-child { grid-column: 1; grid-row: 1 / span 2; color: var(--text2); font-size: 13px; }
|
||||
.mail-row span:last-child { grid-column: 2; color: var(--text2); font-size: 13px; overflow-wrap: anywhere; }
|
||||
|
||||
@media (min-width: 900px) {
|
||||
.record-layout { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); }
|
||||
@@ -667,8 +768,10 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
.outline__body { display: none; }
|
||||
.outline.is-open .outline__body { display: block; }
|
||||
.outline__toggle { display: inline-flex; margin-bottom: 8px; }
|
||||
.mailbox { grid-template-columns: 1fr; grid-template-rows: minmax(140px, 34%) minmax(0, 1fr); min-height: 0; }
|
||||
.mailbox__folders { display: block; max-height: none; overflow: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 8px; }
|
||||
.mailbox, .mailbox.mailbox--read { grid-template-columns: 1fr; grid-template-rows: minmax(120px, 30%) minmax(0, 1fr); min-height: 0; }
|
||||
.mailbox.mailbox--read { grid-template-rows: minmax(110px, 24%) minmax(140px, 34%) minmax(180px, 1fr); }
|
||||
.mailbox__folders, .mail-preview { border-right: 0; border-left: 0; padding-left: 0; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
|
||||
.mailbox__folders { display: block; max-height: none; overflow: auto; }
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
|
||||
Reference in new issue
Block a user