Halte die Vorgangsleiste sichtbar und nimm die ueberfluessigen Kapitelworte weg, damit Datum, Bezuege, Titel und mehrere Belege direkt gesetzt werden koennen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
cbd45a8997
commit
deb5d662fe
13 files changed
+423
-101
No files matched your search
@@ -6,7 +6,7 @@ import { chapterPathLabel, siblingChapterIds, trailWithChapter } from "./chapter
|
||||
import { Modal } from "./Modal.jsx";
|
||||
import { MailPicker, PaperlessPicker } from "./Sources.jsx";
|
||||
import { ErrorNote, ShareBox } from "./widgets.jsx";
|
||||
import { ContentBoard, DirectionChoice, MarkdownEditor, ObjectMenu, OrderChoice, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, saveChapterOrder, writeSelection } from "./content.jsx";
|
||||
import { ContentBoard, DateField, 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";
|
||||
@@ -297,6 +297,7 @@ export function CaseDetail() {
|
||||
const [error, setError] = useState("");
|
||||
const [modal, setModal] = useState("");
|
||||
const [chapterParentId, setChapterParentId] = useState("");
|
||||
const [addChapterId, setAddChapterId] = useState("");
|
||||
const [view, setView] = useState("contents");
|
||||
const [dateDir, setDateDir] = useState("asc");
|
||||
const { width, structureOpen, setStructureOpen } = useWorkspaceLayout();
|
||||
@@ -441,6 +442,11 @@ export function CaseDetail() {
|
||||
setModal("chapter");
|
||||
}
|
||||
|
||||
function openAdd(targetChapterId = chapterId) {
|
||||
setAddChapterId(targetChapterId || "");
|
||||
setModal("add");
|
||||
}
|
||||
|
||||
async function moveChapter(chapterIdToMove, delta) {
|
||||
const ids = siblingChapterIds(record?.chapters || [], chapterIdToMove);
|
||||
const index = ids.indexOf(chapterIdToMove);
|
||||
@@ -532,7 +538,7 @@ export function CaseDetail() {
|
||||
<div className="page-actions">
|
||||
{width < 1500 ? <button type="button" className="quiet" onClick={() => setStructureOpen(true)}>Struktur</button> : null}
|
||||
{canEdit ? (
|
||||
<button type="button" className="desktop-add" onClick={() => setModal("add")}>
|
||||
<button type="button" className="desktop-add" onClick={() => openAdd(chapterId)}>
|
||||
<NavIcon name="plus" /> Inhalt hinzufügen
|
||||
</button>
|
||||
) : null}
|
||||
@@ -575,6 +581,7 @@ export function CaseDetail() {
|
||||
selectedId={entryId}
|
||||
listTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : "Direkt in dieser Akte"}
|
||||
onAddSubchapter={canEdit ? openChapter : null}
|
||||
onAddContent={canEdit ? openAdd : null}
|
||||
context={context}
|
||||
onOpen={openEntry}
|
||||
onChange={load}
|
||||
@@ -601,7 +608,7 @@ export function CaseDetail() {
|
||||
</div>
|
||||
) : null}
|
||||
{canEdit && view === "contents" && !overview ? (
|
||||
<button type="button" className="mobile-add" onClick={() => setModal("add")}>
|
||||
<button type="button" className="mobile-add" onClick={() => openAdd(chapterId)}>
|
||||
<NavIcon name="plus" /> Inhalt hinzufügen
|
||||
</button>
|
||||
) : null}
|
||||
@@ -614,10 +621,10 @@ export function CaseDetail() {
|
||||
</Modal>
|
||||
<Modal open={modal === "add"} title={`Hinzufügen in ${targetLabel}`} onClose={() => setModal("")}>
|
||||
<p className="muted">Dieser Inhalt liegt direkt in der Akte. Er erscheint unter „Direkt in dieser Akte“ und im Überblick, nicht in einem Vorgang.</p>
|
||||
<TargetLine label={targetLabel} chapters={record.chapters} chapterId={activeChapter?.id || ""} />
|
||||
<TargetLine label={targetLabel} chapters={record.chapters} chapterId={addChapterId} />
|
||||
<div className="add-choices">
|
||||
<button type="button" onClick={() => openChapter(activeChapter?.id || "")}>{activeChapter ? "Unterkapitel" : "Kapitel"}</button>
|
||||
{activeChapter ? <button type="button" onClick={() => openChapter("")}>Kapitel auf oberster Ebene</button> : null}
|
||||
<button type="button" onClick={() => openChapter(addChapterId)}>{addChapterId ? "Unterkapitel" : "Kapitel"}</button>
|
||||
{addChapterId ? <button type="button" onClick={() => openChapter("")}>Kapitel auf oberster Ebene</button> : null}
|
||||
<button type="button" onClick={() => setModal("note")}>Notiz</button>
|
||||
<button type="button" onClick={() => setModal("file")}>Datei</button>
|
||||
<button type="button" onClick={() => setModal("paperless")}>Paperless</button>
|
||||
@@ -625,16 +632,16 @@ export function CaseDetail() {
|
||||
</div>
|
||||
</Modal>
|
||||
<Modal open={modal === "note"} title="Notiz" onClose={() => setModal("")}>
|
||||
<NoteForm context={context} chapters={record.chapters} initialChapter={activeChapter?.id || ""} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
<NoteForm context={context} chapters={record.chapters} initialChapter={addChapterId} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "file"} title="Datei" onClose={() => setModal("")}>
|
||||
<FileForm context={context} chapters={record.chapters} initialChapter={activeChapter?.id || ""} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
<FileForm context={context} chapters={record.chapters} initialChapter={addChapterId} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "paperless"} title="Aus Paperless" onClose={() => setModal("")}>
|
||||
<PaperlessPicker context={context} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
<PaperlessPicker context={context} chapterId={addChapterId} chapterTitle={addChapterId ? chapterPathLabel(record.chapters, addChapterId) : ""} targetLabel={targetLabel} onInserted={load} onDone={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "mail"} title="E-Mail verbinden" wide split onClose={() => setModal("")}>
|
||||
<MailPicker context={context} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
<MailPicker context={context} chapterId={addChapterId} chapterTitle={addChapterId ? chapterPathLabel(record.chapters, addChapterId) : ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "subcase"} title="Unterakte anlegen" onClose={() => setModal("")}>
|
||||
<NewSubcase parentId={id} onChange={() => { setModal(""); load(); }} />
|
||||
@@ -846,7 +853,7 @@ export function ChapterForm({ path, onChange, targetLabel = "", parentChapter =
|
||||
{parentChapter ? <>Elternkapitel: <strong>{parentChapter.title}</strong></> : <>Ebene: <strong>oberste Kapitel</strong></>}
|
||||
</p>
|
||||
<label>Titel <input value={title} onChange={(event) => setTitle(event.target.value)} placeholder={parentChapter ? "Unterkapitel" : "Kapitel"} required /></label>
|
||||
<label>Fachliches Datum, optional <input type="date" value={dated} onChange={(event) => setDated(event.target.value)} /></label>
|
||||
<label>Fachliches Datum, optional <DateField value={dated} onChange={setDated} /></label>
|
||||
<button type="submit">Hinzufügen</button>
|
||||
<ErrorNote error={error} />
|
||||
</form>
|
||||
@@ -937,9 +944,9 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = "
|
||||
<label>Titel <input value={title} onChange={(event) => { setTitle(event.target.value); markDirty(true); }} required /></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>
|
||||
<label>Bezugsdatum, optional <DateField value={documentOn} onChange={setDocumentOn} /></label>
|
||||
<label>Versand, optional <DateField value={sentOn} onChange={setSentOn} /></label>
|
||||
<label>Zugang, optional <DateField value={receivedOn} onChange={setReceivedOn} /></label>
|
||||
{chapterSelect(chapters, chapterId, setChapterId)}
|
||||
<button type="submit" disabled={pending}>{pending ? "Wird angelegt …" : "Notiz anlegen"}</button>
|
||||
<ErrorNote error={error} />
|
||||
@@ -994,9 +1001,9 @@ export function FileForm({ context, placement, chapters = [], initialChapter = "
|
||||
<h3>Datei</h3>
|
||||
<input value={title} onChange={(event) => setTitle(event.target.value)} placeholder="Titel des Schreibens" required />
|
||||
<input type="file" accept="application/pdf,image/png,image/jpeg,image/webp" onChange={(event) => setFile(event.target.files?.[0] || null)} required />
|
||||
<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>
|
||||
<label>Dokumentdatum <DateField value={documentOn} onChange={setDocumentOn} /></label>
|
||||
<label>Versand <DateField value={sentOn} onChange={setSentOn} /></label>
|
||||
<label>Zugang <DateField value={receivedOn} onChange={setReceivedOn} /></label>
|
||||
<DirectionChoice value={direction} onChange={setDirection} />
|
||||
{chapterSelect(chapters, chapterId, setChapterId)}
|
||||
<button type="submit">Datei hinzufügen</button>
|
||||
@@ -1055,9 +1062,9 @@ function ExternalForm({ context, placement, chapters = [], initialChapter = "",
|
||||
<option value="url">Andere Quelle</option>
|
||||
</select>
|
||||
<input value={externalId} onChange={(event) => setExternalId(event.target.value)} placeholder="Externe ID" required />
|
||||
<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>
|
||||
<label>Dokumentdatum <DateField value={documentOn} onChange={setDocumentOn} /></label>
|
||||
<label>Versand <DateField value={sentOn} onChange={setSentOn} /></label>
|
||||
<label>Zugang <DateField value={receivedOn} onChange={setReceivedOn} /></label>
|
||||
{chapterSelect(chapters, chapterId, setChapterId)}
|
||||
<button type="submit">Referenz erfassen</button>
|
||||
<ErrorNote error={error} />
|
||||
|
||||
@@ -7,7 +7,7 @@ import { MailPicker, PaperlessPicker } from "./Sources.jsx";
|
||||
import { ErrorNote, ShareBox } from "./widgets.jsx";
|
||||
import { chapterPathLabel, siblingChapterIds, trailWithChapter } from "./chapters.js";
|
||||
import { ChapterForm, FileForm, NoteForm } from "./Cases.jsx";
|
||||
import { ContentBoard, ObjectMenu, Placements, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, matterOpenHref, saveChapterOrder, writeChapter } from "./content.jsx";
|
||||
import { ContentBoard, DateField, ObjectMenu, Placements, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, matterOpenHref, saveChapterOrder, writeChapter } from "./content.jsx";
|
||||
import { ReadingPane } from "./ReadingPane.jsx";
|
||||
import { StructureNavigator, Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
@@ -199,6 +199,7 @@ export function MatterDetail() {
|
||||
const [error, setError] = useState("");
|
||||
const [modal, setModal] = useState("");
|
||||
const [chapterParentId, setChapterParentId] = useState("");
|
||||
const [addChapterId, setAddChapterId] = useState("");
|
||||
const rightsContext = inherited || { kind: "matter", id };
|
||||
const placement = inherited?.kind === "case" ? { kind: "matter", id } : null;
|
||||
const [view, setView] = useState("contents");
|
||||
@@ -374,6 +375,11 @@ export function MatterDetail() {
|
||||
setModal("chapter");
|
||||
}
|
||||
|
||||
function openAdd(targetChapterId = chapterId) {
|
||||
setAddChapterId(targetChapterId || "");
|
||||
setModal("add");
|
||||
}
|
||||
|
||||
async function moveChapter(chapterIdToMove, delta) {
|
||||
const ids = siblingChapterIds(record?.chapters || [], chapterIdToMove);
|
||||
const index = ids.indexOf(chapterIdToMove);
|
||||
@@ -468,6 +474,7 @@ export function MatterDetail() {
|
||||
/>
|
||||
) : null}
|
||||
>
|
||||
<div className="workspace-pin">
|
||||
<header className="workspace-head">
|
||||
<div>
|
||||
<Trail items={trailWithChapter(record.trail?.length ? record.trail : objectTrail(record, query), record.chapters, chapterId, `/matters/${id}${query}`)} />
|
||||
@@ -480,7 +487,7 @@ export function MatterDetail() {
|
||||
<div className="page-actions">
|
||||
{width < 1500 ? <button type="button" className="quiet" onClick={() => setStructureOpen(true)}>Struktur</button> : null}
|
||||
{canEdit ? (
|
||||
<button type="button" className="desktop-add" onClick={() => setModal("add")}>
|
||||
<button type="button" className="desktop-add" onClick={() => openAdd(chapterId)}>
|
||||
<NavIcon name="plus" /> Inhalt hinzufügen
|
||||
</button>
|
||||
) : null}
|
||||
@@ -499,6 +506,7 @@ export function MatterDetail() {
|
||||
{!canEdit ? <p className="muted">In {targetLabel} fehlt das Bearbeitungsrecht.</p> : null}
|
||||
<ErrorNote error={error} />
|
||||
<WorkSwitch view={view} onView={setView} />
|
||||
</div>
|
||||
{view === "contents" ? (
|
||||
<ContentBoard
|
||||
record={record}
|
||||
@@ -509,6 +517,7 @@ export function MatterDetail() {
|
||||
selectedId={entryId}
|
||||
listTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : "Alle Inhalte"}
|
||||
onAddSubchapter={canEdit ? openChapter : null}
|
||||
onAddContent={canEdit ? openAdd : null}
|
||||
onOpen={(binding) => {
|
||||
rememberScroll(listRef.current, scrollKey);
|
||||
openEntry(binding);
|
||||
@@ -544,7 +553,7 @@ export function MatterDetail() {
|
||||
</div>
|
||||
) : null}
|
||||
{canEdit && view === "contents" ? (
|
||||
<button type="button" className="mobile-add" onClick={() => setModal("add")}>
|
||||
<button type="button" className="mobile-add" onClick={() => openAdd(chapterId)}>
|
||||
<NavIcon name="plus" /> Inhalt hinzufügen
|
||||
</button>
|
||||
) : null}
|
||||
@@ -556,10 +565,10 @@ export function MatterDetail() {
|
||||
<WorkForms matterId={id} context={inherited} deadlines={record.deadlines || []} onChange={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "add"} title={`Hinzufügen in ${targetLabel}`} onClose={() => setModal("")}>
|
||||
<TargetLine label={targetLabel} chapters={record.chapters} chapterId={activeChapter?.id || ""} />
|
||||
<TargetLine label={targetLabel} chapters={record.chapters} chapterId={addChapterId} />
|
||||
<div className="add-choices">
|
||||
<button type="button" onClick={() => openChapter(activeChapter?.id || "")}>{activeChapter ? "Unterkapitel" : "Kapitel"}</button>
|
||||
{activeChapter ? <button type="button" onClick={() => openChapter("")}>Kapitel auf oberster Ebene</button> : null}
|
||||
<button type="button" onClick={() => openChapter(addChapterId)}>{addChapterId ? "Unterkapitel" : "Kapitel"}</button>
|
||||
{addChapterId ? <button type="button" onClick={() => openChapter("")}>Kapitel auf oberster Ebene</button> : null}
|
||||
<button type="button" onClick={() => setModal("note")}>Notiz</button>
|
||||
<button type="button" onClick={() => setModal("file")}>Datei</button>
|
||||
<button type="button" onClick={() => setModal("paperless")}>Paperless</button>
|
||||
@@ -567,16 +576,16 @@ export function MatterDetail() {
|
||||
</div>
|
||||
</Modal>
|
||||
<Modal open={modal === "note"} title="Notiz" onClose={() => setModal("")}>
|
||||
<NoteForm context={rightsContext} placement={placement} chapters={record.chapters} initialChapter={activeChapter?.id || ""} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
<NoteForm context={rightsContext} placement={placement} chapters={record.chapters} initialChapter={addChapterId} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "file"} title="Datei" onClose={() => setModal("")}>
|
||||
<FileForm context={rightsContext} placement={placement} chapters={record.chapters} initialChapter={activeChapter?.id || ""} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
<FileForm context={rightsContext} placement={placement} chapters={record.chapters} initialChapter={addChapterId} targetLabel={targetLabel} onChange={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "paperless"} title="Aus Paperless" onClose={() => setModal("")}>
|
||||
<PaperlessPicker context={rightsContext} placement={placement} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
<PaperlessPicker context={rightsContext} placement={placement} chapterId={addChapterId} chapterTitle={addChapterId ? chapterPathLabel(record.chapters, addChapterId) : ""} targetLabel={targetLabel} onInserted={load} onDone={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "mail"} title="E-Mail verbinden" wide split onClose={() => setModal("")}>
|
||||
<MailPicker context={rightsContext} placement={placement} chapterId={activeChapter?.id || ""} chapterTitle={activeChapter ? chapterPathLabel(record.chapters, activeChapter.id) : ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
<MailPicker context={rightsContext} placement={placement} chapterId={addChapterId} chapterTitle={addChapterId ? chapterPathLabel(record.chapters, addChapterId) : ""} targetLabel={targetLabel} onDone={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
<Modal open={modal === "submatter"} title="Teilvorgang anlegen" onClose={() => setModal("")}>
|
||||
<SubmatterForm parentId={id} context={inherited} onChange={() => { setModal(""); load(); }} />
|
||||
@@ -756,13 +765,13 @@ function WorkForms({ matterId, context, deadlines, onChange }) {
|
||||
<form onSubmit={addDeadline} className="stack compact">
|
||||
<h3>Frist</h3>
|
||||
<input value={deadlineTitle} onChange={(event) => setDeadlineTitle(event.target.value)} placeholder="Maßgeblicher Termin" required />
|
||||
<label>Frist <input type="date" value={deadlineDue} onChange={(event) => setDeadlineDue(event.target.value)} required /></label>
|
||||
<label>Frist <DateField value={deadlineDue} onChange={setDeadlineDue} required /></label>
|
||||
<button type="submit">Frist erfassen</button>
|
||||
</form>
|
||||
<form onSubmit={addTask} className="stack compact">
|
||||
<h3>Aufgabe</h3>
|
||||
<input value={taskTitle} onChange={(event) => setTaskTitle(event.target.value)} placeholder="Was ist vor der Frist zu tun?" required />
|
||||
<label>Arbeitstermin <input type="date" value={taskDue} onChange={(event) => setTaskDue(event.target.value)} /></label>
|
||||
<label>Arbeitstermin <DateField value={taskDue} onChange={setTaskDue} /></label>
|
||||
<label>
|
||||
Gehört zur Frist
|
||||
<select value={deadlineId} onChange={(event) => setDeadlineId(event.target.value)}>
|
||||
|
||||
@@ -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, directionValue, directionWord, formatDate, mailFacts, MarkdownEditor, sourceLabel } from "./content.jsx";
|
||||
import { dateCaption, DateField, 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";
|
||||
|
||||
@@ -383,6 +383,21 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
}
|
||||
}
|
||||
|
||||
async function renameTitle() {
|
||||
const title = window.prompt("Titel", element.title);
|
||||
if (!title || title.trim() === element.title) return;
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/elements/${element.id}/title`, {
|
||||
method: "PATCH",
|
||||
body: { expected_version: element.version, title: title.trim(), context },
|
||||
});
|
||||
onReload();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDate(event) {
|
||||
event.preventDefault();
|
||||
setError("");
|
||||
@@ -463,6 +478,11 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
<div className="reader-title">
|
||||
<DirectionColumn direction={shownDirection} />
|
||||
<h2>{element.title}</h2>
|
||||
{binding.rights.edit ? (
|
||||
<button type="button" className="icon-button icon-button--compact" aria-label="Titel ändern" onClick={renameTitle}>
|
||||
<NavIcon name="pencil" />
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="reader-facts">
|
||||
<span>{formatDate(element.dates?.document_on)} · {sourceLabel(element)}</span>
|
||||
@@ -615,15 +635,15 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
<form className="stack" onSubmit={saveDate}>
|
||||
<label>
|
||||
{element.kind === "note" ? "Bezugsdatum, optional" : "Dokumentdatum, optional"}
|
||||
<input type="date" value={documentOn} onChange={(event) => { setDocumentOn(event.target.value); markDirty(true); }} />
|
||||
<DateField value={documentOn} onChange={(value) => { setDocumentOn(value); markDirty(true); }} />
|
||||
</label>
|
||||
<label>
|
||||
Versand, optional
|
||||
<input type="date" value={sentOn} onChange={(event) => { setSentOn(event.target.value); markDirty(true); }} />
|
||||
<DateField value={sentOn} onChange={(value) => { setSentOn(value); markDirty(true); }} />
|
||||
</label>
|
||||
<label>
|
||||
Zugang, optional
|
||||
<input type="date" value={receivedOn} onChange={(event) => { setReceivedOn(event.target.value); markDirty(true); }} />
|
||||
<DateField value={receivedOn} onChange={(value) => { setReceivedOn(value); markDirty(true); }} />
|
||||
</label>
|
||||
<button type="submit" className="quiet">Datum speichern</button>
|
||||
</form>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { NavLink, Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||
import { NavLink, Outlet, useNavigate } from "react-router-dom";
|
||||
import { SessionContext } from "../session.js";
|
||||
import { Mark, NavIcon } from "./icons.jsx";
|
||||
|
||||
@@ -18,10 +18,15 @@ function initials(name) {
|
||||
return parts.slice(0, 2).map((part) => part[0]).join("").toUpperCase();
|
||||
}
|
||||
|
||||
const MOBILE = [
|
||||
...WORK,
|
||||
{ to: "/settings", label: "Verwaltung", short: "Verwaltung", icon: "gear" },
|
||||
{ to: "/search", label: "Suche", short: "Suche", icon: "search" },
|
||||
];
|
||||
|
||||
export function Shell() {
|
||||
const { session, logout } = useContext(SessionContext);
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const [expanded, setExpanded] = useState(() => {
|
||||
try {
|
||||
return localStorage.getItem(NAV_KEY) !== "0";
|
||||
@@ -32,7 +37,6 @@ export function Shell() {
|
||||
const [query, setQuery] = useState("");
|
||||
const [searchOpen, setSearchOpen] = useState(false);
|
||||
const searchRef = useRef(null);
|
||||
const [more, setMore] = useState(false);
|
||||
const [width, setWidth] = useState(() => window.innerWidth);
|
||||
const [markIntroDone, setMarkIntroDone] = useState(false);
|
||||
const markMotion = markIntroDone ? "none" : "intro";
|
||||
@@ -71,10 +75,6 @@ export function Shell() {
|
||||
return () => cancelAnimationFrame(frame);
|
||||
}, [markIntroDone]);
|
||||
|
||||
useEffect(() => {
|
||||
setMore(false);
|
||||
}, [location.pathname]);
|
||||
|
||||
const forcedCompact = width < 1180;
|
||||
const compact = forcedCompact || !expanded;
|
||||
|
||||
@@ -173,32 +173,17 @@ export function Shell() {
|
||||
<Outlet />
|
||||
</div>
|
||||
<nav className="bottom-nav" aria-label="Hauptnavigation">
|
||||
{WORK.map((item) => (
|
||||
{MOBILE.map((item) => (
|
||||
<NavLink key={item.to} to={item.to} end={item.end} className={({ isActive }) => `nav-item${isActive ? " active" : ""}`}>
|
||||
<NavIcon name={item.icon} />
|
||||
<span>{item.short}</span>
|
||||
</NavLink>
|
||||
))}
|
||||
<button type="button" className={`nav-item${more ? " active" : ""}`} onClick={() => setMore(true)}>
|
||||
<NavIcon name="more" />
|
||||
<span>Mehr</span>
|
||||
<button type="button" className="nav-item" onClick={logout}>
|
||||
<NavIcon name="logout" />
|
||||
<span>Abmelden</span>
|
||||
</button>
|
||||
</nav>
|
||||
{more ? (
|
||||
<div className="modal-overlay" onClick={(event) => { if (event.target === event.currentTarget) setMore(false); }}>
|
||||
<div className="sheet" role="dialog" aria-modal="true" aria-label="Weitere Ziele">
|
||||
<header className="modal__bar">
|
||||
<h2>Mehr</h2>
|
||||
<button type="button" className="quiet" onClick={() => setMore(false)}>Schließen</button>
|
||||
</header>
|
||||
<div className="menu-list">
|
||||
<NavLink to="/settings" onClick={() => setMore(false)}>Verwaltung</NavLink>
|
||||
<NavLink to="/search" onClick={() => setMore(false)}>Suche</NavLink>
|
||||
<button type="button" className="quiet" onClick={logout}>Abmelden</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -135,14 +135,17 @@ function MailForm({ onSaved, onError }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function PaperlessPicker({ context, placement, chapterId = "", chapterTitle = "", targetLabel = "", onDone }) {
|
||||
export function PaperlessPicker({ context, placement, chapterId = "", chapterTitle = "", targetLabel = "", onDone, onInserted }) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [items, setItems] = useState([]);
|
||||
const [picked, setPicked] = useState(() => new Set());
|
||||
const [pending, setPending] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function search(event) {
|
||||
event.preventDefault();
|
||||
setError("");
|
||||
setPicked(new Set());
|
||||
try {
|
||||
const data = await api(`/api/v1/sources/paperless/documents?q=${encodeURIComponent(query)}`);
|
||||
setItems(data.items);
|
||||
@@ -151,33 +154,60 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
}
|
||||
}
|
||||
|
||||
async function link(item) {
|
||||
function toggle(id) {
|
||||
setPicked((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(id)) next.delete(id);
|
||||
else next.add(id);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
async function linkMany() {
|
||||
const chosen = items.filter((item) => picked.has(item.id));
|
||||
if (!chosen.length) return;
|
||||
setError("");
|
||||
setPending(true);
|
||||
const inserted = [];
|
||||
try {
|
||||
await api("/api/v1/external-refs", {
|
||||
method: "POST",
|
||||
body: {
|
||||
title: item.title,
|
||||
source: "paperless",
|
||||
external_id: item.id,
|
||||
context,
|
||||
...(placement ? { placement } : {}),
|
||||
...(chapterId ? { chapter_id: chapterId } : {}),
|
||||
...(item.document_on || item.correspondent || item.open_url
|
||||
? {
|
||||
dates: { document_on: item.document_on || null, sent_on: null, received_on: null },
|
||||
detail: {
|
||||
...(item.correspondent ? { correspondent: item.correspondent } : {}),
|
||||
...(item.open_url ? { open_url: item.open_url } : {}),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
onDone();
|
||||
for (const item of chosen) {
|
||||
await api("/api/v1/external-refs", {
|
||||
method: "POST",
|
||||
body: {
|
||||
title: item.title,
|
||||
source: "paperless",
|
||||
external_id: String(item.id),
|
||||
context,
|
||||
...(placement ? { placement } : {}),
|
||||
...(chapterId ? { chapter_id: chapterId } : {}),
|
||||
...(item.document_on || item.correspondent || item.open_url
|
||||
? {
|
||||
dates: { document_on: item.document_on || null, sent_on: null, received_on: null },
|
||||
detail: {
|
||||
...(item.correspondent ? { correspondent: item.correspondent } : {}),
|
||||
...(item.open_url ? { open_url: item.open_url } : {}),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
inserted.push(item.id);
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
if (inserted.length) {
|
||||
setItems((current) => current.filter((item) => !inserted.includes(item.id)));
|
||||
setPicked((current) => {
|
||||
const next = new Set(current);
|
||||
inserted.forEach((id) => next.delete(id));
|
||||
return next;
|
||||
});
|
||||
onInserted?.();
|
||||
}
|
||||
if (inserted.length === chosen.length) onDone();
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -188,10 +218,18 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
<button type="submit">Suchen</button>
|
||||
</form>
|
||||
<ErrorNote error={error} />
|
||||
<p className="muted">Die Verbindung richtest du unter <Link to="/sources">Quellen</Link> ein.</p>
|
||||
<p className="muted">Die Verbindung richtest du unter <Link to="/sources">Quellen</Link> ein. Mehrere Treffer lassen sich zusammen einfügen.</p>
|
||||
{items.length ? (
|
||||
<button type="button" disabled={pending || picked.size === 0} onClick={linkMany}>
|
||||
{picked.size ? `${picked.size} Belege einfügen` : "Belege auswählen"}
|
||||
</button>
|
||||
) : null}
|
||||
<div className="stack">
|
||||
{items.map((item) => (
|
||||
<button key={item.id} type="button" className="quiet" onClick={() => link(item)}>{item.title}</button>
|
||||
<label key={item.id} className="paperless-pick">
|
||||
<input type="checkbox" checked={picked.has(item.id)} disabled={pending} onChange={() => toggle(item.id)} />
|
||||
<span>{formatDate(item.document_on) !== "Ohne Datum" ? `${formatDate(item.document_on)} · ` : ""}{item.title}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { api, fetchFile, fetchPaperless } from "../api.js";
|
||||
import { contentSourceSymbol, contentSymbol, symbolUrl } from "../content-symbol.mjs";
|
||||
import { bezugCount, counterpartLabel, directionSymbol } from "../list-meta.mjs";
|
||||
import { MarkdownView } from "../markdown.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
import { Modal } from "./Modal.jsx";
|
||||
import { ErrorNote } from "./widgets.jsx";
|
||||
import {
|
||||
@@ -22,6 +23,56 @@ export function formatDate(value) {
|
||||
return `${day}.${month}.${year}`;
|
||||
}
|
||||
|
||||
function completeDate(value) {
|
||||
return /^\d{4}-\d{2}-\d{2}$/.test(value || "");
|
||||
}
|
||||
|
||||
export function DateField({ value = "", onChange, disabled = false, ...rest }) {
|
||||
const ref = useRef(null);
|
||||
const committed = useRef(value || "");
|
||||
// Chromium setzt bei einem gesteuerten Datumsfeld nach jeder Ziffer `value`
|
||||
// neu. Die Jahresstelle springt dann auf eine einstellige Zahl wie 0002
|
||||
// und der Fokus verlässt das Feld. Das Feld bleibt deshalb ungesteuert.
|
||||
useEffect(() => {
|
||||
const next = value || "";
|
||||
const node = ref.current;
|
||||
if (node && document.activeElement === node) return;
|
||||
committed.current = next;
|
||||
if (node && node.value !== next) node.value = next;
|
||||
}, [value]);
|
||||
|
||||
function commit(next) {
|
||||
if (next === committed.current) return;
|
||||
committed.current = next;
|
||||
onChange(next);
|
||||
}
|
||||
|
||||
function commitFrom(node) {
|
||||
if (node.validity?.badInput) {
|
||||
node.value = committed.current || "";
|
||||
return;
|
||||
}
|
||||
const next = node.value || "";
|
||||
if (next && !completeDate(next)) return;
|
||||
commit(next);
|
||||
}
|
||||
|
||||
return (
|
||||
<input
|
||||
{...rest}
|
||||
ref={ref}
|
||||
type="date"
|
||||
defaultValue={value || ""}
|
||||
disabled={disabled}
|
||||
autoComplete="off"
|
||||
onChange={(event) => {
|
||||
if (completeDate(event.target.value)) commit(event.target.value);
|
||||
}}
|
||||
onBlur={(event) => commitFrom(event.target)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function formatStamp(value) {
|
||||
if (!value) return "";
|
||||
const [day, time = ""] = String(value).split("T");
|
||||
@@ -351,12 +402,15 @@ function MenuPopover({ open, anchorRef, onClose, label, children, sheet = false
|
||||
}
|
||||
function onScroll(event) {
|
||||
if (panelRef.current?.contains(event.target)) return;
|
||||
const active = document.activeElement;
|
||||
if (active && panelRef.current?.contains(active) && /^(INPUT|TEXTAREA|SELECT)$/.test(active.tagName)) return;
|
||||
position();
|
||||
}
|
||||
window.addEventListener("keydown", onKey);
|
||||
window.addEventListener("resize", position);
|
||||
window.addEventListener("scroll", onScroll, true);
|
||||
const frame = requestAnimationFrame(() => {
|
||||
if (panelRef.current?.contains(document.activeElement)) return;
|
||||
const selected = panelRef.current?.querySelector("[aria-selected='true']")
|
||||
|| panelRef.current?.querySelector("button, a, input, select");
|
||||
selected?.focus();
|
||||
@@ -496,17 +550,22 @@ function BezugTarget({ item, source, onOpen, itemHref, onDone }) {
|
||||
return <p>{caption}</p>;
|
||||
}
|
||||
|
||||
function BezugMenu({ element, source, onOpen, itemHref }) {
|
||||
function BezugMenu({ element, source, onOpen, itemHref, canEdit = false, onClearBezug }) {
|
||||
const refers = element.refers_to || [];
|
||||
const replies = element.referred_by || [];
|
||||
const count = bezugCount(element);
|
||||
const anchorRef = useRef(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
const canClear = Boolean(canEdit && onClearBezug);
|
||||
if (!count) return null;
|
||||
function close() {
|
||||
setOpen(false);
|
||||
anchorRef.current?.focus();
|
||||
}
|
||||
function dissolve(sourceId, targetId) {
|
||||
close();
|
||||
onClearBezug(sourceId, targetId);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
@@ -529,11 +588,17 @@ function BezugMenu({ element, source, onOpen, itemHref }) {
|
||||
<MenuPopover open={open} anchorRef={anchorRef} onClose={close} label={`Bezüge ${count}`} sheet>
|
||||
{refers.length ? <p className="menu-popover__label">Bezug auf</p> : null}
|
||||
{refers.map((item) => (
|
||||
<BezugTarget key={`to-${item.id}`} item={item} source={source} onOpen={onOpen} itemHref={itemHref} onDone={close} />
|
||||
<div key={`to-${item.id}`} className="bezug-entry">
|
||||
<BezugTarget item={item} source={source} onOpen={onOpen} itemHref={itemHref} onDone={close} />
|
||||
{canClear ? <button type="button" onClick={() => dissolve(element.id, item.id)}>Bezug lösen</button> : null}
|
||||
</div>
|
||||
))}
|
||||
{replies.length ? <p className="menu-popover__label">Darauf bezogen</p> : null}
|
||||
{replies.map((item) => (
|
||||
<BezugTarget key={`by-${item.id}`} item={item} source={source} onOpen={onOpen} itemHref={itemHref} onDone={close} />
|
||||
<div key={`by-${item.id}`} className="bezug-entry">
|
||||
<BezugTarget item={item} source={source} onOpen={onOpen} itemHref={itemHref} onDone={close} />
|
||||
{canClear ? <button type="button" onClick={() => dissolve(item.id, element.id)}>Bezug lösen</button> : null}
|
||||
</div>
|
||||
))}
|
||||
</MenuPopover>
|
||||
</>
|
||||
@@ -560,6 +625,7 @@ function ChapterHeading({
|
||||
onDate,
|
||||
onMove,
|
||||
onAddSubchapter,
|
||||
onAddContent,
|
||||
onChange,
|
||||
onError,
|
||||
onPending,
|
||||
@@ -574,10 +640,23 @@ function ChapterHeading({
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<h3 className="chapter-title">
|
||||
{real ? <span className="chapter-kind">{section.parentId ? "Unterkapitel" : "Kapitel"}</span> : null}
|
||||
{section.title}
|
||||
<h3 className={`chapter-title${section.parentId ? " is-nested" : ""}`}>
|
||||
{real ? <NavIcon name="chapter" /> : null}
|
||||
<span>{section.title}</span>
|
||||
</h3>
|
||||
{canEdit && onAddContent ? (
|
||||
<button
|
||||
type="button"
|
||||
className="chapter-plus"
|
||||
aria-label={`Inhalt in ${section.title} hinzufügen`}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
onAddContent(section.id);
|
||||
}}
|
||||
>
|
||||
<NavIcon name="plus" />
|
||||
</button>
|
||||
) : null}
|
||||
<span className="count">{count}</span>
|
||||
{section.documentOn ? <span className="chapter-date">{formatDate(section.documentOn)}</span> : null}
|
||||
{showMenu ? (
|
||||
@@ -603,7 +682,7 @@ function ChapterHeading({
|
||||
{canDate ? (
|
||||
<label>
|
||||
Kapiteldatum
|
||||
<input type="date" aria-label={`Kapiteldatum für ${section.title}`} value={section.documentOn || ""} disabled={pending} onChange={(event) => onDate(event.target.value)} />
|
||||
<DateField aria-label={`Kapiteldatum für ${section.title}`} value={section.documentOn || ""} onChange={onDate} />
|
||||
</label>
|
||||
) : null}
|
||||
{movable ? <button type="button" disabled={pending || siblingIndex <= 0} onClick={() => { close(); onMove(-1); }}>Nach oben</button> : null}
|
||||
@@ -659,6 +738,7 @@ function EntryActions({
|
||||
pending,
|
||||
onSetBezug,
|
||||
onClearBezug,
|
||||
onRenameTitle,
|
||||
onRemove,
|
||||
onMove,
|
||||
onPlaceChapter,
|
||||
@@ -692,6 +772,7 @@ function EntryActions({
|
||||
<MenuPopover open={open} anchorRef={anchorRef} onClose={close} label={`Aktionen für ${element.title}`} sheet>
|
||||
{canEdit ? (
|
||||
<>
|
||||
<button type="button" onClick={() => { close(); onRenameTitle(element); }}>Titel ändern</button>
|
||||
<p className="menu-popover__label">Bezug</p>
|
||||
<label>
|
||||
Bezug auf
|
||||
@@ -705,10 +786,16 @@ function EntryActions({
|
||||
</select>
|
||||
</label>
|
||||
{(element.refers_to || []).map((item) => (
|
||||
<button key={item.id} type="button" onClick={() => { close(); onClearBezug(element.id, item.id); }}>
|
||||
<button key={`to-${item.id}`} type="button" onClick={() => { close(); onClearBezug(element.id, item.id); }}>
|
||||
Bezug auf {item.title} lösen
|
||||
</button>
|
||||
))}
|
||||
{(element.referred_by || []).length ? <p className="menu-popover__label">Darauf bezogen</p> : null}
|
||||
{(element.referred_by || []).map((item) => (
|
||||
<button key={`by-${item.id}`} type="button" onClick={() => { close(); onClearBezug(item.id, element.id); }}>
|
||||
Bezug von {item.title} lösen
|
||||
</button>
|
||||
))}
|
||||
</>
|
||||
) : null}
|
||||
{canSort && chapters.length ? (
|
||||
@@ -811,6 +898,7 @@ export function ContentBoard({
|
||||
selectedId = "",
|
||||
onOpen,
|
||||
onAddSubchapter,
|
||||
onAddContent,
|
||||
listTitle = "",
|
||||
}) {
|
||||
const source = bindings || record?.bindings || [];
|
||||
@@ -883,6 +971,24 @@ export function ContentBoard({
|
||||
}
|
||||
}
|
||||
|
||||
async function renameElement(element) {
|
||||
const title = window.prompt("Titel", element.title);
|
||||
if (!title || title.trim() === element.title) return;
|
||||
setPending(true);
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/elements/${element.id}/title`, {
|
||||
method: "PATCH",
|
||||
body: { expected_version: element.version, title: title.trim(), context: actionContext() },
|
||||
});
|
||||
await onChange();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function clearBezug(elementId, refersToId) {
|
||||
setPending(true);
|
||||
setError("");
|
||||
@@ -1429,6 +1535,7 @@ export function ContentBoard({
|
||||
onDate={(value) => saveChapterDate(section.id, value)}
|
||||
onMove={(delta) => moveChapter(section.id, delta)}
|
||||
onAddSubchapter={onAddSubchapter}
|
||||
onAddContent={section.id === "loose" ? null : onAddContent}
|
||||
onChange={onChange}
|
||||
onError={setError}
|
||||
onPending={setPending}
|
||||
@@ -1535,7 +1642,7 @@ export function ContentBoard({
|
||||
</span>
|
||||
) : null}
|
||||
<span className="preview-row__facts">{facts}</span>
|
||||
<BezugMenu element={element} source={source} onOpen={onOpen} itemHref={itemHref} />
|
||||
<BezugMenu element={element} source={source} onOpen={onOpen} itemHref={itemHref} canEdit={canEdit} onClearBezug={clearBezug} />
|
||||
</div>
|
||||
{text ? (
|
||||
<Link className="preview-row__text" to={href} onClick={openFromList}>{text}</Link>
|
||||
@@ -1556,6 +1663,7 @@ export function ContentBoard({
|
||||
pending={pending}
|
||||
onSetBezug={setBezug}
|
||||
onClearBezug={clearBezug}
|
||||
onRenameTitle={renameElement}
|
||||
onRemove={removeBinding}
|
||||
onMove={move}
|
||||
onPlaceChapter={placeChapter}
|
||||
|
||||
@@ -72,7 +72,7 @@ function TreeRow({ node, onNavigate, ancestor = false, toggle = null }) {
|
||||
const label = (
|
||||
<span className="nav-tree__title">
|
||||
{node.title}
|
||||
{node.kind === "Kapitel" || node.kind === "Unterkapitel" || node.kind === "Teilvorgang" ? (
|
||||
{node.kind === "Teilvorgang" ? (
|
||||
<span className="nav-tree__kind">{node.kind}</span>
|
||||
) : null}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user