Halte die Richtung an der einzelnen Einbindung und mach sie in der Uebersicht waehlbar.
Deploy Development / deploy (push) Successful in 28s
Deploy Development / deploy (push) Successful in 28s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2664021e7f
commit
95381030bc
12 files changed
+185
-52
No files matched your search
@@ -956,7 +956,7 @@ export function FileForm({ context, placement, chapters = [], initialChapter = "
|
||||
if (documentOn) form.set("document_on", documentOn);
|
||||
if (sentOn) form.set("sent_on", sentOn);
|
||||
if (receivedOn) form.set("received_on", receivedOn);
|
||||
if (direction === "in" || direction === "out") form.set("communication_direction", direction);
|
||||
if (direction === "in" || direction === "out" || direction === "local") form.set("communication_direction", direction);
|
||||
setError("");
|
||||
try {
|
||||
await api("/api/v1/files", { method: "POST", form });
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { documentToText, downloadMailPart, fetchFile, fetchMailPart, fetchPaperless, markDirty, textToDocument, api } from "../api.js";
|
||||
import { ErrorNote } from "./widgets.jsx";
|
||||
import { dateCaption, DirectionChoice, DirectionColumn, directionWord, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
|
||||
import { dateCaption, DirectionChoice, DirectionColumn, directionValue, directionWord, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
import workerSrc from "pdfjs-dist/build/pdf.worker.min.mjs?url";
|
||||
|
||||
@@ -22,7 +22,7 @@ function MailAttachments({ files, current, onOpen }) {
|
||||
{files.map((file) => (
|
||||
<li key={`${file.index ?? "name"}-${file.filename}`}>
|
||||
{onOpen && Number.isInteger(file.index) ? (
|
||||
<button type="button" className={file.index === current ? "quiet is-current" : "quiet"} aria-current={file.index === current ? "true" : undefined} onClick={() => onOpen(file)}>{file.filename}</button>
|
||||
<button type="button" className={file.index === current ? "quiet is-current" : "quiet"} aria-pressed={file.index === current} onClick={() => onOpen(file)}>{file.filename}</button>
|
||||
) : file.filename}
|
||||
</li>
|
||||
))}
|
||||
@@ -30,7 +30,7 @@ function MailAttachments({ files, current, onOpen }) {
|
||||
);
|
||||
}
|
||||
|
||||
function Correspondence({ element, onOpenRelated }) {
|
||||
function Correspondence({ element, direction, onOpenRelated }) {
|
||||
const refers = element.refers_to || [];
|
||||
const replies = element.referred_by || [];
|
||||
if (!refers.length && !replies.length) return null;
|
||||
@@ -38,7 +38,7 @@ function Correspondence({ element, onOpenRelated }) {
|
||||
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),
|
||||
direction: direction || null,
|
||||
current: true,
|
||||
};
|
||||
const seen = new Set();
|
||||
@@ -90,7 +90,8 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
const [notice, setNotice] = useState("");
|
||||
const [annotate, setAnnotate] = useState(false);
|
||||
const [letter, setLetter] = useState(null);
|
||||
const [shownIndex, setShownIndex] = useState(null);
|
||||
const [shownFor, setShownFor] = useState(null);
|
||||
const shownIndex = shownFor?.elementId === element?.id ? shownFor.index : null;
|
||||
const canvasRef = useRef(null);
|
||||
const objectUrl = useRef("");
|
||||
const closeRef = useRef(null);
|
||||
@@ -106,28 +107,33 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
setSentOn(element.dates?.sent_on || "");
|
||||
setReceivedOn(element.dates?.received_on || "");
|
||||
setSummary(element.summary || "");
|
||||
setError("");
|
||||
setNotice("");
|
||||
setPage(1);
|
||||
setPdf(null);
|
||||
setPages(0);
|
||||
setMedia("");
|
||||
setLetter(null);
|
||||
setShownIndex(null);
|
||||
if (objectUrl.current) {
|
||||
URL.revokeObjectURL(objectUrl.current);
|
||||
objectUrl.current = "";
|
||||
}
|
||||
setBlobUrl("");
|
||||
const mail = element.external?.source === "imap";
|
||||
setPhase(element.kind === "note" || mail ? "ready" : element.preview?.available ? "loading" : "missing");
|
||||
return undefined;
|
||||
}, [element?.id, element?.version]);
|
||||
}, [element?.id, element?.version, element?.summary, element?.document, element?.dates?.document_on, element?.dates?.sent_on, element?.dates?.received_on]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!element) return undefined;
|
||||
const mail = element.external?.source === "imap";
|
||||
if (element.kind === "note" || mail) setPhase("ready");
|
||||
else if (!element.preview?.available) setPhase("missing");
|
||||
setError("");
|
||||
return undefined;
|
||||
}, [element?.id, element?.kind, element?.external?.source, element?.preview?.available]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!element || element.kind === "note" || element.external?.source === "imap" || !element.preview?.available) return undefined;
|
||||
let alive = true;
|
||||
let url = "";
|
||||
setPage(1);
|
||||
setPdf(null);
|
||||
setPages(0);
|
||||
setMedia("");
|
||||
setLetter(null);
|
||||
if (objectUrl.current) {
|
||||
URL.revokeObjectURL(objectUrl.current);
|
||||
objectUrl.current = "";
|
||||
}
|
||||
setBlobUrl("");
|
||||
setPhase("loading");
|
||||
const load = element.external?.source === "paperless" ? fetchPaperless(element.id, context) : fetchFile(element.id, context);
|
||||
load.then(async (blob) => {
|
||||
@@ -175,15 +181,20 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
}, [element?.id, element?.kind, element?.external?.source, element?.preview?.available, context?.kind, context?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!letter?.complete) return undefined;
|
||||
const files = letter.attachments || [];
|
||||
const viewable = files.findIndex((file) => previewKind(file.content_type, file.filename) !== "other");
|
||||
setShownIndex(viewable >= 0 ? files[viewable].index : (files[0] ? files[0].index : null));
|
||||
return undefined;
|
||||
}, [letter]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!element || element.external?.source !== "imap" || shownIndex === null) return undefined;
|
||||
if (!element || element.external?.source !== "imap") return undefined;
|
||||
if (shownIndex === null) {
|
||||
setPhase("ready");
|
||||
setPdf(null);
|
||||
setPages(0);
|
||||
setPage(1);
|
||||
setMedia("");
|
||||
if (objectUrl.current) {
|
||||
URL.revokeObjectURL(objectUrl.current);
|
||||
objectUrl.current = "";
|
||||
}
|
||||
setBlobUrl("");
|
||||
return undefined;
|
||||
}
|
||||
const file = (letter?.attachments || []).find((item) => item.index === shownIndex);
|
||||
if (!file) return undefined;
|
||||
let alive = true;
|
||||
@@ -473,7 +484,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
</header>
|
||||
<div className="reader-pane__stage">
|
||||
<ErrorNote error={error} />
|
||||
<Correspondence element={element} onOpenRelated={onOpenRelated} />
|
||||
<Correspondence element={element} direction={shownDirection} onOpenRelated={onOpenRelated} />
|
||||
{isMail ? (
|
||||
<article className="mail-letter">
|
||||
<p className="mail-letter__way"><DirectionColumn direction={shownDirection} />{directionWord(shownDirection) ? <span>{directionWord(shownDirection)}</span> : null}</p>
|
||||
@@ -482,7 +493,12 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
{mailDetail.message_cc ? <p><span>Kopie</span> {mailDetail.message_cc}</p> : null}
|
||||
{letter?.complete ? (
|
||||
<>
|
||||
<MailAttachments files={letter.attachments} current={shownIndex} onOpen={(file) => { setError(""); setShownIndex(file.index); }} />
|
||||
<MailAttachments files={letter.attachments} current={shownIndex} onOpen={(file) => {
|
||||
setError("");
|
||||
setShownFor((current) => (
|
||||
current?.elementId === element.id && current.index === file.index ? null : { elementId: element.id, index: file.index }
|
||||
));
|
||||
}} />
|
||||
{shownFile ? <p className="mail-attachment__caption">Anlage: {shownFile.filename}</p> : null}
|
||||
{shownFile && phase === "loading" ? <p className="muted">Die Anlage wird geladen …</p> : null}
|
||||
{media === "image" && blobUrl ? (
|
||||
@@ -516,7 +532,7 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
) : null}
|
||||
<form className="stack reader-direction" onSubmit={(event) => event.preventDefault()}>
|
||||
<DirectionChoice
|
||||
value={communication.explicit ? (communication.direction || "") : (shownDirection || "")}
|
||||
value={directionValue(communication)}
|
||||
disabled={!binding.rights.edit}
|
||||
onChange={saveDirection}
|
||||
/>
|
||||
|
||||
@@ -279,6 +279,13 @@ export function elementFacts(element, communication) {
|
||||
export function directionWord(direction) {
|
||||
if (direction === "out") return "Ausgang";
|
||||
if (direction === "in") return "Eingang";
|
||||
if (direction === "local") return "Lokal";
|
||||
return "";
|
||||
}
|
||||
|
||||
export function directionValue(communication) {
|
||||
const direction = communication?.direction;
|
||||
if (direction === "in" || direction === "out" || direction === "local") return direction;
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -298,15 +305,20 @@ export function DirectionColumn({ direction }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function DirectionChoice({ value, disabled, onChange }) {
|
||||
export function DirectionChoice({ value, disabled, onChange, compact = false, label = "Kommunikationsrichtung" }) {
|
||||
const select = (
|
||||
<select aria-label={label} value={value || ""} disabled={disabled} onChange={(event) => onChange(event.target.value)}>
|
||||
<option value="">Keine Angabe</option>
|
||||
<option value="in">Eingang</option>
|
||||
<option value="out">Ausgang</option>
|
||||
<option value="local">Lokal</option>
|
||||
</select>
|
||||
);
|
||||
if (compact) return <span className="direction-choice">{select}</span>;
|
||||
return (
|
||||
<label>
|
||||
Kommunikationsrichtung
|
||||
<select aria-label="Kommunikationsrichtung" value={value || ""} disabled={disabled} onChange={(event) => onChange(event.target.value)}>
|
||||
<option value="">Keine Angabe</option>
|
||||
<option value="in">Eingang</option>
|
||||
<option value="out">Ausgang</option>
|
||||
</select>
|
||||
{label}
|
||||
{select}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
@@ -352,7 +364,6 @@ function BezugLink({ item, label, source, onOpen, itemHref, reply = false }) {
|
||||
const className = reply ? "bezug__link bezug__link--reply" : "bezug__link";
|
||||
const body = (
|
||||
<>
|
||||
<DirectionColumn direction={item.direction} />
|
||||
<span>{label}</span>
|
||||
<strong>{formatDate(item.document_on)} · {item.title}</strong>
|
||||
{directionWord(item.direction) ? <span>{directionWord(item.direction)}</span> : null}
|
||||
@@ -491,6 +502,26 @@ export function ContentBoard({
|
||||
}
|
||||
}
|
||||
|
||||
async function saveRowDirection(binding, value) {
|
||||
setPending(true);
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/bindings/${binding.id}/communication`, {
|
||||
method: "PATCH",
|
||||
body: {
|
||||
expected_version: binding.element.version,
|
||||
direction: value || null,
|
||||
context: actionContext(),
|
||||
},
|
||||
});
|
||||
await onChange();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function clearBezug(elementId, refersToId) {
|
||||
setPending(true);
|
||||
setError("");
|
||||
@@ -978,6 +1009,15 @@ export function ContentBoard({
|
||||
<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}
|
||||
<DirectionColumn direction={binding.communication?.direction} />
|
||||
{canEdit ? (
|
||||
<DirectionChoice
|
||||
compact
|
||||
label={`Richtung für ${element.title}`}
|
||||
value={directionValue(binding.communication)}
|
||||
disabled={pending}
|
||||
onChange={(value) => saveRowDirection(binding, value)}
|
||||
/>
|
||||
) : null}
|
||||
{canSort && custom ? (
|
||||
<button
|
||||
type="button"
|
||||
@@ -1017,7 +1057,7 @@ export function ContentBoard({
|
||||
</span>
|
||||
) : null}
|
||||
{formatDate(fachDate(element))} · {sourceLabel(element)}
|
||||
{directionWord(binding.communication?.direction) ? <span>{directionWord(binding.communication?.direction)}</span> : null}
|
||||
{!canEdit && directionWord(binding.communication?.direction) ? <span>{directionWord(binding.communication?.direction)}</span> : null}
|
||||
{mailFacts(element) ? <span>{mailFacts(element)}</span> : null}
|
||||
{dateCaption(element, binding.communication?.direction) ? <span>{dateCaption(element, binding.communication?.direction)}</span> : null}
|
||||
</span>
|
||||
|
||||
@@ -467,6 +467,8 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
.icon-button--compact { width: 32px; min-width: 32px; height: 32px; }
|
||||
.icon-button--compact svg { width: 16px; height: 16px; }
|
||||
.icon-button--compact:hover, .icon-button--compact:focus-visible { background: var(--surface2); color: var(--text1); }
|
||||
.direction-choice { flex: 0 0 auto; }
|
||||
.direction-choice select { width: auto; min-width: 7.5rem; min-height: 32px; height: 32px; padding: 0 8px; font-size: 13px; }
|
||||
.direction-column { flex: 0 0 36px; width: 36px; height: 40px; display: grid; place-items: center; }
|
||||
.direction-column__icon { width: 28px; height: 28px; display: block; }
|
||||
.direction-column__icon--dark { display: none; }
|
||||
|
||||
Reference in new issue
Block a user