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
-2
@@ -123,8 +123,7 @@ export async function downloadFile(elementId, context, filename) {
|
||||
}
|
||||
|
||||
export function textToDocument(text) {
|
||||
const blocks = text.split(/\n/).map((line) => ({ type: "paragraph", text: line }));
|
||||
return { version: 1, blocks: blocks.length ? blocks : [{ type: "paragraph", text: "" }] };
|
||||
return { version: 1, blocks: [{ type: "markdown", text: text || "" }] };
|
||||
}
|
||||
|
||||
export function documentToText(document) {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { Fragment } from "react";
|
||||
|
||||
function inline(text, keyPrefix) {
|
||||
const pattern = /(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\(https?:\/\/[^)\s]+\))/g;
|
||||
const nodes = [];
|
||||
let last = 0;
|
||||
let index = 0;
|
||||
for (const match of text.matchAll(pattern)) {
|
||||
if (match.index > last) nodes.push(text.slice(last, match.index));
|
||||
const token = match[0];
|
||||
const key = `${keyPrefix}-${index}`;
|
||||
if (token.startsWith("**")) nodes.push(<strong key={key}>{token.slice(2, -2)}</strong>);
|
||||
else if (token.startsWith("*")) nodes.push(<em key={key}>{token.slice(1, -1)}</em>);
|
||||
else if (token.startsWith("`")) nodes.push(<code key={key}>{token.slice(1, -1)}</code>);
|
||||
else {
|
||||
const linked = token.match(/^\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)$/);
|
||||
if (linked) {
|
||||
nodes.push(<a key={key} href={linked[2]} rel="noreferrer">{linked[1]}</a>);
|
||||
}
|
||||
}
|
||||
last = match.index + token.length;
|
||||
index += 1;
|
||||
}
|
||||
if (last < text.length) nodes.push(text.slice(last));
|
||||
return nodes;
|
||||
}
|
||||
|
||||
export function MarkdownView({ text }) {
|
||||
const lines = String(text || "").replace(/\r\n/g, "\n").split("\n");
|
||||
const blocks = [];
|
||||
let list = null;
|
||||
function closeList() {
|
||||
if (!list) return;
|
||||
const items = list.items.map((item, index) => <li key={`${list.key}-${index}`}>{inline(item, `${list.key}-${index}`)}</li>);
|
||||
blocks.push(list.ordered ? <ol key={list.key}>{items}</ol> : <ul key={list.key}>{items}</ul>);
|
||||
list = null;
|
||||
}
|
||||
lines.forEach((line, index) => {
|
||||
const heading = line.match(/^(#{1,3})\s+(.*)$/);
|
||||
const bullet = line.match(/^\s*[-*]\s+(.*)$/);
|
||||
const numbered = line.match(/^\s*\d+\.\s+(.*)$/);
|
||||
if (heading) {
|
||||
closeList();
|
||||
const Tag = heading[1].length === 1 ? "h3" : heading[1].length === 2 ? "h4" : "h5";
|
||||
blocks.push(<Tag key={`h-${index}`}>{inline(heading[2], `h-${index}`)}</Tag>);
|
||||
return;
|
||||
}
|
||||
if (bullet || numbered) {
|
||||
if (!list || list.ordered !== Boolean(numbered)) {
|
||||
closeList();
|
||||
list = { key: `l-${index}`, ordered: Boolean(numbered), items: [] };
|
||||
}
|
||||
list.items.push((bullet || numbered)[1]);
|
||||
return;
|
||||
}
|
||||
closeList();
|
||||
if (!line.trim()) {
|
||||
blocks.push(<Fragment key={`s-${index}`} />);
|
||||
return;
|
||||
}
|
||||
blocks.push(<p key={`p-${index}`}>{inline(line, `p-${index}`)}</p>);
|
||||
});
|
||||
closeList();
|
||||
return <div className="markdown">{blocks}</div>;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { SessionContext } from "../session.js";
|
||||
import { Modal } from "./Modal.jsx";
|
||||
import { MailPicker, PaperlessPicker } from "./Sources.jsx";
|
||||
import { ErrorNote, ShareBox } from "./widgets.jsx";
|
||||
import { ContentBoard, ObjectMenu, OrderChoice, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, saveChapterOrder, writeSelection } from "./content.jsx";
|
||||
import { ContentBoard, DirectionChoice, MarkdownEditor, ObjectMenu, OrderChoice, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, saveChapterOrder, writeSelection } from "./content.jsx";
|
||||
import { ReadingPane } from "./ReadingPane.jsx";
|
||||
import { StructureNavigator, Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
@@ -276,7 +276,10 @@ function caseNodes(record, parentRecord) {
|
||||
kind: "Akte",
|
||||
href: `/cases/${parentRecord.id}`,
|
||||
current: false,
|
||||
children: siblings.length ? siblings : [self],
|
||||
children: [
|
||||
...(siblings.length ? siblings : [self]),
|
||||
...(parentRecord.matters || []).map((matter) => matterNode(matter, parentRecord.id)),
|
||||
],
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -306,6 +309,40 @@ export function CaseDetail() {
|
||||
return detail;
|
||||
}
|
||||
|
||||
async function renameCase() {
|
||||
const title = window.prompt("Aktenname", record.title);
|
||||
if (!title || title.trim() === record.title) return;
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/cases/${id}`, { method: "PATCH", body: { expected_version: record.version, title: title.trim() } });
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function archiveCase() {
|
||||
const next = record.status === "closed" ? "open" : "closed";
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/cases/${id}`, { method: "PATCH", body: { expected_version: record.version, status: next } });
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteCase() {
|
||||
if (!window.confirm("Diese Akte löschen? Unterakten und zugeordnete Vorgänge müssen vorher gelöst sein. Inhalte bleiben erhalten.")) return;
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/cases/${id}/delete`, { method: "POST", body: { expected_version: record.version } });
|
||||
navigate("/cases");
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
setRecord(null);
|
||||
@@ -496,6 +533,9 @@ export function CaseDetail() {
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("assign")}>Vorhandenen Vorgang zuordnen</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("subcase")}>Unterakte anlegen</button> : null}
|
||||
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={renameCase}>Umbenennen</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={archiveCase}>{record.status === "closed" ? "Wieder öffnen" : "Archivieren"}</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={deleteCase}>Löschen</button> : null}
|
||||
</ObjectMenu>
|
||||
</div>
|
||||
</header>
|
||||
@@ -821,6 +861,7 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = "
|
||||
const [documentOn, setDocumentOn] = useState("");
|
||||
const [sentOn, setSentOn] = useState("");
|
||||
const [receivedOn, setReceivedOn] = useState("");
|
||||
const [direction, setDirection] = useState("");
|
||||
const [chapterId, setChapterId] = useState(initialChapter);
|
||||
const [error, setError] = useState("");
|
||||
const [pending, setPending] = useState(false);
|
||||
@@ -848,6 +889,7 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = "
|
||||
received_on: receivedOn || null,
|
||||
},
|
||||
} : {}),
|
||||
...(direction ? { communication_direction: direction } : {}),
|
||||
},
|
||||
});
|
||||
setTitle("");
|
||||
@@ -855,6 +897,7 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = "
|
||||
setDocumentOn("");
|
||||
setSentOn("");
|
||||
setReceivedOn("");
|
||||
setDirection("");
|
||||
markDirty(false);
|
||||
onChange();
|
||||
} catch (err) {
|
||||
@@ -869,7 +912,8 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = "
|
||||
<TargetLine label={targetLabel} chapters={chapters} chapterId={chapterId} />
|
||||
<h3>Notiz</h3>
|
||||
<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>
|
||||
<MarkdownEditor value={text} onChange={(value) => { setText(value); markDirty(true); }} rows={8} />
|
||||
<DirectionChoice value={direction} onChange={(value) => { setDirection(value); markDirty(true); }} />
|
||||
<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>
|
||||
@@ -887,6 +931,7 @@ export function FileForm({ context, placement, chapters = [], initialChapter = "
|
||||
const [documentOn, setDocumentOn] = useState("");
|
||||
const [sentOn, setSentOn] = useState("");
|
||||
const [receivedOn, setReceivedOn] = useState("");
|
||||
const [direction, setDirection] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
|
||||
useEffect(() => { setChapterId(initialChapter || ""); }, [initialChapter]);
|
||||
@@ -907,6 +952,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);
|
||||
setError("");
|
||||
try {
|
||||
await api("/api/v1/files", { method: "POST", form });
|
||||
@@ -928,6 +974,7 @@ export function FileForm({ context, placement, chapters = [], initialChapter = "
|
||||
<label>Dokumentdatum <input type="date" value={documentOn} onChange={(event) => setDocumentOn(event.target.value)} /></label>
|
||||
<label>Versand <input type="date" value={sentOn} onChange={(event) => setSentOn(event.target.value)} /></label>
|
||||
<label>Zugang <input type="date" value={receivedOn} onChange={(event) => setReceivedOn(event.target.value)} /></label>
|
||||
<DirectionChoice value={direction} onChange={setDirection} />
|
||||
{chapterSelect(chapters, chapterId, setChapterId)}
|
||||
<button type="submit">Datei hinzufügen</button>
|
||||
<ErrorNote error={error} />
|
||||
|
||||
@@ -189,6 +189,7 @@ function objectTrail(record, query) {
|
||||
|
||||
export function MatterDetail() {
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [params, setParams] = useSearchParams();
|
||||
const inherited = pageContext(params);
|
||||
const chapterId = params.get("kapitel") || "";
|
||||
@@ -213,6 +214,49 @@ export function MatterDetail() {
|
||||
return detail;
|
||||
}
|
||||
|
||||
async function renameMatter() {
|
||||
const title = window.prompt("Vorgangsname", record.title);
|
||||
if (!title || title.trim() === record.title) return;
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/matters/${id}`, {
|
||||
method: "PATCH",
|
||||
body: { expected_version: record.version, title: title.trim(), context: rightsContext },
|
||||
});
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function archiveMatter() {
|
||||
const next = record.status === "closed" ? "open" : "closed";
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/matters/${id}`, {
|
||||
method: "PATCH",
|
||||
body: { expected_version: record.version, status: next, context: rightsContext },
|
||||
});
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteMatter() {
|
||||
if (!window.confirm("Diesen Vorgang löschen? Teilvorgänge müssen vorher gelöst sein. Inhalte bleiben erhalten.")) return;
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/matters/${id}/delete`, {
|
||||
method: "POST",
|
||||
body: { expected_version: record.version, context: rightsContext },
|
||||
});
|
||||
navigate("/matters");
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
setRecord(null);
|
||||
@@ -435,6 +479,10 @@ export function MatterDetail() {
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("submatter")}>Teilvorgang anlegen</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("cross")}>Querverweis</button> : null}
|
||||
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={renameMatter}>Umbenennen</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={archiveMatter}>{record.status === "closed" ? "Wieder öffnen" : "Archivieren"}</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("move")}>Verschieben</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={deleteMatter}>Löschen</button> : null}
|
||||
</ObjectMenu>
|
||||
</div>
|
||||
</header>
|
||||
@@ -537,10 +585,98 @@ export function MatterDetail() {
|
||||
<Modal open={modal === "share"} title="Teilen" onClose={() => setModal("")}>
|
||||
<ShareBox path={`/api/v1/matters/${id}/grants`} grants={record.grants || []} onChange={load} />
|
||||
</Modal>
|
||||
<Modal open={modal === "move"} title="Vorgang verschieben" onClose={() => setModal("")}>
|
||||
<MoveMatter
|
||||
matterId={id}
|
||||
version={record.version}
|
||||
context={rightsContext}
|
||||
soleCaseId={(record.placements || []).length === 1 ? record.placements[0].case_id : ""}
|
||||
onDone={() => { setModal(""); load(); }}
|
||||
/>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function MoveMatter({ matterId, version, context, soleCaseId = "", onDone }) {
|
||||
const [cases, setCases] = useState([]);
|
||||
const [caseId, setCaseId] = useState("");
|
||||
const [matters, setMatters] = useState([]);
|
||||
const [parentId, setParentId] = useState("");
|
||||
const [clearParent, setClearParent] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const [pending, setPending] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
api("/api/v1/cases").then((data) => setCases(data.items || data || [])).catch((err) => setError(err.message));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!caseId) {
|
||||
setMatters([]);
|
||||
return undefined;
|
||||
}
|
||||
api(`/api/v1/cases/${caseId}`).then((detail) => {
|
||||
const direct = detail.matters || [];
|
||||
setMatters(direct.filter((item) => item.id !== matterId));
|
||||
}).catch((err) => setError(err.message));
|
||||
return undefined;
|
||||
}, [caseId, matterId]);
|
||||
|
||||
async function submit(event) {
|
||||
event.preventDefault();
|
||||
if (!caseId && !parentId && !clearParent) {
|
||||
setError("Wähle eine Akte oder einen übergeordneten Vorgang.");
|
||||
return;
|
||||
}
|
||||
setPending(true);
|
||||
setError("");
|
||||
try {
|
||||
const fromCase = context?.kind === "case" ? context.id : soleCaseId;
|
||||
await api(`/api/v1/matters/${matterId}/move`, {
|
||||
method: "POST",
|
||||
body: {
|
||||
expected_version: version,
|
||||
context: fromCase ? { kind: "case", id: fromCase } : context,
|
||||
...(caseId ? { case_id: caseId } : {}),
|
||||
...(parentId ? { parent_matter_id: parentId } : {}),
|
||||
...(clearParent ? { clear_parent: true } : {}),
|
||||
},
|
||||
});
|
||||
onDone();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form className="stack" onSubmit={submit}>
|
||||
<label>
|
||||
Akte oder Unterakte
|
||||
<select value={caseId} onChange={(event) => setCaseId(event.target.value)}>
|
||||
<option value="">Akte unverändert lassen</option>
|
||||
{cases.map((item) => <option key={item.id} value={item.id}>{item.title}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Übergeordneter Vorgang
|
||||
<select value={parentId} disabled={!caseId || clearParent} onChange={(event) => setParentId(event.target.value)}>
|
||||
<option value="">Kein neuer übergeordneter Vorgang</option>
|
||||
{matters.map((item) => <option key={item.id} value={item.id}>{item.title}</option>)}
|
||||
</select>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={clearParent} onChange={(event) => { setClearParent(event.target.checked); if (event.target.checked) setParentId(""); }} />
|
||||
Aus dem übergeordneten Vorgang lösen
|
||||
</label>
|
||||
<button type="submit" disabled={pending}>{pending ? "Wird verschoben …" : "Verschieben"}</button>
|
||||
<ErrorNote error={error} />
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
function WorkForms({ matterId, context, deadlines, onChange }) {
|
||||
const [taskTitle, setTaskTitle] = useState("");
|
||||
const [taskDue, setTaskDue] = useState("");
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -435,7 +435,8 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
async function link(item) {
|
||||
setError("");
|
||||
const letter = preview && preview.uid === item.uid ? preview : null;
|
||||
const direction = (letter?.direction || item.direction) === "out" ? "out" : "in";
|
||||
const known = letter?.direction || item.direction;
|
||||
const direction = known === "out" || known === "in" ? known : null;
|
||||
const attachments = (letter?.attachments || item.attachments || [])
|
||||
.filter((file) => file?.filename)
|
||||
.map((file) => ({
|
||||
@@ -513,14 +514,16 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
{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 incoming = item.direction === "in";
|
||||
const who = outgoing ? (item.message_to ? `an ${item.message_to}` : "") : (item.message_from || "");
|
||||
const way = outgoing ? "Ausgang" : incoming ? "Eingang" : "";
|
||||
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>{[way, who].filter(Boolean).join(" · ")}</span>
|
||||
</span>
|
||||
{files ? <span className="mail-row__files" aria-label={`${files} ${files === 1 ? "Anhang" : "Anhänge"}`}>{files}</span> : null}
|
||||
</button>
|
||||
@@ -533,7 +536,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
{!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 className="mail-preview__party">{(preview?.direction || selected.direction) === "out" ? "Ausgang" : (preview?.direction || selected.direction) === "in" ? "Eingang" : "Richtung nicht bekannt"}</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}
|
||||
@@ -542,6 +545,7 @@ export function MailPicker({ context, placement, chapterId = "", chapterTitle =
|
||||
{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?.text_truncated ? <p className="muted">Der Text ist gekürzt, weil die Nachricht sehr groß ist.</p> : 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>
|
||||
</>
|
||||
|
||||
+104
-21
@@ -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}
|
||||
|
||||
@@ -453,6 +453,21 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
.chapter-head.is-movable .chapter-date,
|
||||
.chapter-head.is-movable .chapter-move { cursor: auto; touch-action: auto; user-select: auto; }
|
||||
.chapter-title { margin: 22px 0 4px; font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--text1); font-weight: 700; }
|
||||
.chapter-menu { display: inline-flex; gap: 8px; flex: 0 0 auto; }
|
||||
.direction-mark { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
|
||||
.direction-mark__icon { display: block; }
|
||||
.direction-mark__icon--dark { display: none; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.direction-mark__icon--light { display: none; }
|
||||
.direction-mark__icon--dark { display: block; }
|
||||
}
|
||||
.markdown-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
|
||||
.markdown-editor__preview { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 8rem; overflow: auto; }
|
||||
.markdown-editor__preview h1, .markdown-editor__preview h2, .markdown-editor__preview h3 { margin: 0.4em 0; }
|
||||
.markdown-editor__preview p, .markdown-editor__preview ul, .markdown-editor__preview ol { margin: 0.4em 0; }
|
||||
@media (max-width: 720px) {
|
||||
.markdown-editor { grid-template-columns: 1fr; }
|
||||
}
|
||||
.chapter-head .chapter-title { margin: 0; flex: 1 1 8rem; }
|
||||
.chapter-date { display: flex; align-items: center; gap: 6px; margin: 0 0 0 auto; color: var(--text2); font-size: 13px; }
|
||||
.chapter-date__label { font-weight: 700; color: var(--text3); }
|
||||
|
||||
Reference in new issue
Block a user