Ui/UX #4
No files matched your search
@@ -78,6 +78,7 @@ from app.api.schemas import (
|
||||
TaskDependencyIn,
|
||||
TaskElementsIn,
|
||||
SummaryPatch,
|
||||
TitlePatch,
|
||||
TaskIn,
|
||||
TaskPatch,
|
||||
)
|
||||
@@ -142,6 +143,7 @@ from app.ops import (
|
||||
update_dates,
|
||||
update_note,
|
||||
update_summary,
|
||||
update_title,
|
||||
)
|
||||
from app.present import (
|
||||
LABELS,
|
||||
@@ -1593,6 +1595,24 @@ def patch_element_summary(
|
||||
return {"id": str(element["id"]), "version": element["version"], "summary": element["summary"]}
|
||||
|
||||
|
||||
@router.patch("/api/v1/elements/{element_id}/title")
|
||||
def patch_element_title(
|
||||
element_id: UUID,
|
||||
body: TitlePatch,
|
||||
principal: Principal = Depends(get_principal),
|
||||
conn: Connection = Depends(get_conn),
|
||||
):
|
||||
element = update_title(
|
||||
conn,
|
||||
principal.account_id,
|
||||
element_id,
|
||||
body.expected_version,
|
||||
body.title,
|
||||
_ctx_model(body.context),
|
||||
)
|
||||
return {"id": str(element["id"]), "version": element["version"], "title": element["title"]}
|
||||
|
||||
|
||||
@router.patch("/api/v1/bindings/{binding_id}/chapter")
|
||||
def patch_binding_chapter(
|
||||
binding_id: UUID,
|
||||
|
||||
@@ -220,6 +220,12 @@ class SummaryPatch(APIModel):
|
||||
context: ContextIn | None = None
|
||||
|
||||
|
||||
class TitlePatch(APIModel):
|
||||
expected_version: int = Field(ge=1)
|
||||
title: str = Field(min_length=1, max_length=200)
|
||||
context: ContextIn | None = None
|
||||
|
||||
|
||||
class ChapterMoveIn(APIModel):
|
||||
expected_version: int = Field(ge=1)
|
||||
chapter_id: UUID | None = None
|
||||
|
||||
@@ -1497,6 +1497,19 @@ def update_summary(conn, actor: UUID, element_id: UUID, expected: int, summary:
|
||||
return get_element(conn, element_id)
|
||||
|
||||
|
||||
def update_title(conn, actor: UUID, element_id: UUID, expected: int, title: str, context: Ctx | None) -> dict:
|
||||
element, rights = require_element(conn, actor, element_id, context, "edit")
|
||||
if not rights.edit:
|
||||
raise forbidden()
|
||||
cleaned = title.strip()
|
||||
if not cleaned or len(cleaned) > 200:
|
||||
raise unprocessable("Der Titel fehlt oder ist zu lang.")
|
||||
bump_version(conn, "elements", element_id, expected)
|
||||
conn.execute("UPDATE elements SET title = %s WHERE id = %s", (cleaned, element_id))
|
||||
audit(conn, actor, element["home_scope_id"], "title_changed", "element", element_id, context)
|
||||
return get_element(conn, element_id)
|
||||
|
||||
|
||||
def move_binding_chapter(conn, actor: UUID, binding_id: UUID, expected: int, chapter_id: UUID | None, context: Ctx | None) -> int:
|
||||
"""Move one visible binding inside its container. No new binding and no grant."""
|
||||
binding = conn.execute("SELECT * FROM bindings WHERE id = %s", (binding_id,)).fetchone()
|
||||
|
||||
@@ -954,6 +954,7 @@ LABELS = {
|
||||
"correspondence_recorded": "Erfassung",
|
||||
"chapter_created": "Kapitel angelegt",
|
||||
"summary_changed": "Kurzbeschreibung geändert",
|
||||
"title_changed": "Titel geändert",
|
||||
"binding_chapter": "In ein Kapitel eingeordnet",
|
||||
"chapters_reordered": "Kapitelreihenfolge geändert",
|
||||
"chapter_dated": "Kapiteldatum geändert",
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
"""An entry title can be renamed without touching the document body."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from tests.support import Actor, document, register
|
||||
|
||||
|
||||
def test_element_title_can_be_renamed(client, db):
|
||||
ada = Actor(client, "ada-titel@example.test", "Ada Titel")
|
||||
register(db, ada.email, ada.name)
|
||||
ada.login()
|
||||
matter = ada.request("POST", "/api/v1/matters", json={"title": "Vorgang"}, status=201)
|
||||
ada.request(
|
||||
"POST",
|
||||
"/api/v1/notes",
|
||||
json={
|
||||
"title": "Alter Titel",
|
||||
"document": document("Text"),
|
||||
"context": {"kind": "matter", "id": matter["id"]},
|
||||
},
|
||||
status=201,
|
||||
)
|
||||
detail = ada.request("GET", f"/api/v1/matters/{matter['id']}")
|
||||
element = detail["bindings"][0]["element"]
|
||||
renamed = ada.request(
|
||||
"PATCH",
|
||||
f"/api/v1/elements/{element['id']}/title",
|
||||
json={
|
||||
"expected_version": element["version"],
|
||||
"title": "Neuer Titel",
|
||||
"context": {"kind": "matter", "id": matter["id"]},
|
||||
},
|
||||
)
|
||||
assert renamed["title"] == "Neuer Titel"
|
||||
assert renamed["version"] == element["version"] + 1
|
||||
shown = ada.request("GET", f"/api/v1/matters/{matter['id']}")
|
||||
assert shown["bindings"][0]["element"]["title"] == "Neuer Titel"
|
||||
ada.request(
|
||||
"PATCH",
|
||||
f"/api/v1/elements/{element['id']}/title",
|
||||
json={
|
||||
"expected_version": renamed["version"],
|
||||
"title": " ",
|
||||
"context": {"kind": "matter", "id": matter["id"]},
|
||||
},
|
||||
status=422,
|
||||
)
|
||||
@@ -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);
|
||||
@@ -439,6 +445,7 @@ export function MatterDetail() {
|
||||
nodes={nodes}
|
||||
chapters={chapters}
|
||||
chapterId={chapterId}
|
||||
allLabel=""
|
||||
allCount={(record.bindings || []).length}
|
||||
chapterHeading={`Kapitel in ${record.title}`}
|
||||
onChapter={chooseChapter}
|
||||
@@ -468,6 +475,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 +488,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 +507,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 +518,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 +554,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 +566,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 +577,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 +766,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,9 +135,16 @@ function MailForm({ onSaved, onError }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function PaperlessPicker({ context, placement, chapterId = "", chapterTitle = "", targetLabel = "", onDone }) {
|
||||
function paperlessLabel(item) {
|
||||
const dated = formatDate(item.document_on);
|
||||
return dated !== "Ohne Datum" ? `${dated} · ${item.title}` : item.title;
|
||||
}
|
||||
|
||||
export function PaperlessPicker({ context, placement, chapterId = "", chapterTitle = "", targetLabel = "", onDone, onInserted }) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [items, setItems] = useState([]);
|
||||
const [picked, setPicked] = useState(() => new Map());
|
||||
const [pending, setPending] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function search(event) {
|
||||
@@ -151,33 +158,61 @@ export function PaperlessPicker({ context, placement, chapterId = "", chapterTit
|
||||
}
|
||||
}
|
||||
|
||||
async function link(item) {
|
||||
function toggle(item) {
|
||||
const key = String(item.id);
|
||||
setPicked((current) => {
|
||||
const next = new Map(current);
|
||||
if (next.has(key)) next.delete(key);
|
||||
else next.set(key, item);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
async function linkMany() {
|
||||
const chosen = [...picked.values()];
|
||||
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(String(item.id));
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
if (inserted.length) {
|
||||
setItems((current) => current.filter((item) => !inserted.includes(String(item.id))));
|
||||
setPicked((current) => {
|
||||
const next = new Map(current);
|
||||
inserted.forEach((id) => next.delete(id));
|
||||
return next;
|
||||
});
|
||||
onInserted?.();
|
||||
}
|
||||
if (inserted.length === chosen.length) onDone();
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -188,10 +223,24 @@ 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 || picked.size ? (
|
||||
<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">
|
||||
{[...picked.values()].filter((item) => !items.some((entry) => String(entry.id) === String(item.id))).map((item) => (
|
||||
<label key={`held-${item.id}`} className="paperless-pick">
|
||||
<input type="checkbox" checked disabled={pending} onChange={() => toggle(item)} />
|
||||
<span>{paperlessLabel(item)}</span>
|
||||
</label>
|
||||
))}
|
||||
{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(String(item.id))} disabled={pending} onChange={() => toggle(item)} />
|
||||
<span>{paperlessLabel(item)}</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,37 @@ function ChapterHeading({
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<h3 className="chapter-title">
|
||||
{real ? <span className="chapter-kind">{section.parentId ? "Unterkapitel" : "Kapitel"}</span> : null}
|
||||
{section.title}
|
||||
{real ? (
|
||||
<button
|
||||
type="button"
|
||||
className="chapter-fold"
|
||||
aria-expanded={expanded}
|
||||
aria-label={expanded ? `${section.title} einklappen` : `${section.title} ausklappen`}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
onToggle();
|
||||
}}
|
||||
>
|
||||
{expanded ? "▾" : "▸"}
|
||||
</button>
|
||||
) : null}
|
||||
<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 +696,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 +752,7 @@ function EntryActions({
|
||||
pending,
|
||||
onSetBezug,
|
||||
onClearBezug,
|
||||
onRenameTitle,
|
||||
onRemove,
|
||||
onMove,
|
||||
onPlaceChapter,
|
||||
@@ -692,6 +786,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 +800,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 +912,7 @@ export function ContentBoard({
|
||||
selectedId = "",
|
||||
onOpen,
|
||||
onAddSubchapter,
|
||||
onAddContent,
|
||||
listTitle = "",
|
||||
}) {
|
||||
const source = bindings || record?.bindings || [];
|
||||
@@ -883,6 +985,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 +1549,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 +1656,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 +1677,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>
|
||||
@@ -159,13 +159,15 @@ function scopeContents({ chapters, chapterId, allLabel, overview, onChapter, can
|
||||
onSelect: overview.onSelect,
|
||||
});
|
||||
}
|
||||
items.push({
|
||||
id: "all-contents",
|
||||
title: allLabel,
|
||||
kind: "Inhalte",
|
||||
current: !chapterId && !overview?.active,
|
||||
onSelect: () => onChapter?.(""),
|
||||
});
|
||||
if (allLabel) {
|
||||
items.push({
|
||||
id: "all-contents",
|
||||
title: allLabel,
|
||||
kind: "Inhalte",
|
||||
current: !chapterId && !overview?.active,
|
||||
onSelect: () => onChapter?.(""),
|
||||
});
|
||||
}
|
||||
const byParent = new Map();
|
||||
chapters.forEach((chapter) => {
|
||||
const key = chapter.parent_chapter_id || "";
|
||||
@@ -192,16 +194,23 @@ function scopeContents({ chapters, chapterId, allLabel, overview, onChapter, can
|
||||
return items;
|
||||
}
|
||||
|
||||
function attachScope(nodes, extras) {
|
||||
function attachScope(nodes, extras, onContainerSelect) {
|
||||
return (nodes || []).map((node) => {
|
||||
const children = attachScope(node.children, extras);
|
||||
const children = attachScope(node.children, extras, onContainerSelect);
|
||||
if (!node.current) return { ...node, children };
|
||||
return { ...node, children: [...extras, ...children] };
|
||||
const nested = [...extras, ...children];
|
||||
const childCurrent = Boolean(onContainerSelect) && nested.some(branchHasCurrent);
|
||||
return {
|
||||
...node,
|
||||
current: onContainerSelect ? !childCurrent : node.current,
|
||||
...(onContainerSelect ? { onSelect: onContainerSelect } : {}),
|
||||
children: nested,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function treeWithScope(nodes, extras) {
|
||||
const attached = attachScope(nodes, extras);
|
||||
function treeWithScope(nodes, extras, onContainerSelect) {
|
||||
const attached = attachScope(nodes, extras, onContainerSelect);
|
||||
if (attached.some(branchHasCurrent)) return attached;
|
||||
return [...extras, ...attached];
|
||||
}
|
||||
@@ -224,7 +233,8 @@ export function StructureNavigator({
|
||||
}) {
|
||||
const [opened, setOpened] = useState(() => new Set());
|
||||
const [closed, setClosed] = useState(() => new Set());
|
||||
const tree = treeWithScope(nodes, scopeContents({ chapters, chapterId, allLabel, overview, onChapter, canReorder, onMoveChapter }));
|
||||
const extras = scopeContents({ chapters, chapterId, allLabel, overview, onChapter, canReorder, onMoveChapter });
|
||||
const tree = treeWithScope(nodes, extras, allLabel ? null : () => onChapter?.(""));
|
||||
|
||||
function isOpen(node, unfold) {
|
||||
if (!node.children?.length) return false;
|
||||
|
||||
+107
-12
@@ -98,6 +98,7 @@ input, select, textarea {
|
||||
border: 1.5px solid var(--border2);
|
||||
border-radius: 8px;
|
||||
}
|
||||
input[type="date"] { user-select: text; touch-action: manipulation; }
|
||||
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
|
||||
textarea { min-height: 7rem; resize: vertical; }
|
||||
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--text1); }
|
||||
@@ -230,14 +231,21 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: flex-start;
|
||||
overflow-x: auto;
|
||||
overscroll-behavior-x: contain;
|
||||
scrollbar-width: none;
|
||||
background: var(--surface);
|
||||
border-top: 1px solid var(--border);
|
||||
z-index: 20;
|
||||
padding: var(--nav-pad-top) 6px env(safe-area-inset-bottom, 0px);
|
||||
min-height: calc(var(--nav-h) + var(--nav-pad-top) + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
.bottom-nav::-webkit-scrollbar { display: none; }
|
||||
.nav-item {
|
||||
flex: 1;
|
||||
flex: 1 0 auto;
|
||||
min-width: 4.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
@@ -250,6 +258,17 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
line-height: 1.15;
|
||||
padding: 2px 4px 4px;
|
||||
}
|
||||
button.nav-item {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
min-height: 0;
|
||||
color: var(--text3);
|
||||
font-weight: 500;
|
||||
font-size: 10px;
|
||||
}
|
||||
button.nav-item:active { transform: none; }
|
||||
.nav-item span { white-space: nowrap; }
|
||||
.nav-item.active { color: var(--accent); }
|
||||
.nav-item svg { flex-shrink: 0; }
|
||||
|
||||
@@ -532,7 +551,54 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
||||
.chapter-head.is-movable:active { cursor: grabbing; }
|
||||
.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-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0;
|
||||
text-transform: none;
|
||||
color: var(--brand);
|
||||
font-weight: 700;
|
||||
}
|
||||
.chapter-title.is-nested { font-size: 17px; }
|
||||
.chapter-title svg { width: 18px; height: 18px; flex: 0 0 18px; }
|
||||
.chapter-title span { min-width: 0; }
|
||||
.chapter-plus {
|
||||
width: 36px;
|
||||
min-width: 36px;
|
||||
height: 36px;
|
||||
min-height: 36px;
|
||||
padding: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: none;
|
||||
background: transparent;
|
||||
color: var(--brand);
|
||||
border: 1px solid var(--border2);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.chapter-plus svg { width: 18px; height: 18px; }
|
||||
.chapter-fold {
|
||||
width: 28px;
|
||||
min-width: 28px;
|
||||
height: 28px;
|
||||
min-height: 28px;
|
||||
padding: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: none;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--brand);
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
}
|
||||
.chapter-fold:hover, .chapter-fold:focus-visible { background: var(--accent-light); }
|
||||
.chapter-menu, .record-tools, .chapter-move { display: inline-flex; gap: 0; flex: 0 0 auto; align-items: center; }
|
||||
.icon-button--compact { width: 32px; min-width: 32px; height: 32px; }
|
||||
.icon-button--compact svg { width: 16px; height: 16px; }
|
||||
@@ -751,6 +817,17 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
.menu-popover__panel button[aria-selected="true"] { background: var(--accent-light); color: var(--brand); }
|
||||
.menu-popover__panel button.danger { background: #fcebeb; color: var(--danger); }
|
||||
.menu-popover__label { margin: 6px 4px 0; color: var(--text3); font-size: 12px; font-weight: 700; }
|
||||
.bezug-entry { display: grid; gap: 2px; }
|
||||
.paperless-pick {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
min-height: 44px;
|
||||
padding: 8px 2px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.paperless-pick input { width: 20px; min-width: 20px; min-height: 20px; margin-top: 2px; }
|
||||
.paperless-pick span { min-width: 0; overflow-wrap: anywhere; }
|
||||
.trail__more {
|
||||
min-height: 28px;
|
||||
height: auto;
|
||||
@@ -1097,7 +1174,16 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.workspace-scrim { position: absolute; inset: 0; z-index: 5; border: 0; background: rgba(28, 27, 24, 0.28); }
|
||||
.workspace-main { padding: 22px 28px 32px; }
|
||||
.workspace-main { --pin-x: 28px; --pin-y: 22px; padding: var(--pin-y) var(--pin-x) 32px; }
|
||||
.workspace-pin {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 4;
|
||||
background: var(--bg);
|
||||
margin: calc(var(--pin-y) * -1) calc(var(--pin-x) * -1) 12px;
|
||||
padding: var(--pin-y) var(--pin-x) 0;
|
||||
}
|
||||
.workspace-pin .surface-tabs { margin-bottom: 0; }
|
||||
.workspace-reader { background: #eef2ee; border-left: 1px solid var(--border); display: flex; min-height: 0; }
|
||||
.workspace-head, .title-row, .page-actions, .content-toolbar, .reader-pane__bar, .reader-controls {
|
||||
display: flex;
|
||||
@@ -1188,25 +1274,34 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
}
|
||||
.chapter-link__move { display: flex; gap: 2px; flex: none; align-items: center; }
|
||||
.chapter-link__move button {
|
||||
min-height: 44px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
min-height: 28px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
font-size: 16px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
background: transparent;
|
||||
color: var(--text3);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.nav-tree__toggle {
|
||||
width: 44px;
|
||||
min-width: 44px;
|
||||
height: 44px;
|
||||
width: 22px;
|
||||
min-width: 22px;
|
||||
height: 28px;
|
||||
min-height: 28px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: var(--text2);
|
||||
font-size: 16px;
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
}
|
||||
.structure .chapter-add {
|
||||
min-height: 32px;
|
||||
padding: 4px 10px;
|
||||
margin-top: 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.nav-tree__toggle.is-empty { visibility: hidden; }
|
||||
.nav-tree__kind {
|
||||
@@ -1361,7 +1456,7 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
@media (max-width: 759px) {
|
||||
.rail { display: none; }
|
||||
.app-shell { flex-direction: column; }
|
||||
.workspace-main { padding: 8px 12px 88px; }
|
||||
.workspace-main { --pin-x: 12px; --pin-y: 8px; padding: 8px 12px 88px; }
|
||||
.structure { padding-bottom: 96px; }
|
||||
.mobile-add { display: none; }
|
||||
.page-actions { flex-wrap: wrap; }
|
||||
|
||||
Reference in new issue
Block a user