Unterscheide Eingang und Ausgang an der Einbindung und ermoegliche Umbenennen, Archivieren, Loeschen und Verschieben.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
20625b4596
commit
ad6240a5da
27 files changed
+1191
-88
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { documentToText, fetchFile, fetchPaperless, markDirty, textToDocument, api } from "../api.js";
|
||||
import { ErrorNote } from "./widgets.jsx";
|
||||
import { elementFacts, formatDate } from "./content.jsx";
|
||||
import { dateCaption, DirectionChoice, DirectionMark, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
||||
|
||||
@@ -49,7 +49,7 @@ function Correspondence({ element, onOpenRelated }) {
|
||||
>
|
||||
<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>
|
||||
<DirectionMark direction={item.direction} />
|
||||
</button>
|
||||
))}
|
||||
</section>
|
||||
@@ -163,8 +163,10 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
.then((data) => {
|
||||
if (alive) setLetter(data);
|
||||
})
|
||||
.catch(() => {
|
||||
if (alive) setLetter(null);
|
||||
.catch((err) => {
|
||||
if (!alive) return;
|
||||
setLetter(null);
|
||||
setError(err.message || "Die Nachricht konnte nicht geladen werden.");
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
@@ -261,6 +263,19 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDirection(value) {
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/bindings/${binding.id}/communication`, {
|
||||
method: "PATCH",
|
||||
body: { expected_version: element.version, direction: value || null, context },
|
||||
});
|
||||
onReload();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDate(event) {
|
||||
event.preventDefault();
|
||||
setError("");
|
||||
@@ -325,7 +340,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
);
|
||||
}
|
||||
|
||||
const typeLabel = elementFacts(element);
|
||||
const communication = binding.communication || {};
|
||||
const shownDirection = communication.direction || null;
|
||||
const isMail = element.external?.source === "imap";
|
||||
const mailDetail = letter || element.external?.detail || {};
|
||||
|
||||
@@ -337,7 +353,12 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
</button>
|
||||
<div className="reader-pane__heading">
|
||||
<h2>{element.title}</h2>
|
||||
<p>{formatDate(element.dates?.document_on)} · {typeLabel}</p>
|
||||
<p className="reader-facts">
|
||||
<span>{formatDate(element.dates?.document_on)} · {sourceLabel(element)}</span>
|
||||
<DirectionMark direction={shownDirection} />
|
||||
{mailFacts(element) ? <span>{mailFacts(element)}</span> : null}
|
||||
{dateCaption(element, shownDirection) ? <span>{dateCaption(element, shownDirection)}</span> : null}
|
||||
</p>
|
||||
</div>
|
||||
<div className="reader-pane__tools">
|
||||
{element.kind !== "note" && !isMail ? (
|
||||
@@ -355,27 +376,33 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
<Correspondence element={element} onOpenRelated={onOpenRelated} />
|
||||
{isMail ? (
|
||||
<article className="mail-letter">
|
||||
<p>{mailDetail.direction === "out" ? "Ausgang" : "Eingang"}</p>
|
||||
<p><DirectionMark direction={shownDirection} /></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>
|
||||
<p className="muted">{error || "Zu dieser Nachricht liegt kein Text vor. Absender und Empfänger bleiben gespeichert."}</p>
|
||||
)}
|
||||
{letter?.text_truncated ? <p className="muted">Der Text ist gekürzt. Die Nachricht selbst ist größer als die Vorschau.</p> : null}
|
||||
</article>
|
||||
) : null}
|
||||
{element.kind === "note" ? (
|
||||
<form className="reader-note" onSubmit={saveNote}>
|
||||
<label>
|
||||
Gemeinsamer Text
|
||||
<textarea rows={12} value={text} disabled={!binding.rights.edit} onChange={(event) => { setText(event.target.value); markDirty(true); }} />
|
||||
</label>
|
||||
<p className="muted">Diese Änderung betrifft den gemeinsamen Inhalt der Notiz, nicht die hiesige Anmerkung.</p>
|
||||
<MarkdownEditor value={text} disabled={!binding.rights.edit} onChange={(value) => { setText(value); markDirty(true); }} />
|
||||
<p className="muted">Diese Änderung betrifft den gemeinsamen Inhalt der Notiz, nicht die hiesige Anmerkung. Gespeichert wird Markdown.</p>
|
||||
{notice ? <p className="notice">{notice}</p> : null}
|
||||
{binding.rights.edit ? <button type="submit">Text speichern</button> : <p className="muted">In diesem Kontext nur lesbar.</p>}
|
||||
</form>
|
||||
) : null}
|
||||
<form className="stack reader-direction" onSubmit={(event) => event.preventDefault()}>
|
||||
<DirectionChoice
|
||||
value={communication.explicit ? (communication.direction || "") : (shownDirection || "")}
|
||||
disabled={!binding.rights.edit}
|
||||
onChange={saveDirection}
|
||||
/>
|
||||
<p className="muted">Keine Angabe bleibt leer. Versand- und Zugangsdatum ändern die Richtung nicht.</p>
|
||||
</form>
|
||||
{phase === "loading" ? <p className="reader-pane__state">Vorschau wird geladen …</p> : null}
|
||||
{phase === "missing" ? (
|
||||
<div className="reader-pane__state">
|
||||
|
||||
Reference in new issue
Block a user