diff --git a/backend/app/api/routes.py b/backend/app/api/routes.py index 18a8b1c..9df0e11 100644 --- a/backend/app/api/routes.py +++ b/backend/app/api/routes.py @@ -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, diff --git a/backend/app/api/schemas.py b/backend/app/api/schemas.py index d7e678a..0d0022e 100644 --- a/backend/app/api/schemas.py +++ b/backend/app/api/schemas.py @@ -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 diff --git a/backend/app/ops.py b/backend/app/ops.py index 1332601..dc109fe 100644 --- a/backend/app/ops.py +++ b/backend/app/ops.py @@ -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() diff --git a/backend/app/present.py b/backend/app/present.py index 9fba596..5b93321 100644 --- a/backend/app/present.py +++ b/backend/app/present.py @@ -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", diff --git a/backend/tests/test_element_title.py b/backend/tests/test_element_title.py new file mode 100644 index 0000000..2b29110 --- /dev/null +++ b/backend/tests/test_element_title.py @@ -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, + ) diff --git a/frontend/src/pages/Cases.jsx b/frontend/src/pages/Cases.jsx index 0f65b16..ef7e20b 100644 --- a/frontend/src/pages/Cases.jsx +++ b/frontend/src/pages/Cases.jsx @@ -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() {
{width < 1500 ? : null} {canEdit ? ( - ) : 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() {
) : null} {canEdit && view === "contents" && !overview ? ( - ) : null} @@ -614,10 +621,10 @@ export function CaseDetail() { setModal("")}>

Dieser Inhalt liegt direkt in der Akte. Er erscheint unter „Direkt in dieser Akte“ und im Überblick, nicht in einem Vorgang.

- +
- - {activeChapter ? : null} + + {addChapterId ? : null} @@ -625,16 +632,16 @@ export function CaseDetail() {
setModal("")}> - { setModal(""); load(); }} /> + { setModal(""); load(); }} /> setModal("")}> - { setModal(""); load(); }} /> + { setModal(""); load(); }} /> setModal("")}> - { setModal(""); load(); }} /> + { setModal(""); load(); }} /> setModal("")}> - { setModal(""); load(); }} /> + { setModal(""); load(); }} /> setModal("")}> { setModal(""); load(); }} /> @@ -846,7 +853,7 @@ export function ChapterForm({ path, onChange, targetLabel = "", parentChapter = {parentChapter ? <>Elternkapitel: {parentChapter.title} : <>Ebene: oberste Kapitel}

- + @@ -937,9 +944,9 @@ export function NoteForm({ context, placement, chapters = [], initialChapter = " { setText(value); markDirty(true); }} rows={8} /> { setDirection(value); markDirty(true); }} /> - - - + + + {chapterSelect(chapters, chapterId, setChapterId)} @@ -994,9 +1001,9 @@ export function FileForm({ context, placement, chapters = [], initialChapter = "

Datei

setTitle(event.target.value)} placeholder="Titel des Schreibens" required /> setFile(event.target.files?.[0] || null)} required /> - - - + + + {chapterSelect(chapters, chapterId, setChapterId)} @@ -1055,9 +1062,9 @@ function ExternalForm({ context, placement, chapters = [], initialChapter = "", setExternalId(event.target.value)} placeholder="Externe ID" required /> - - - + + + {chapterSelect(chapters, chapterId, setChapterId)} diff --git a/frontend/src/pages/Matters.jsx b/frontend/src/pages/Matters.jsx index 2ae4973..10bf639 100644 --- a/frontend/src/pages/Matters.jsx +++ b/frontend/src/pages/Matters.jsx @@ -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} > +
@@ -480,7 +488,7 @@ export function MatterDetail() {
{width < 1500 ? : null} {canEdit ? ( - ) : null} @@ -499,6 +507,7 @@ export function MatterDetail() { {!canEdit ?

In {targetLabel} fehlt das Bearbeitungsrecht.

: null} +
{view === "contents" ? ( { rememberScroll(listRef.current, scrollKey); openEntry(binding); @@ -544,7 +554,7 @@ export function MatterDetail() {
) : null} {canEdit && view === "contents" ? ( - ) : null} @@ -556,10 +566,10 @@ export function MatterDetail() { { setModal(""); load(); }} /> setModal("")}> - +
- - {activeChapter ? : null} + + {addChapterId ? : null} @@ -567,16 +577,16 @@ export function MatterDetail() {
setModal("")}> - { setModal(""); load(); }} /> + { setModal(""); load(); }} /> setModal("")}> - { setModal(""); load(); }} /> + { setModal(""); load(); }} /> setModal("")}> - { setModal(""); load(); }} /> + { setModal(""); load(); }} /> setModal("")}> - { setModal(""); load(); }} /> + { setModal(""); load(); }} /> setModal("")}> { setModal(""); load(); }} /> @@ -756,13 +766,13 @@ function WorkForms({ matterId, context, deadlines, onChange }) {

Frist

setDeadlineTitle(event.target.value)} placeholder="Maßgeblicher Termin" required /> - +

