Unterscheide Eingang und Ausgang an der Einbindung und ermoegliche Umbenennen, Archivieren, Loeschen und Verschieben.
Deploy Development / deploy (push) Successful in 26s
Test Suite / pytest-backend (push) Successful in 1m4s
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-17 18:30:26 +02:00
1 parent 20625b4596
commit ad6240a5da
27 files changed
+1191 -88

No files matched your search

+104 -21
View File
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react";
import { Link } from "react-router-dom";
import { api, fetchFile, fetchPaperless } from "../api.js";
import { contentSourceSymbol, contentSymbol } from "../content-symbol.mjs";
import { MarkdownView } from "../markdown.jsx";
import { Modal } from "./Modal.jsx";
import { ErrorNote } from "./widgets.jsx";
@@ -242,7 +243,7 @@ function elementSymbol(element) {
return contentSymbol(element || {});
}
function sourceLabel(element) {
export function sourceLabel(element) {
const type = SYMBOL_LABEL[elementSymbol(element)] || "Datei";
if (element.external?.source === "paperless") return `${type} · Paperless`;
if (element.external?.source === "imap") return "E-Mail";
@@ -253,28 +254,65 @@ function sourceLabel(element) {
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 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(" · ");
return [from, to, files].filter(Boolean).join(" · ");
}
function dateFlow(element) {
if (element?.external?.source === "imap") return "";
export function dateCaption(element) {
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 "";
const parts = [];
if (dates.received_on) parts.push(`Eingegangen am ${formatDate(dates.received_on)}`);
if (dates.sent_on) parts.push(`Versendet am ${formatDate(dates.sent_on)}`);
return parts.join(" · ");
}
export function elementFacts(element) {
const type = sourceLabel(element);
const mail = mailFacts(element);
const flow = dateFlow(element);
return [type, mail, flow].filter(Boolean).join(" · ");
export function elementFacts(element, communication) {
const direction = communication?.direction;
const way = direction === "out" ? "Ausgang" : direction === "in" ? "Eingang" : "";
return [sourceLabel(element), way, mailFacts(element), dateCaption(element, direction)].filter(Boolean).join(" · ");
}
export function DirectionMark({ direction }) {
if (direction !== "in" && direction !== "out") return null;
const name = direction === "out" ? "communication-out" : "communication-in";
const label = direction === "out" ? "Ausgang" : "Eingang";
return (
<span className="direction-mark">
<img className="direction-mark__icon direction-mark__icon--light" src={`/ui/content-symbols-v1/light/${name}.svg`} width="16" height="16" alt="" />
<img className="direction-mark__icon direction-mark__icon--dark" src={`/ui/content-symbols-v1/dark/${name}.svg`} width="16" height="16" alt="" />
<span>{label}</span>
</span>
);
}
export function DirectionChoice({ value, disabled, onChange }) {
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>
);
}
export function MarkdownEditor({ value, onChange, disabled, rows = 12 }) {
return (
<div className="markdown-editor">
<label>
Markdown
<textarea rows={rows} value={value} disabled={disabled} onChange={(event) => onChange(event.target.value)} />
</label>
<div className="markdown-editor__preview" aria-label="Gerenderte Notiz">
{value.trim() ? <MarkdownView text={value} /> : <p className="muted">Die Vorschau erscheint hier.</p>}
</div>
</div>
);
}
function directionMark(direction) {
@@ -284,7 +322,8 @@ function directionMark(direction) {
}
function blurb(element) {
return element.summary || element.excerpt || "";
const raw = element.summary || element.excerpt || "";
return raw.replace(/^#{1,3}\s+/gm, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/[*`]/g, "").replace(/\s+/g, " ").trim();
}
function BezugLines({ element, source, onOpen, itemHref }) {
@@ -311,7 +350,7 @@ function BezugLink({ item, label, source, onOpen, itemHref, reply = false }) {
<>
<span>{label}</span>
<strong>{formatDate(item.document_on)} · {item.title}</strong>
{directionMark(item.direction) ? <em>{directionMark(item.direction)}</em> : null}
<DirectionMark direction={item.direction} />
</>
);
if (found && onOpen) {
@@ -611,6 +650,41 @@ export function ContentBoard({
}
}
async function renameChapter(section) {
const title = window.prompt("Kapitelname", section.title);
if (!title || title.trim() === section.title) return;
setError("");
setPending(true);
try {
await api(`/api/v1/chapters/${section.id}/title`, {
method: "PATCH",
body: { expected_version: record.version, title: title.trim(), ...orderContext },
});
onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}
async function removeChapter(section) {
if (!window.confirm(`Kapitel „${section.title}“ löschen? Die Inhalte bleiben in der Liste.`)) return;
setError("");
setPending(true);
try {
await api(`/api/v1/chapters/${section.id}/delete`, {
method: "POST",
body: { expected_version: record.version, ...orderContext },
});
onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}
async function move(bindingId, delta) {
const next = sections.map((section) => ({ ...section, items: [...section.items] }));
let moved = false;
@@ -836,11 +910,11 @@ export function ContentBoard({
draggable={movable && !pending}
onPointerDownCapture={(event) => {
if (!movable) return;
if (event.target.closest("input, textarea, select, a, label, .chapter-move, .chapter-date")) return;
if (event.target.closest("input, textarea, select, a, label, .chapter-move, .chapter-date, .chapter-menu")) return;
beginDrag(event, { kind: "chapter", chapterId: section.id });
}}
onDragStart={(event) => {
if (!movable || event.target.closest("input, textarea, select, a, label, .chapter-move")) {
if (!movable || event.target.closest("input, textarea, select, a, label, .chapter-move, .chapter-menu")) {
event.preventDefault();
return;
}
@@ -857,6 +931,12 @@ export function ContentBoard({
</span>
) : null}
<h3 className="chapter-title">{section.title}</h3>
{canEdit && section.id !== "loose" ? (
<span className="chapter-menu">
<button type="button" className="quiet" onClick={() => renameChapter(section)}>Umbenennen</button>
<button type="button" className="quiet" onClick={() => removeChapter(section)}>Löschen</button>
</span>
) : null}
{section.id !== "loose" ? (
<span className="chapter-date">
<span className="chapter-date__label">Kapiteldatum</span>
@@ -930,7 +1010,10 @@ export function ContentBoard({
<TypeGlyph name={sourceSymbol} tone="dark" size={16} />
</span>
) : null}
{formatDate(fachDate(element))} · {elementFacts(element)}
{formatDate(fachDate(element))} · {sourceLabel(element)}
<DirectionMark direction={binding.communication?.direction} />
{mailFacts(element) ? <span>{mailFacts(element)}</span> : null}
{dateCaption(element, binding.communication?.direction) ? <span>{dateCaption(element, binding.communication?.direction)}</span> : null}
</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}