Aufgabe

setTaskTitle(event.target.value)} placeholder="Was ist vor der Frist zu tun?" required /> - +
diff --git a/frontend/src/pages/Shell.jsx b/frontend/src/pages/Shell.jsx index cb6b3fb..94fec86 100644 --- a/frontend/src/pages/Shell.jsx +++ b/frontend/src/pages/Shell.jsx @@ -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() {
- {more ? ( -
{ if (event.target === event.currentTarget) setMore(false); }}> -
-
-

Mehr

- -
-
- setMore(false)}>Verwaltung - setMore(false)}>Suche - -
-
-
- ) : null} ); diff --git a/frontend/src/pages/Sources.jsx b/frontend/src/pages/Sources.jsx index 7676299..91b86a0 100644 --- a/frontend/src/pages/Sources.jsx +++ b/frontend/src/pages/Sources.jsx @@ -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 -

Die Verbindung richtest du unter Quellen ein.

+

Die Verbindung richtest du unter Quellen ein. Mehrere Treffer lassen sich zusammen einfügen.

+ {items.length || picked.size ? ( + + ) : null}
+ {[...picked.values()].filter((item) => !items.some((entry) => String(entry.id) === String(item.id))).map((item) => ( + + ))} {items.map((item) => ( - + ))}
diff --git a/frontend/src/pages/content.jsx b/frontend/src/pages/content.jsx index 9bfcb39..7fb4096 100644 --- a/frontend/src/pages/content.jsx +++ b/frontend/src/pages/content.jsx @@ -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 ( + { + 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

{caption}

; } -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 ( <> : null} + ))} {replies.length ?

Darauf bezogen

: null} {replies.map((item) => ( - +
+ + {canClear ? : null} +
))} @@ -560,6 +625,7 @@ function ChapterHeading({ onDate, onMove, onAddSubchapter, + onAddContent, onChange, onError, onPending, @@ -574,10 +640,37 @@ function ChapterHeading({ } return ( <> -

- {real ? {section.parentId ? "Unterkapitel" : "Kapitel"} : null} - {section.title} + {real ? ( + + ) : null} +

+ {real ? : null} + {section.title}

+ {canEdit && onAddContent ? ( + + ) : null} {count} {section.documentOn ? {formatDate(section.documentOn)} : null} {showMenu ? ( @@ -603,7 +696,7 @@ function ChapterHeading({ {canDate ? ( ) : null} {movable ? : null} @@ -659,6 +752,7 @@ function EntryActions({ pending, onSetBezug, onClearBezug, + onRenameTitle, onRemove, onMove, onPlaceChapter, @@ -692,6 +786,7 @@ function EntryActions({ {canEdit ? ( <> +

Bezug

{(element.refers_to || []).map((item) => ( - ))} + {(element.referred_by || []).length ?

Darauf bezogen

: null} + {(element.referred_by || []).map((item) => ( + + ))} ) : 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({ ) : null} {facts} - + {text ? ( {text} @@ -1556,6 +1677,7 @@ export function ContentBoard({ pending={pending} onSetBezug={setBezug} onClearBezug={clearBezug} + onRenameTitle={renameElement} onRemove={removeBinding} onMove={move} onPlaceChapter={placeChapter} diff --git a/frontend/src/pages/workspace.jsx b/frontend/src/pages/workspace.jsx index 4a7ae0f..d2f946b 100644 --- a/frontend/src/pages/workspace.jsx +++ b/frontend/src/pages/workspace.jsx @@ -72,7 +72,7 @@ function TreeRow({ node, onNavigate, ancestor = false, toggle = null }) { const label = ( {node.title} - {node.kind === "Kapitel" || node.kind === "Unterkapitel" || node.kind === "Teilvorgang" ? ( + {node.kind === "Teilvorgang" ? ( {node.kind} ) : null} @@ -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; diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 9b230eb..d4e7afc 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -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; }