Vereine Ablage, Akte und Vorgang in einem Navigationsbaum mit Fokus und Nachladen.
Der Baum Meine Ablage steht jetzt auch auf den Seiten von Akte und Vorgang und ersetzt die Spalte Struktur. Ein Klick öffnet den Eintrag und klappt seine Struktur auf: Überblick, Kapitel und Unterkapitel, Unterakten, Vorgänge und Teilvorgänge. Der Pfad bleibt offen, die aktuelle Zeile ist hervorgehoben und nach dem Neuladen stimmt der Fokus wieder. Ein Vorgang steht unter jeder Akte, in der er liegt, und unter Vorgänge; ein Klick unter einer Akte öffnet ihn in diesem Aktenkontext. So wechselt man direkt von Vorgang zu Vorgang. Kapitel anlegen und verschieben geht im Baum. Die Struktur eines Knotens kommt aus neuen schlanken Endpunkten (cases und matters outline), die nur Lesbares liefern, und wird beim Aufklappen einmal nachgeladen. Die Zweispaltenansicht mit dem Lesebereich beginnt erst, wenn neben dem Baum genug Platz bleibt. Im Browser gegen die lokale Umgebung durchgespielt (Akte, Vorgang unter der Akte, Wechsel zwischen Vorgängen, Kapitel anlegen, Neuladen, Vorgang ohne Akte, Handy, Hell und Dunkel). Die Backend-Suite läuft mit 149 Tests grün, der Frontend-Build und 37 Node-Tests ebenfalls. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
322ad491c1
commit
5f60e1fe40
15 files changed
+688
-471
No files matched your search
@@ -8,11 +8,12 @@ from fastapi import APIRouter, Depends
|
||||
from fastapi.responses import JSONResponse
|
||||
from psycopg import Connection
|
||||
|
||||
from app.access.policy import parse_query_context, require_case, require_matter
|
||||
from app.access.roles import room_role
|
||||
from app.api.deps import Principal, get_conn, get_principal
|
||||
from app.api.schemas import BatchShareIn
|
||||
from app.core.errors import forbidden
|
||||
from app.library import case_items, matter_items, room_contents, room_effect
|
||||
from app.library import case_items, case_outline, matter_items, matter_outline, room_contents, room_effect
|
||||
from app.ops import share_with_room
|
||||
|
||||
router = APIRouter()
|
||||
@@ -97,3 +98,22 @@ def share_many(
|
||||
"access": body.access,
|
||||
"effect": room_effect(conn, room_id, principal.account_id, body.access),
|
||||
}
|
||||
|
||||
|
||||
@router.get("/api/v1/cases/{case_id}/outline")
|
||||
def case_outline_view(case_id: UUID, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
||||
case, _rights = require_case(conn, principal.account_id, case_id, "read")
|
||||
return JSONResponse(case_outline(conn, principal.account_id, case), headers=_NO_STORE)
|
||||
|
||||
|
||||
@router.get("/api/v1/matters/{matter_id}/outline")
|
||||
def matter_outline_view(
|
||||
matter_id: UUID,
|
||||
context_kind: str | None = None,
|
||||
context_id: str | None = None,
|
||||
principal: Principal = Depends(get_principal),
|
||||
conn: Connection = Depends(get_conn),
|
||||
):
|
||||
context = parse_query_context(context_kind, context_id)
|
||||
matter, _rights = require_matter(conn, principal.account_id, matter_id, context, "read")
|
||||
return JSONResponse(matter_outline(conn, principal.account_id, matter, context), headers=_NO_STORE)
|
||||
+45
-1
@@ -20,7 +20,7 @@ from app.access.policy import (
|
||||
matter_rights,
|
||||
room_name,
|
||||
)
|
||||
from app.present import case_summary, matter_summary
|
||||
from app.present import _chapters, _matter_tree, case_summary, matter_summary
|
||||
|
||||
|
||||
def shared_rooms(conn, kind: str, resource_id: UUID) -> list[dict]:
|
||||
@@ -124,3 +124,47 @@ def room_effect(conn, room_id: UUID, actor: UUID, access: str) -> list[dict]:
|
||||
}
|
||||
)
|
||||
return effect
|
||||
|
||||
|
||||
def case_outline(conn, actor: UUID, case: dict) -> dict:
|
||||
"""What the navigation tree shows below a case. Only readable entries; no bindings or texts."""
|
||||
chapters = _chapters(conn, "case", case["id"], case.get("content_order") or "position", case.get("content_order_dir") or "asc")
|
||||
subcases = []
|
||||
for row in conn.execute(
|
||||
"SELECT * FROM cases WHERE parent_case_id = %s AND deleted_at IS NULL ORDER BY title, id",
|
||||
(case["id"],),
|
||||
).fetchall():
|
||||
if case_rights(conn, actor, row).read:
|
||||
subcases.append({"id": str(row["id"]), "title": row["title"], "status": row["record_status"]})
|
||||
linked = []
|
||||
for link in conn.execute(
|
||||
"""
|
||||
SELECT m.* FROM matter_case_links l JOIN matters m ON m.id = l.matter_id
|
||||
WHERE l.case_id = %s AND m.deleted_at IS NULL ORDER BY m.title, m.id
|
||||
""",
|
||||
(case["id"],),
|
||||
).fetchall():
|
||||
if matter_rights(conn, actor, link, Ctx("case", case["id"])).read:
|
||||
linked.append(link)
|
||||
return {
|
||||
"kind": "case",
|
||||
"id": str(case["id"]),
|
||||
"chapters": chapters,
|
||||
"subcases": subcases,
|
||||
"matters": _matter_tree(conn, actor, case["id"], linked),
|
||||
}
|
||||
|
||||
|
||||
def matter_outline(conn, actor: UUID, matter: dict, context: Ctx | None) -> dict:
|
||||
"""What the navigation tree shows below a matter: its chapters and its readable Teilvorgänge."""
|
||||
chapters = _chapters(
|
||||
conn, "matter", matter["id"], matter.get("content_order") or "position", matter.get("content_order_dir") or "asc"
|
||||
)
|
||||
children = []
|
||||
for row in conn.execute(
|
||||
"SELECT * FROM matters WHERE parent_matter_id = %s AND deleted_at IS NULL ORDER BY title, id",
|
||||
(matter["id"],),
|
||||
).fetchall():
|
||||
if matter_rights(conn, actor, row, context).read:
|
||||
children.append({"id": str(row["id"]), "title": row["title"], "status": row["record_status"]})
|
||||
return {"kind": "matter", "id": str(matter["id"]), "chapters": chapters, "submatters": children}
|
||||
@@ -152,3 +152,52 @@ def _id(owner: Actor, person: Actor) -> str:
|
||||
|
||||
with psycopg.connect(get_settings().dsn(), row_factory=psycopg.rows.dict_row) as conn:
|
||||
return str(conn.execute("SELECT id FROM auth_accounts WHERE email = %s", (person.email,)).fetchone()["id"])
|
||||
|
||||
|
||||
def test_the_outline_lists_only_what_the_person_may_read(world):
|
||||
ada, ben, cem, dan, room = world["ada"], world["ben"], world["cem"], world["dan"], world["room"]
|
||||
case = ada.request("POST", "/api/v1/cases", json={"title": "Gliederung"}, status=201)
|
||||
ada.request("POST", f"/api/v1/cases/{case['id']}/chapters", json={"title": "Schriftverkehr"}, status=201)
|
||||
sub = ada.request(
|
||||
"POST", "/api/v1/cases",
|
||||
json={"title": "Unterakte", "parent_case_id": case["id"], "rights_mode": "inherit_parent"}, status=201,
|
||||
)
|
||||
open_matter = matter_of(ada, "Offener Vorgang")
|
||||
hidden_matter = matter_of(ada, "Verborgener Vorgang")
|
||||
child = ada.request("POST", "/api/v1/matters", json={"title": "Teilvorgang", "parent_matter_id": open_matter["id"]}, status=201)
|
||||
ada.request("POST", f"/api/v1/matters/{open_matter['id']}/chapters", json={"title": "Belege"}, status=201)
|
||||
_link(ada, open_matter["id"], case["id"])
|
||||
_link(ada, hidden_matter["id"], case["id"])
|
||||
_share(ada, "cases", case["id"], room)
|
||||
ada.request(
|
||||
"PUT", "/api/v1/exceptions",
|
||||
json={"resource_kind": "matter", "resource_id": hidden_matter["id"], "context": {"kind": "case", "id": case["id"]}, "remove_read": True},
|
||||
)
|
||||
|
||||
mine = ada.request("GET", f"/api/v1/cases/{case['id']}/outline")
|
||||
assert [c["title"] for c in mine["chapters"]] == ["Schriftverkehr"]
|
||||
assert [c["title"] for c in mine["subcases"]] == ["Unterakte"]
|
||||
# An exception in the case context hides the matter there for everyone, the owner included.
|
||||
assert {m["title"] for m in mine["matters"]} == {"Offener Vorgang"}
|
||||
seen = ben.request("GET", f"/api/v1/cases/{case['id']}/outline")
|
||||
assert {m["title"] for m in seen["matters"]} == {"Offener Vorgang"}
|
||||
assert [c["title"] for c in seen["matters"][0]["children"]] == ["Teilvorgang"]
|
||||
assert sub["id"] in [c["id"] for c in seen["subcases"]]
|
||||
|
||||
matter = ada.request("GET", f"/api/v1/matters/{open_matter['id']}/outline")
|
||||
assert [c["title"] for c in matter["chapters"]] == ["Belege"]
|
||||
assert [c["title"] for c in matter["submatters"]] == ["Teilvorgang"]
|
||||
in_case = ben.request(
|
||||
"GET", f"/api/v1/matters/{open_matter['id']}/outline",
|
||||
params={"context_kind": "case", "context_id": case["id"]},
|
||||
)
|
||||
assert [c["title"] for c in in_case["submatters"]] == ["Teilvorgang"]
|
||||
ben.request("GET", f"/api/v1/matters/{open_matter['id']}/outline", status=404)
|
||||
assert child["title"] == "Teilvorgang"
|
||||
|
||||
unknown = "00000000-0000-4000-8000-000000000000"
|
||||
seen_status = dan.request("GET", f"/api/v1/cases/{case['id']}/outline", status=404)
|
||||
missing = dan.request("GET", f"/api/v1/cases/{unknown}/outline", status=404)
|
||||
assert seen_status["detail"] == missing["detail"]
|
||||
dan.request("GET", f"/api/v1/matters/{open_matter['id']}/outline", status=404)
|
||||
assert cem.request("GET", f"/api/v1/cases/{case['id']}/outline")["id"] == case["id"]
|
||||
@@ -75,6 +75,7 @@ Legende Spalte „Auth“: **–** öffentlich, **S** gültige Session, **S+R**
|
||||
| GET | `/api/v1/rooms/overview` | S+R | Räume der Person als Kacheln: Rolle, Eigentümer, Zahl der Mitglieder und der lesbaren Akten und Vorgänge; Mitgliedernamen nur für Verwalter |
|
||||
| GET | `/api/v1/rooms/{id}/contents` | S+R, Mitglied | Akten und Vorgänge, die mit dem Raum geteilt und für die Person lesbar sind, mit Zählern |
|
||||
| POST | `/api/v1/rooms/{id}/shares` | S+R, Mitglied | mehrere eigene Einträge auf einmal mit dem Raum teilen (alle oder keiner); Antwort nennt die Wirkung je Mitglied |
|
||||
| GET | `/api/v1/cases/{id}/outline`, `/api/v1/matters/{id}/outline` | S+R | Struktur für den Navigationsbaum: Kapitel, Unterakten und Vorgänge bzw. Teilvorgänge, nur aus Lesbarem; für Vorgänge optional `context_kind=case&context_id=` |
|
||||
| GET | `/api/v1/team` | S+R, Hauptnutzer | Personen in den eigenen Räumen mit Rolle je Raum; `mine` = selbst eingeladen |
|
||||
| PATCH | `/api/v1/team/{id}` | S+R, Hauptnutzer | `status` eines selbst eingeladenen Mitarbeiters; fremde und unbekannte ID: 403 |
|
||||
| POST | `/api/v1/team/{id}/password-reset` | S+R, Hauptnutzer | Einmal-Passwort für einen selbst eingeladenen Mitarbeiter |
|
||||
|
||||
@@ -85,3 +85,12 @@ MFA (später optional für alle Konten), Leerlaufablauf und Rotation der Sitzung
|
||||
### Vorbereitung Subscription
|
||||
|
||||
`backend/app/access/limits.py` ist die einzige Stelle für Grenzen. `ensure_can_create_room(conn, owner_id)` läuft beim Anlegen eines Raums, `ensure_can_add_member(conn, owner_id, room_id)` beim Aufnehmen, Einladen und Annehmen einer Einladung. Heute lassen beide alles zu. Das Kontingentsubjekt ist der Eigentümer des Raums, ein Hauptnutzer, wie der Verein bei Shinkan (Entitlements-Blueprint). Vorgesehene Messgrößen: aktive Mitarbeiter je Hauptnutzer und je Raum, aus der Datenbank gezählt. Der Betreiber setzt den Plan. Zahlungsdienst und Tarife gehören nicht in diese Stufe. Offene Entscheidung: Ein Mitarbeiter, den ein zweiter Hauptnutzer als bestehendes Konto aufnimmt, zählt beim Raum-Eigentümer; die Zuständigkeit bei Grenzen klärt das Tarifkonzept.
|
||||
|
||||
### Ein Navigationsbaum für Ablage, Akten und Vorgänge (seit 23.10.2026)
|
||||
|
||||
Der Baum „Meine Ablage“ steht links auf den Listenseiten und auf den Seiten von Akte und Vorgang. Die frühere Spalte „Struktur“ ist darin aufgegangen.
|
||||
|
||||
- **Aufklappen mit Fokus:** Ein Klick auf eine Akte oder einen Vorgang öffnet ihn und klappt seine Struktur auf. Der Pfad dorthin bleibt offen, die aktuelle Zeile (auch ein Kapitel) ist hervorgehoben. Nach dem Neuladen der Seite stimmt der Fokus wieder.
|
||||
- **Unter einer Akte:** Überblick, „Direkt in dieser Akte“, Kapitel mit Unterkapiteln, Unterakten und die Vorgänge der Akte. **Unter einem Vorgang:** „Alle Inhalte“, Kapitel, Teilvorgänge. „Neues Kapitel“ und die Pfeile zum Verschieben stehen im Baum, solange der Eintrag offen ist.
|
||||
- **Direkt von Vorgang zu Vorgang:** Ein Vorgang erscheint unter jeder Akte, in der er liegt, und unter „Vorgänge“. Ein Klick unter einer Akte öffnet ihn in diesem Aktenkontext, unter „Vorgänge“ ohne Akte. Die frühere Auswahl des Handlungskontexts entfällt. Querverweise und weitere Akten stehen unter dem Titel des Vorgangs.
|
||||
- **Nachladen:** Die Wurzeln kommen aus `/cases` und `/matters`, die Struktur eines Knotens aus `GET /cases/{id}/outline` und `GET /matters/{id}/outline`, einmal beim Aufklappen. Die Antworten enthalten nur Lesbares (keine Inhalte). Ändert sich der offene Eintrag (Kapitel, Unterakte, Vorgang), lädt der Baum seine Struktur neu.
|
||||
@@ -136,9 +136,9 @@ export function App() {
|
||||
<Route path="matters" element={<EntryPage kind="matter" />} />
|
||||
<Route path="rooms" element={<RoomsPage />} />
|
||||
<Route path="rooms/:id" element={<RoomPage />} />
|
||||
<Route path="cases/:id" element={<CaseDetail />} />
|
||||
<Route path="matters/:id" element={<MatterDetail />} />
|
||||
</Route>
|
||||
<Route path="cases/:id" element={<CaseDetail />} />
|
||||
<Route path="matters/:id" element={<MatterDetail />} />
|
||||
<Route path="matters/:id/items/:bindingId" element={<Reader />} />
|
||||
<Route path="cases/:id/items/:bindingId" element={<Reader />} />
|
||||
<Route path="work" element={<Work />} />
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
||||
import { NavLink, Outlet, useLocation, useSearchParams } from "react-router-dom";
|
||||
import { Outlet, useLocation } from "react-router-dom";
|
||||
import { api } from "../api.js";
|
||||
import { SHARE_DRAG_TYPE, isEmployee, parseShareDrag, shareTargets } from "../admin/admin-core.js";
|
||||
import { isEmployee, shareTargets } from "../admin/admin-core.js";
|
||||
import { ErrorNote } from "../pages/widgets.jsx";
|
||||
import { SessionContext } from "../session.js";
|
||||
import { effectText, folderTree } from "./library-core.js";
|
||||
import { MiniIcon } from "./MiniIcon.jsx";
|
||||
import { effectText } from "./library-core.js";
|
||||
import { NavTree } from "./NavTree.jsx";
|
||||
|
||||
export const LibraryContext = createContext(null);
|
||||
|
||||
@@ -15,129 +15,33 @@ export function useLibrary() {
|
||||
|
||||
const PLURAL = { case: "cases", matter: "matters" };
|
||||
|
||||
function TreeNodes({ nodes, children, hrefFor, parentKey, current, openIds, toggle }) {
|
||||
return (
|
||||
<ul className="library-tree__list">
|
||||
{nodes.map((node) => {
|
||||
const kids = children.get(node.id) || [];
|
||||
const open = openIds.has(node.id);
|
||||
const selected = current === node.id;
|
||||
return (
|
||||
<li key={node.id}>
|
||||
<div className="library-tree__row">
|
||||
{kids.length ? (
|
||||
<button type="button" className="library-tree__toggle" aria-label={open ? "Einklappen" : "Aufklappen"} aria-expanded={open} onClick={() => toggle(node.id)}>
|
||||
{open ? "▾" : "▸"}
|
||||
</button>
|
||||
) : <span className="library-tree__toggle is-empty" />}
|
||||
<NavLink className={`library-tree__link${selected ? " is-current" : ""}`} to={hrefFor(node)} end>
|
||||
<span className="library-tree__icon"><MiniIcon kind={parentKey === "parent_case_id" ? "case" : "matter"} /></span>
|
||||
<span className="library-tree__title">{node.title}</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
{open && kids.length ? (
|
||||
<TreeNodes nodes={kids} children={children} hrefFor={hrefFor} parentKey={parentKey} current={current} openIds={openIds} toggle={toggle} />
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
const outlineKey = (kind, id, contextId = "") => `${kind}:${id}:${contextId || ""}`;
|
||||
|
||||
// A detail page tells the tree which entry is open and what can be done there.
|
||||
// `actions` are read when a row is clicked, so they may close over the latest state.
|
||||
export function useLibraryFocus(focus, actions) {
|
||||
const library = useLibrary();
|
||||
const signature = JSON.stringify(focus || null);
|
||||
useEffect(() => {
|
||||
library?.setFocus(focus || null);
|
||||
return () => library?.setFocus(null);
|
||||
}, [signature]);
|
||||
if (library) library.actionsRef.current = actions || {};
|
||||
}
|
||||
|
||||
function TreeSection({ to, label, items, parentKey, folder, active }) {
|
||||
const { roots, children } = folderTree(items || [], parentKey);
|
||||
const [openIds, setOpenIds] = useState(() => new Set());
|
||||
const byId = new Map((items || []).map((item) => [item.id, item]));
|
||||
// The path to the selected folder stays open.
|
||||
const path = new Set();
|
||||
for (let node = byId.get(folder); node; node = node[parentKey] ? byId.get(node[parentKey]) : null) path.add(node[parentKey]);
|
||||
const shown = new Set([...openIds, ...path]);
|
||||
const toggle = (id) =>
|
||||
setOpenIds((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(id)) next.delete(id);
|
||||
else next.add(id);
|
||||
return next;
|
||||
});
|
||||
return (
|
||||
<div className="library-tree__section">
|
||||
<NavLink to={to} end className={`library-tree__root${active && !folder ? " is-current" : ""}`}>
|
||||
<span className="library-tree__icon"><MiniIcon kind={parentKey === "parent_case_id" ? "case" : "matter"} /></span> {label}
|
||||
<span className="library-tree__count">{(items || []).length}</span>
|
||||
</NavLink>
|
||||
<TreeNodes
|
||||
nodes={roots}
|
||||
children={children}
|
||||
parentKey={parentKey}
|
||||
hrefFor={(node) => `${to}?ordner=${node.id}`}
|
||||
current={active ? folder : ""}
|
||||
openIds={shown}
|
||||
toggle={toggle}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LibraryTree({ cases, matters, rooms, onDropOnRoom, employee }) {
|
||||
const location = useLocation();
|
||||
const [params] = useSearchParams();
|
||||
const folder = params.get("ordner") || "";
|
||||
const [over, setOver] = useState("");
|
||||
return (
|
||||
<nav className="library-tree" aria-label="Ordner">
|
||||
{employee ? null : (
|
||||
<>
|
||||
<h2 className="library-tree__heading">Meine Ablage</h2>
|
||||
<TreeSection to="/cases" label="Akten" items={cases} parentKey="parent_case_id" folder={folder} active={location.pathname === "/cases"} />
|
||||
<TreeSection to="/matters" label="Vorgänge" items={matters} parentKey="parent_matter_id" folder={folder} active={location.pathname === "/matters"} />
|
||||
</>
|
||||
)}
|
||||
<h2 className="library-tree__heading">Räume</h2>
|
||||
<NavLink to="/rooms" end className={({ isActive }) => `library-tree__root${isActive ? " is-current" : ""}`}>
|
||||
<span className="library-tree__icon"><MiniIcon kind="room" /></span> Alle Räume
|
||||
</NavLink>
|
||||
<ul className="library-tree__list">
|
||||
{(rooms || []).map((room) => (
|
||||
<li key={room.id}>
|
||||
<NavLink
|
||||
to={`/rooms/${room.id}`}
|
||||
className={({ isActive }) => `library-tree__link library-tree__room${isActive ? " is-current" : ""}${over === room.id ? " is-over" : ""}`}
|
||||
onDragOver={(event) => {
|
||||
if (!Array.from(event.dataTransfer?.types || []).includes(SHARE_DRAG_TYPE)) return;
|
||||
event.preventDefault();
|
||||
event.dataTransfer.dropEffect = "link";
|
||||
setOver(room.id);
|
||||
}}
|
||||
onDragLeave={() => setOver((current) => (current === room.id ? "" : current))}
|
||||
onDrop={(event) => {
|
||||
event.preventDefault();
|
||||
setOver("");
|
||||
const text = event.dataTransfer.getData(SHARE_DRAG_TYPE);
|
||||
const payload = parseShareDrag(text, "case") || parseShareDrag(text, "matter");
|
||||
if (payload) onDropOnRoom(payload, room);
|
||||
}}
|
||||
>
|
||||
<span className="library-tree__icon"><MiniIcon kind="room" /></span>
|
||||
<span className="library-tree__title">{room.name}</span>
|
||||
<span className="library-tree__count">{room.case_count + room.matter_count}</span>
|
||||
</NavLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
// Frame of the library: folder tree on the left, tiles on the right, one place for data and messages.
|
||||
// Frame of the library: one navigation tree on the left, the page on the right.
|
||||
export function LibraryLayout() {
|
||||
const { session } = useContext(SessionContext);
|
||||
const employee = isEmployee(session);
|
||||
const [data, setData] = useState({ cases: null, matters: null, rooms: null });
|
||||
const [outlines, setOutlines] = useState(() => new Map());
|
||||
const [focus, setFocus] = useState(null);
|
||||
const [error, setError] = useState("");
|
||||
const [message, setMessage] = useState("");
|
||||
const [treeOpen, setTreeOpen] = useState(false);
|
||||
const timer = useRef(null);
|
||||
const actionsRef = useRef({});
|
||||
const pending = useRef(new Set());
|
||||
const location = useLocation();
|
||||
|
||||
const reload = useCallback(async () => {
|
||||
@@ -155,8 +59,34 @@ export function LibraryLayout() {
|
||||
|
||||
useEffect(() => {
|
||||
reload();
|
||||
setOutlines(new Map());
|
||||
}, [reload, session.scope.id]);
|
||||
|
||||
// Outlines come on demand and stay in memory. `force` fetches again after a change.
|
||||
const loadOutline = useCallback(async (kind, id, contextId = "", force = false) => {
|
||||
const key = outlineKey(kind, id, contextId);
|
||||
if (pending.current.has(key)) return;
|
||||
if (!force && outlines.has(key)) return;
|
||||
pending.current.add(key);
|
||||
try {
|
||||
const query = kind === "matter" && contextId ? `?context_kind=case&context_id=${contextId}` : "";
|
||||
const outline = await api(`/api/v1/${PLURAL[kind]}/${id}/outline${query}`);
|
||||
setOutlines((current) => new Map(current).set(key, outline));
|
||||
} catch {
|
||||
setOutlines((current) => new Map(current).set(key, { chapters: [], subcases: [], matters: [], submatters: [] }));
|
||||
} finally {
|
||||
pending.current.delete(key);
|
||||
}
|
||||
}, [outlines]);
|
||||
|
||||
// The open entry changed (a chapter added, a matter moved): fetch its outline and the lists again.
|
||||
const stamp = focus?.stamp || "";
|
||||
useEffect(() => {
|
||||
if (!focus) return;
|
||||
loadOutline(focus.kind, focus.id, focus.contextId || "", true);
|
||||
reload();
|
||||
}, [stamp]);
|
||||
|
||||
useEffect(() => {
|
||||
setTreeOpen(false);
|
||||
}, [location.pathname, location.search]);
|
||||
@@ -195,6 +125,11 @@ export function LibraryLayout() {
|
||||
notify,
|
||||
share,
|
||||
unshare,
|
||||
focus,
|
||||
setFocus,
|
||||
outlines,
|
||||
loadOutline,
|
||||
actionsRef,
|
||||
dropOnRoom: (payload, room) => share(payload.kind, { id: payload.id, title: payload.title }, room),
|
||||
targets: shareTargets(session.rooms),
|
||||
employee,
|
||||
@@ -207,7 +142,7 @@ export function LibraryLayout() {
|
||||
{treeOpen ? "Ordner ausblenden" : "Ordner anzeigen"}
|
||||
</button>
|
||||
<aside className={`library__tree${treeOpen ? " is-open" : ""}`}>
|
||||
<LibraryTree cases={data.cases} matters={data.matters} rooms={data.rooms} onDropOnRoom={value.dropOnRoom} employee={employee} />
|
||||
<NavTree cases={data.cases} matters={data.matters} rooms={data.rooms} employee={employee} onDropOnRoom={value.dropOnRoom} />
|
||||
</aside>
|
||||
<div className="library__main">
|
||||
<ErrorNote error={error} />
|
||||
|
||||
@@ -9,6 +9,13 @@ export function MiniIcon({ kind }) {
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
if (kind === "plus") {
|
||||
return (
|
||||
<svg {...common}>
|
||||
<path d="M12 5v14M5 12h14" fill="none" stroke="currentColor" strokeWidth="2.6" strokeLinecap="round" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
if (kind === "chapter") {
|
||||
return (
|
||||
<svg {...common}>
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link, NavLink } from "react-router-dom";
|
||||
import { SHARE_DRAG_TYPE, parseShareDrag } from "../admin/admin-core.js";
|
||||
import { useLibrary } from "./LibraryLayout.jsx";
|
||||
import { MiniIcon } from "./MiniIcon.jsx";
|
||||
import {
|
||||
caseHref,
|
||||
caseKey,
|
||||
chapterTree,
|
||||
focusKeys,
|
||||
folderTree,
|
||||
matterHref,
|
||||
matterKey,
|
||||
rowState,
|
||||
} from "./library-core.js";
|
||||
|
||||
// One row of the navigation tree. A row with `load` fetches its outline when it opens.
|
||||
function Row({ node, tree }) {
|
||||
const library = useLibrary();
|
||||
const open = tree.isOpen(node.key);
|
||||
const expandable = Boolean(node.expandable);
|
||||
|
||||
useEffect(() => {
|
||||
if (open && node.load) library.loadOutline(node.load.kind, node.load.id, node.load.contextId);
|
||||
}, [open, node.key]);
|
||||
|
||||
const className = `library-tree__link${node.current ? " is-current" : ""}${node.ancestor ? " is-ancestor" : ""}`;
|
||||
const inner = (
|
||||
<>
|
||||
<span className="library-tree__icon"><MiniIcon kind={node.icon} /></span>
|
||||
<span className="library-tree__title">{node.title}</span>
|
||||
{node.count !== undefined ? <span className="library-tree__count">{node.count}</span> : null}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<li className={node.className || ""}>
|
||||
<div className="library-tree__row">
|
||||
{expandable ? (
|
||||
<button
|
||||
type="button"
|
||||
className="library-tree__toggle"
|
||||
aria-expanded={open}
|
||||
aria-label={`${node.title} ${open ? "einklappen" : "ausklappen"}`}
|
||||
onClick={() => tree.toggle(node.key)}
|
||||
>
|
||||
{open ? "▾" : "▸"}
|
||||
</button>
|
||||
) : <span className="library-tree__toggle is-empty" aria-hidden="true" />}
|
||||
{node.href ? (
|
||||
<Link className={className} to={node.href} aria-current={node.current ? "page" : undefined} title={node.title}>{inner}</Link>
|
||||
) : (
|
||||
<button type="button" className={className} onClick={node.onClick} title={node.title}>{inner}</button>
|
||||
)}
|
||||
{node.moves ? (
|
||||
<span className="library-tree__moves">
|
||||
<button type="button" aria-label={`${node.title} nach oben`} disabled={node.moves.first} onClick={() => library.actionsRef.current.moveChapter?.(node.moves.id, -1)}>↑</button>
|
||||
<button type="button" aria-label={`${node.title} nach unten`} disabled={node.moves.last} onClick={() => library.actionsRef.current.moveChapter?.(node.moves.id, 1)}>↓</button>
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
{open && node.children ? <List nodes={node.children()} tree={tree} /> : null}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function List({ nodes, tree }) {
|
||||
if (!nodes.length) return null;
|
||||
return (
|
||||
<ul className="library-tree__list">
|
||||
{nodes.map((node) => <Row key={node.key} node={node} tree={tree} />)}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
// Builds the node descriptions from the lists, the loaded outlines and the focus of the page.
|
||||
function buildNodes({ cases, matters, library, isOpen }) {
|
||||
const { focus, outlines } = library;
|
||||
const caseTree = folderTree(cases || [], "parent_case_id");
|
||||
const matterTreeAll = folderTree(matters || [], "parent_matter_id");
|
||||
|
||||
const chapterNodes = (tree, base, owner, ownerKind, contextId) =>
|
||||
tree.map(({ chapter, first, last, children }) => {
|
||||
const state = rowState(focus, ownerKind, owner, contextId);
|
||||
const href = ownerKind === "case" ? caseHref(owner, { kapitel: chapter.id }) : matterHref(owner, contextId, { kapitel: chapter.id });
|
||||
return {
|
||||
key: `k:${chapter.id}:${contextId || ""}`,
|
||||
icon: "chapter",
|
||||
title: chapter.title,
|
||||
href,
|
||||
current: state.here && state.chapter === chapter.id,
|
||||
expandable: children.length > 0,
|
||||
moves: state.here && focus.canReorder ? { id: chapter.id, first, last } : null,
|
||||
children: () => chapterNodes(children, base, owner, ownerKind, contextId),
|
||||
};
|
||||
});
|
||||
|
||||
const addChapter = (owner, ownerKind, contextId) => {
|
||||
const state = rowState(focus, ownerKind, owner, contextId);
|
||||
if (!state.here || !focus.canEdit) return [];
|
||||
return [{
|
||||
key: `add:${owner}:${contextId || ""}`,
|
||||
icon: "plus",
|
||||
title: state.chapter ? "Neues Unterkapitel" : "Neues Kapitel",
|
||||
className: "library-tree__add",
|
||||
onClick: () => library.actionsRef.current.addChapter?.(state.chapter),
|
||||
}];
|
||||
};
|
||||
|
||||
function matterNode(item, contextId, subs) {
|
||||
const key = matterKey(item.id, contextId);
|
||||
const state = rowState(focus, "matter", item.id, contextId);
|
||||
return {
|
||||
key,
|
||||
icon: "matter",
|
||||
title: item.title,
|
||||
href: matterHref(item.id, contextId),
|
||||
current: state.whole && !isOpen(key),
|
||||
ancestor: state.here,
|
||||
expandable: true,
|
||||
load: { kind: "matter", id: item.id, contextId },
|
||||
children: () => {
|
||||
const outline = outlines.get(`matter:${item.id}:${contextId || ""}`);
|
||||
if (!outline) return [{ key: `${key}:loading`, icon: "contents", title: "Wird geladen …", className: "library-tree__hint", onClick: () => {} }];
|
||||
const submatters = (outline.submatters || []).map((child) => matterNode(child, contextId, null));
|
||||
return [
|
||||
{ key: `${key}:all`, icon: "contents", title: "Alle Inhalte", href: matterHref(item.id, contextId), current: state.whole },
|
||||
...chapterNodes(chapterTree(outline.chapters || []), "", item.id, "matter", contextId),
|
||||
...submatters,
|
||||
...addChapter(item.id, "matter", contextId),
|
||||
];
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function caseNode(item) {
|
||||
const key = caseKey(item.id);
|
||||
const state = rowState(focus, "case", item.id);
|
||||
const kids = caseTree.children.get(item.id) || [];
|
||||
return {
|
||||
key,
|
||||
icon: "case",
|
||||
title: item.title,
|
||||
href: caseHref(item.id),
|
||||
current: state.whole && !isOpen(key),
|
||||
ancestor: state.here,
|
||||
expandable: true,
|
||||
load: { kind: "case", id: item.id },
|
||||
children: () => {
|
||||
const outline = outlines.get(`case:${item.id}:`);
|
||||
if (!outline) return [{ key: `${key}:loading`, icon: "contents", title: "Wird geladen …", className: "library-tree__hint", onClick: () => {} }];
|
||||
const hasParts = (outline.subcases || []).length > 0 || (outline.matters || []).length > 0;
|
||||
const rows = [];
|
||||
if (hasParts) rows.push({ key: `${key}:over`, icon: "contents", title: "Überblick", href: caseHref(item.id, { bereich: "ueberblick" }), current: state.overview });
|
||||
rows.push({ key: `${key}:direct`, icon: "contents", title: "Direkt in dieser Akte", href: caseHref(item.id), current: state.whole });
|
||||
rows.push(...chapterNodes(chapterTree(outline.chapters || []), "", item.id, "case", ""));
|
||||
rows.push(...kids.map(caseNode));
|
||||
rows.push(...(outline.matters || []).map((matter) => matterNode(matter, item.id, matter.children)));
|
||||
rows.push(...addChapter(item.id, "case", ""));
|
||||
return rows;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
cases: caseTree.roots.map(caseNode),
|
||||
matters: matterTreeAll.roots.map((item) => matterNode(item, "", null)),
|
||||
};
|
||||
}
|
||||
|
||||
function Section({ id, icon, label, count, nodes, tree, to }) {
|
||||
const open = tree.isOpen(id);
|
||||
return (
|
||||
<div className="library-tree__section">
|
||||
<div className="library-tree__row">
|
||||
<button type="button" className="library-tree__toggle" aria-expanded={open} aria-label={`${label} ${open ? "einklappen" : "ausklappen"}`} onClick={() => tree.toggle(id)}>
|
||||
{open ? "▾" : "▸"}
|
||||
</button>
|
||||
<NavLink to={to} end className={({ isActive }) => `library-tree__root${isActive ? " is-current" : ""}`}>
|
||||
<span className="library-tree__icon"><MiniIcon kind={icon} /></span> {label}
|
||||
<span className="library-tree__count">{count}</span>
|
||||
</NavLink>
|
||||
</div>
|
||||
{open ? <List nodes={nodes} tree={tree} /> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function NavTree({ cases, matters, rooms, employee, onDropOnRoom }) {
|
||||
const library = useLibrary();
|
||||
const [opened, setOpened] = useState(() => new Set(["sec:cases", "sec:matters"]));
|
||||
const [closed, setClosed] = useState(() => new Set());
|
||||
const [over, setOver] = useState("");
|
||||
const auto = focusKeys(library.focus, cases || [], matters || []);
|
||||
|
||||
const tree = {
|
||||
isOpen: (key) => {
|
||||
if (closed.has(key)) return false;
|
||||
return opened.has(key) || auto.has(key);
|
||||
},
|
||||
toggle: (key) => {
|
||||
const currently = tree.isOpen(key);
|
||||
setOpened((current) => {
|
||||
const next = new Set(current);
|
||||
if (currently) next.delete(key);
|
||||
else next.add(key);
|
||||
return next;
|
||||
});
|
||||
setClosed((current) => {
|
||||
const next = new Set(current);
|
||||
if (currently) next.add(key);
|
||||
else next.delete(key);
|
||||
return next;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// A new focus opens its path again, even if the person closed it before.
|
||||
const focusId = library.focus ? `${library.focus.kind}:${library.focus.id}:${library.focus.contextId || ""}` : "";
|
||||
useEffect(() => {
|
||||
if (!focusId) return;
|
||||
setClosed((current) => {
|
||||
const next = new Set(current);
|
||||
for (const key of auto) next.delete(key);
|
||||
return next;
|
||||
});
|
||||
}, [focusId]);
|
||||
|
||||
const nodes = buildNodes({ cases, matters, library, isOpen: tree.isOpen });
|
||||
|
||||
return (
|
||||
<nav className="library-tree" aria-label="Ablage">
|
||||
{employee ? null : (
|
||||
<>
|
||||
<h2 className="library-tree__heading">Meine Ablage</h2>
|
||||
<Section id="sec:cases" icon="case" label="Akten" count={(cases || []).length} nodes={nodes.cases} tree={tree} to="/cases" />
|
||||
<Section id="sec:matters" icon="matter" label="Vorgänge" count={(matters || []).length} nodes={nodes.matters} tree={tree} to="/matters" />
|
||||
</>
|
||||
)}
|
||||
<h2 className="library-tree__heading">Räume</h2>
|
||||
<NavLink to="/rooms" end className={({ isActive }) => `library-tree__root${isActive ? " is-current" : ""}`}>
|
||||
<span className="library-tree__icon"><MiniIcon kind="room" /></span> Alle Räume
|
||||
</NavLink>
|
||||
<ul className="library-tree__list">
|
||||
{(rooms || []).map((room) => (
|
||||
<li key={room.id}>
|
||||
<NavLink
|
||||
to={`/rooms/${room.id}`}
|
||||
className={({ isActive }) => `library-tree__link library-tree__room${isActive ? " is-current" : ""}${over === room.id ? " is-over" : ""}`}
|
||||
onDragOver={(event) => {
|
||||
if (!Array.from(event.dataTransfer?.types || []).includes(SHARE_DRAG_TYPE)) return;
|
||||
event.preventDefault();
|
||||
event.dataTransfer.dropEffect = "link";
|
||||
setOver(room.id);
|
||||
}}
|
||||
onDragLeave={() => setOver((current) => (current === room.id ? "" : current))}
|
||||
onDrop={(event) => {
|
||||
event.preventDefault();
|
||||
setOver("");
|
||||
const text = event.dataTransfer.getData(SHARE_DRAG_TYPE);
|
||||
const payload = parseShareDrag(text, "case") || parseShareDrag(text, "matter");
|
||||
if (payload) onDropOnRoom(payload, room);
|
||||
}}
|
||||
>
|
||||
<span className="library-tree__icon"><MiniIcon kind="room" /></span>
|
||||
<span className="library-tree__title">{room.name}</span>
|
||||
<span className="library-tree__count">{room.case_count + room.matter_count}</span>
|
||||
</NavLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,3 +104,87 @@ export function addable(items, roomId) {
|
||||
export function roleHint(role) {
|
||||
return roleLabel(role);
|
||||
}
|
||||
|
||||
// ---- Navigation tree: keys, the path that opens for the focused entry, chapters and links ----
|
||||
|
||||
export const caseKey = (id) => `c:${id}`;
|
||||
export const matterKey = (id, contextId = "") => (contextId ? `m:${id}@${contextId}` : `m:${id}`);
|
||||
|
||||
// Keys of all nodes that open so that the focused entry is visible: its sections, parents and itself.
|
||||
export function focusKeys(focus, cases = [], matters = []) {
|
||||
const keys = new Set();
|
||||
if (!focus) return keys;
|
||||
const caseById = new Map(cases.map((item) => [item.id, item]));
|
||||
const matterById = new Map(matters.map((item) => [item.id, item]));
|
||||
const addCaseChain = (caseId) => {
|
||||
keys.add("sec:cases");
|
||||
keys.add(caseKey(caseId));
|
||||
const seen = new Set();
|
||||
let current = caseById.get(caseId);
|
||||
while (current && !seen.has(current.id)) {
|
||||
seen.add(current.id);
|
||||
keys.add(caseKey(current.id));
|
||||
current = current.parent_case_id ? caseById.get(current.parent_case_id) : null;
|
||||
}
|
||||
};
|
||||
if (focus.kind === "case") {
|
||||
addCaseChain(focus.id);
|
||||
} else if (focus.kind === "matter") {
|
||||
const context = focus.contextId || "";
|
||||
if (context) addCaseChain(context);
|
||||
else keys.add("sec:matters");
|
||||
keys.add(matterKey(focus.id, context));
|
||||
const seen = new Set();
|
||||
let current = matterById.get(focus.id);
|
||||
while (current && current.parent_matter_id && !seen.has(current.id)) {
|
||||
seen.add(current.id);
|
||||
keys.add(matterKey(current.parent_matter_id, context));
|
||||
current = matterById.get(current.parent_matter_id);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
// Chapters of one container as a tree. Each node knows its siblings for the move arrows.
|
||||
export function chapterTree(chapters = [], parentId = "") {
|
||||
const siblings = chapters.filter((chapter) => (chapter.parent_chapter_id || "") === parentId);
|
||||
return siblings.map((chapter, index) => ({
|
||||
chapter,
|
||||
first: index === 0,
|
||||
last: index === siblings.length - 1,
|
||||
children: chapterTree(chapters, chapter.id),
|
||||
}));
|
||||
}
|
||||
|
||||
export function caseHref(id, extra = {}) {
|
||||
const query = new URLSearchParams(extra).toString();
|
||||
return `/cases/${id}${query ? `?${query}` : ""}`;
|
||||
}
|
||||
|
||||
export function matterHref(id, contextId = "", extra = {}) {
|
||||
const query = new URLSearchParams({ ...(contextId ? { context_kind: "case", context_id: contextId } : {}), ...extra }).toString();
|
||||
return `/matters/${id}${query ? `?${query}` : ""}`;
|
||||
}
|
||||
|
||||
// Which row is the current one for the focus. The container row is current only when nothing below it is selected.
|
||||
export function rowState(focus, kind, id, contextId = "") {
|
||||
const here = Boolean(focus) && focus.kind === kind && focus.id === id && (kind === "case" || (focus.contextId || "") === (contextId || ""));
|
||||
return {
|
||||
here,
|
||||
chapter: here ? focus.chapterId || "" : "",
|
||||
overview: here && kind === "case" ? Boolean(focus.overview) : false,
|
||||
whole: here && !focus.chapterId && !focus.overview,
|
||||
};
|
||||
}
|
||||
|
||||
// A short signature of what the tree shows below an entry. A change reloads that outline.
|
||||
export function outlineSignature(record) {
|
||||
if (!record) return "";
|
||||
const chapters = (record.chapters || []).map((chapter) => `${chapter.id}:${chapter.title}:${chapter.position}:${chapter.parent_chapter_id || ""}`).join("|");
|
||||
const subcases = (record.subcases || []).map((item) => item.id).join(",");
|
||||
const matters = [];
|
||||
const walk = (nodes) => (nodes || []).forEach((node) => { matters.push(node.id); walk(node.children); });
|
||||
walk(record.matters);
|
||||
const submatters = (record.submatters || []).map((item) => item.id).join(",");
|
||||
return [record.id, record.title, chapters, subcases, matters.join(","), submatters].join("#");
|
||||
}
|
||||
@@ -61,3 +61,69 @@ test("only own entries that are not yet in the room can be added", () => {
|
||||
assert.deepEqual(addable(cases, "r1").map((c) => c.id), ["b", "d"]);
|
||||
assert.deepEqual(addable(cases, "r2").map((c) => c.id), ["a", "b", "d"]);
|
||||
});
|
||||
|
||||
import { caseHref, caseKey, chapterTree, focusKeys, matterHref, matterKey, outlineSignature, rowState } from "./library-core.js";
|
||||
|
||||
const allCases = [
|
||||
{ id: "a", parent_case_id: null },
|
||||
{ id: "b", parent_case_id: "a" },
|
||||
];
|
||||
const allMatters = [
|
||||
{ id: "m1", parent_matter_id: null },
|
||||
{ id: "m2", parent_matter_id: "m1" },
|
||||
];
|
||||
|
||||
test("the focus opens the path to a case, its parents and its section", () => {
|
||||
assert.deepEqual([...focusKeys({ kind: "case", id: "b" }, allCases, allMatters)].sort(), ["c:a", "c:b", "sec:cases"]);
|
||||
assert.equal(focusKeys(null, allCases, allMatters).size, 0);
|
||||
});
|
||||
|
||||
test("a matter opens under its case context or under the matters section", () => {
|
||||
const inCase = focusKeys({ kind: "matter", id: "m2", contextId: "b" }, allCases, allMatters);
|
||||
assert.deepEqual([...inCase].sort(), ["c:a", "c:b", "m:m1@b", "m:m2@b", "sec:cases"]);
|
||||
const alone = focusKeys({ kind: "matter", id: "m2", contextId: "" }, allCases, allMatters);
|
||||
assert.deepEqual([...alone].sort(), ["m:m1", "m:m2", "sec:matters"]);
|
||||
assert.equal(matterKey("x", "c"), "m:x@c");
|
||||
assert.equal(matterKey("x"), "m:x");
|
||||
assert.equal(caseKey("x"), "c:x");
|
||||
});
|
||||
|
||||
test("chapters become a tree that knows its first and last sibling", () => {
|
||||
const chapters = [
|
||||
{ id: "1", parent_chapter_id: null },
|
||||
{ id: "2", parent_chapter_id: "1" },
|
||||
{ id: "3", parent_chapter_id: "1" },
|
||||
{ id: "4", parent_chapter_id: null },
|
||||
];
|
||||
const tree = chapterTree(chapters);
|
||||
assert.deepEqual(tree.map((n) => [n.chapter.id, n.first, n.last]), [["1", true, false], ["4", false, true]]);
|
||||
assert.deepEqual(tree[0].children.map((n) => [n.chapter.id, n.first, n.last]), [["2", true, false], ["3", false, true]]);
|
||||
});
|
||||
|
||||
test("links keep the case context of a matter", () => {
|
||||
assert.equal(caseHref("a"), "/cases/a");
|
||||
assert.equal(caseHref("a", { kapitel: "k" }), "/cases/a?kapitel=k");
|
||||
assert.equal(matterHref("m", "a"), "/matters/m?context_kind=case&context_id=a");
|
||||
assert.equal(matterHref("m", "a", { kapitel: "k" }), "/matters/m?context_kind=case&context_id=a&kapitel=k");
|
||||
assert.equal(matterHref("m"), "/matters/m");
|
||||
});
|
||||
|
||||
test("a row is current only for its own context", () => {
|
||||
const focus = { kind: "matter", id: "m", contextId: "a", chapterId: "" };
|
||||
assert.equal(rowState(focus, "matter", "m", "a").whole, true);
|
||||
assert.equal(rowState(focus, "matter", "m", "b").here, false);
|
||||
assert.equal(rowState(focus, "matter", "m", "").here, false);
|
||||
assert.equal(rowState({ kind: "case", id: "a", overview: true }, "case", "a").overview, true);
|
||||
assert.equal(rowState({ kind: "case", id: "a", chapterId: "k" }, "case", "a").whole, false);
|
||||
assert.equal(rowState(null, "case", "a").here, false);
|
||||
});
|
||||
|
||||
test("the outline signature changes with chapters, subcases and matters", () => {
|
||||
const base = { id: "a", title: "T", chapters: [{ id: "1", title: "K", position: 1 }], subcases: [{ id: "s" }], matters: [{ id: "m", children: [{ id: "n", children: [] }] }] };
|
||||
const same = outlineSignature(base);
|
||||
assert.equal(outlineSignature({ ...base }), same);
|
||||
assert.notEqual(outlineSignature({ ...base, chapters: [...base.chapters, { id: "2", title: "L", position: 2 }] }), same);
|
||||
assert.notEqual(outlineSignature({ ...base, subcases: [] }), same);
|
||||
assert.notEqual(outlineSignature({ ...base, matters: [] }), same);
|
||||
assert.equal(outlineSignature(null), "");
|
||||
});
|
||||
@@ -103,3 +103,17 @@ a.button.quiet { background: var(--surface2); border: 1px solid var(--border2);
|
||||
.mini-icon--room { color: var(--kind-room); }
|
||||
.library-tree__toggle { font-size: 14px; }
|
||||
.mark, .chip-popover .popover__button { display: inline-flex; align-items: center; gap: 5px; }
|
||||
|
||||
/* Navigation tree below the entries */
|
||||
.library-tree__link.is-ancestor { font-weight: 700; }
|
||||
.library-tree__add .library-tree__link, .library-tree__add button { color: var(--accent-dark); font-weight: 600; }
|
||||
.library-tree__hint .library-tree__link { color: var(--text2); font-style: italic; }
|
||||
.library-tree__moves { display: inline-flex; gap: 0; flex: none; }
|
||||
.library-tree__moves button { min-height: 26px; width: 24px; padding: 0; font-size: 13px; background: transparent; color: var(--text2); border-radius: 6px; }
|
||||
.library-tree__moves button:hover:not(:disabled) { background: var(--accent-light); color: var(--accent-dark); }
|
||||
.library-tree button.library-tree__link { background: transparent; border: 0; justify-content: flex-start; text-align: left; width: 100%; }
|
||||
.library__main .workspace { min-height: calc(100vh - 80px); }
|
||||
.library__main > .page, .library__main > .workspace { max-width: none; }
|
||||
.library-tree__list { min-width: 0; }
|
||||
.library-tree__section > .library-tree__row > .library-tree__root { flex: 1; }
|
||||
.mini-icon--plus { color: var(--accent-dark); }
|
||||
+22
-194
@@ -11,106 +11,11 @@ import { RoomShare } from "../admin/RoomShare.jsx";
|
||||
import { writableRooms } from "../admin/admin-core.js";
|
||||
import { ContentBoard, DateField, DirectionChoice, MarkdownEditor, ObjectMenu, OrderChoice, 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 { Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||
import { useLibraryFocus } from "../library/LibraryLayout.jsx";
|
||||
import { outlineSignature } from "../library/library-core.js";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
|
||||
function OutlineLink({ kind, title, to }) {
|
||||
return (
|
||||
<Link className="hierarchy__row" to={to}>
|
||||
<span className="hierarchy__kind">{kind}</span>
|
||||
<strong>{title}</strong>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function matterChapters(record, matterId) {
|
||||
return (record.contained || []).find((item) => item.matter_id === matterId)?.chapters || [];
|
||||
}
|
||||
|
||||
function ChapterLinks({ chapters, scopeId, scope, chapterId, onChapter }) {
|
||||
if (!chapters.length) return null;
|
||||
return (
|
||||
<ul>
|
||||
{chapters.map((chapter) => (
|
||||
<li key={chapter.id}>
|
||||
<button
|
||||
type="button"
|
||||
className={scope === scopeId && chapterId === chapter.id ? "hierarchy__row is-current" : "hierarchy__row"}
|
||||
onClick={() => onChapter(scopeId, chapter.id)}
|
||||
>
|
||||
<span className="hierarchy__kind">Kapitel</span>
|
||||
<strong>{chapter.title}</strong>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function MatterBranch({ matter, caseId, scope, chapterId, record, onScope, onChapter }) {
|
||||
const selected = scope === matter.id && !chapterId;
|
||||
return (
|
||||
<li>
|
||||
<div className="hierarchy__line">
|
||||
<button type="button" className={selected ? "hierarchy__row is-current" : "hierarchy__row"} onClick={() => onScope(matter.id)}>
|
||||
<span className="hierarchy__kind">{matter.kind_label || "Vorgang"}</span>
|
||||
<strong>{matter.title}</strong>
|
||||
</button>
|
||||
<Link className="hierarchy__open" to={`/matters/${matter.id}?context_kind=case&context_id=${caseId}`}>Öffnen</Link>
|
||||
</div>
|
||||
<ChapterLinks chapters={matterChapters(record, matter.id)} scopeId={matter.id} scope={scope} chapterId={chapterId} onChapter={onChapter} />
|
||||
{matter.children?.length ? (
|
||||
<ul>
|
||||
{matter.children.map((child) => (
|
||||
<MatterBranch key={child.id} matter={child} caseId={caseId} scope={scope} chapterId={chapterId} record={record} onScope={onScope} onChapter={onChapter} />
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function CaseOutline({ record, caseId, scope, chapterId, onScope, onChapter }) {
|
||||
const hasParent = Boolean(record.parent_case_id && record.parent_title);
|
||||
return (
|
||||
<nav className="outline-nav" aria-label="Gliederung">
|
||||
<h2>Gliederung</h2>
|
||||
<button type="button" className={scope === "all" ? "hierarchy__row is-current" : "hierarchy__row"} onClick={() => onScope("all")}>
|
||||
<span className="hierarchy__kind">Überblick</span>
|
||||
<strong>Alle Inhalte</strong>
|
||||
</button>
|
||||
<button type="button" className={scope === "direct" && !chapterId ? "hierarchy__row is-current" : "hierarchy__row"} onClick={() => onScope("direct")}>
|
||||
<span className="hierarchy__kind">Akte</span>
|
||||
<strong>Direkt in dieser Akte</strong>
|
||||
</button>
|
||||
<ChapterLinks chapters={record.chapters || []} scopeId="direct" scope={scope} chapterId={chapterId} onChapter={onChapter} />
|
||||
{hasParent ? (
|
||||
<p className="hierarchy__parent">Übergeordnet: <Link to={`/cases/${record.parent_case_id}`}>Akte {record.parent_title}</Link></p>
|
||||
) : null}
|
||||
{record.subcases?.length ? (
|
||||
<>
|
||||
<h3>Unterakten</h3>
|
||||
<ul className="hierarchy">
|
||||
{record.subcases.map((item) => (
|
||||
<li key={item.id}><OutlineLink kind="Unterakte" title={item.title} to={`/cases/${item.id}`} /></li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
{record.matters?.length ? (
|
||||
<>
|
||||
<h3>Vorgänge</h3>
|
||||
<ul className="hierarchy">
|
||||
{record.matters.map((matter) => (
|
||||
<MatterBranch key={matter.id} matter={matter} caseId={caseId} scope={scope} chapterId={chapterId} record={record} onScope={onScope} onChapter={onChapter} />
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function matterOrigin(group) {
|
||||
const kind = group.kind_label === "Teilvorgang" ? "Teilvorgang" : "Vorgang";
|
||||
const parent = group.parent_title ? ` · Vorgang ${group.parent_title}` : "";
|
||||
@@ -146,59 +51,6 @@ function mergedCaseItems(record, direction, caseId) {
|
||||
return [...dated, ...undated];
|
||||
}
|
||||
|
||||
function matterNode(matter, caseId) {
|
||||
const query = `?context_kind=case&context_id=${caseId}`;
|
||||
return {
|
||||
id: matter.id,
|
||||
title: matter.title,
|
||||
kind: matter.kind_label || "Vorgang",
|
||||
href: `/matters/${matter.id}${query}`,
|
||||
current: false,
|
||||
children: (matter.children || []).map((child) => matterNode(child, caseId)),
|
||||
};
|
||||
}
|
||||
|
||||
function caseNodes(record, parentRecord) {
|
||||
const self = {
|
||||
id: record.id,
|
||||
title: record.title,
|
||||
kind: record.kind_label || "Akte",
|
||||
href: null,
|
||||
current: true,
|
||||
children: [
|
||||
...(record.subcases || []).map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
kind: "Unterakte",
|
||||
href: `/cases/${item.id}`,
|
||||
current: false,
|
||||
children: [],
|
||||
})),
|
||||
...(record.matters || []).map((matter) => matterNode(matter, record.id)),
|
||||
],
|
||||
};
|
||||
if (!parentRecord) return [self];
|
||||
const siblings = (parentRecord.subcases || []).map((item) => (item.id === record.id ? self : {
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
kind: "Unterakte",
|
||||
href: `/cases/${item.id}`,
|
||||
current: false,
|
||||
children: [],
|
||||
}));
|
||||
return [{
|
||||
id: parentRecord.id,
|
||||
title: parentRecord.title,
|
||||
kind: "Akte",
|
||||
href: `/cases/${parentRecord.id}`,
|
||||
current: false,
|
||||
children: [
|
||||
...(siblings.length ? siblings : [self]),
|
||||
...(parentRecord.matters || []).map((matter) => matterNode(matter, parentRecord.id)),
|
||||
],
|
||||
}];
|
||||
}
|
||||
|
||||
export function CaseDetail() {
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
@@ -208,7 +60,6 @@ export function CaseDetail() {
|
||||
const chapterId = overview ? "" : (params.get("kapitel") || "");
|
||||
const entryId = params.get("eintrag") || "";
|
||||
const [record, setRecord] = useState(null);
|
||||
const [parentTree, setParentTree] = useState(null);
|
||||
const [error, setError] = useState("");
|
||||
const [modal, setModal] = useState("");
|
||||
const [chapterParentId, setChapterParentId] = useState("");
|
||||
@@ -269,7 +120,6 @@ export function CaseDetail() {
|
||||
setModal("");
|
||||
setDateDir("asc");
|
||||
setStructureOpen(false);
|
||||
setParentTree(null);
|
||||
api(`/api/v1/cases/${id}`).then((detail) => {
|
||||
if (!alive) return;
|
||||
pendingChapter.current = "";
|
||||
@@ -280,19 +130,6 @@ export function CaseDetail() {
|
||||
return () => { alive = false; };
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!record || record.id !== id || !record.parent_case_id) return undefined;
|
||||
let alive = true;
|
||||
api(`/api/v1/cases/${record.parent_case_id}`).then((parent) => {
|
||||
if (alive) setParentTree(parent);
|
||||
}).catch(() => {
|
||||
if (alive) setParentTree(null);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [record, id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!record || record.id !== id) return;
|
||||
const matterId = rawScope && !["all", "ueberblick", "direkt", "direct"].includes(rawScope) ? rawScope : "";
|
||||
@@ -385,6 +222,25 @@ export function CaseDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
useLibraryFocus(
|
||||
record && record.id === id
|
||||
? {
|
||||
kind: "case",
|
||||
id,
|
||||
chapterId: overview ? "" : chapterId,
|
||||
overview,
|
||||
canEdit: Boolean(record.rights?.edit),
|
||||
canReorder: Boolean(record.rights?.edit) && (record.chapters || []).length > 1,
|
||||
stamp: outlineSignature(record),
|
||||
}
|
||||
: null,
|
||||
{ addChapter: (parentId) => openChapter(parentId), moveChapter },
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setView("contents");
|
||||
}, [chapterId, overview]);
|
||||
|
||||
if (error && !record) return <main className="page"><ErrorNote error={error} /></main>;
|
||||
if (!record) return <main className="page"><p className="muted">Akte wird geladen …</p></main>;
|
||||
|
||||
@@ -396,10 +252,6 @@ export function CaseDetail() {
|
||||
count: (record.bindings || []).filter((item) => item.chapter_id === chapter.id).length,
|
||||
}));
|
||||
const merged = mergedCaseItems(record, dateDir, id);
|
||||
const contexts = [
|
||||
...(parentTree ? [{ id: parentTree.id, label: parentTree.title }] : []),
|
||||
{ id: record.id, label: record.title },
|
||||
];
|
||||
const entry = overview ? null : ((record.bindings || []).find((item) => item.id === entryId) || null);
|
||||
const hasContained = Boolean(record.contained?.length);
|
||||
|
||||
@@ -411,29 +263,6 @@ export function CaseDetail() {
|
||||
setStructureOpen={setStructureOpen}
|
||||
hasEntry={Boolean(entry) && !overview}
|
||||
listRef={listRef}
|
||||
nav={(
|
||||
<StructureNavigator
|
||||
contexts={contexts}
|
||||
contextValue={id}
|
||||
onContext={parentTree ? ((next) => { if (next !== id) navigate(`/cases/${next}`); }) : null}
|
||||
nodes={caseNodes(record, parentTree)}
|
||||
allLabel="Direkt in dieser Akte"
|
||||
chapters={chapters}
|
||||
chapterId={overview ? "" : chapterId}
|
||||
allCount={(record.bindings || []).length}
|
||||
overview={hasContained ? { active: overview, count: merged.length, onSelect: showOverview } : null}
|
||||
chapterHeading={`Kapitel in ${record.title}`}
|
||||
onChapter={chooseChapter}
|
||||
onAddChapter={canEdit ? () => openChapter(chapterId) : null}
|
||||
onAddRootChapter={canEdit ? () => openChapter("") : null}
|
||||
canAddChapter={canEdit}
|
||||
onMoveChapter={moveChapter}
|
||||
canReorder={canEdit && chapters.length > 1}
|
||||
links={[]}
|
||||
onNavigate={() => setStructureOpen(false)}
|
||||
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
||||
/>
|
||||
)}
|
||||
reader={entry ? (
|
||||
<ReadingPane
|
||||
binding={entry}
|
||||
@@ -459,7 +288,6 @@ export function CaseDetail() {
|
||||
</div>
|
||||
</div>
|
||||
<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={() => openAdd(chapterId)}>
|
||||
<NavIcon name="plus" /> Inhalt hinzufügen
|
||||
|
||||
+32
-151
@@ -10,7 +10,9 @@ import { chapterPathLabel, siblingChapterIds, trailWithChapter } from "./chapter
|
||||
import { ChapterForm, FileForm, NoteForm } from "./Cases.jsx";
|
||||
import { ContentBoard, DateField, ObjectMenu, Placements, 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 { Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||
import { useLibraryFocus } from "../library/LibraryLayout.jsx";
|
||||
import { outlineSignature } from "../library/library-core.js";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
import { ExportPackage } from "./ExportPackage.jsx";
|
||||
import { RoomShare } from "../admin/RoomShare.jsx";
|
||||
@@ -27,98 +29,6 @@ function contextQuery(inherited) {
|
||||
return inherited ? `?context_kind=${inherited.kind}&context_id=${inherited.id}` : "";
|
||||
}
|
||||
|
||||
function mapMatterNodes(nodes, activeId, query) {
|
||||
return (nodes || []).map((node) => ({
|
||||
id: node.id,
|
||||
title: node.title,
|
||||
kind: node.kind_label || "Vorgang",
|
||||
href: `/matters/${node.id}${query}`,
|
||||
current: node.id === activeId,
|
||||
children: mapMatterNodes(node.children, activeId, query),
|
||||
}));
|
||||
}
|
||||
|
||||
function caseNodes(caseRecord, parentRecord, activeId, contextId) {
|
||||
const query = `?context_kind=case&context_id=${contextId}`;
|
||||
const self = {
|
||||
id: caseRecord.id,
|
||||
title: caseRecord.title,
|
||||
kind: caseRecord.kind_label || "Akte",
|
||||
href: `/cases/${caseRecord.id}`,
|
||||
current: false,
|
||||
children: [
|
||||
...(caseRecord.subcases || []).map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
kind: "Unterakte",
|
||||
href: `/cases/${item.id}`,
|
||||
current: false,
|
||||
children: [],
|
||||
})),
|
||||
...mapMatterNodes(caseRecord.matters, activeId, query),
|
||||
],
|
||||
};
|
||||
if (!parentRecord) return [self];
|
||||
const siblings = (parentRecord.subcases || []).map((item) => (item.id === caseRecord.id ? self : {
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
kind: "Unterakte",
|
||||
href: `/cases/${item.id}`,
|
||||
current: false,
|
||||
children: [],
|
||||
}));
|
||||
return [{
|
||||
id: parentRecord.id,
|
||||
title: parentRecord.title,
|
||||
kind: "Akte",
|
||||
href: `/cases/${parentRecord.id}`,
|
||||
current: false,
|
||||
children: [
|
||||
...(siblings.length ? siblings : [self]),
|
||||
...mapMatterNodes(parentRecord.matters, activeId, `?context_kind=case&context_id=${parentRecord.id}`),
|
||||
],
|
||||
}];
|
||||
}
|
||||
|
||||
function placementNodes(record) {
|
||||
const matter = {
|
||||
id: record.id,
|
||||
title: record.title,
|
||||
kind: record.kind_label || "Vorgang",
|
||||
href: null,
|
||||
current: true,
|
||||
children: (record.submatters || []).map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
kind: "Teilvorgang",
|
||||
href: `/matters/${item.id}`,
|
||||
current: false,
|
||||
children: [],
|
||||
})),
|
||||
};
|
||||
const rooted = record.parent_matter_id && record.parent_title ? [{
|
||||
id: record.parent_matter_id,
|
||||
title: record.parent_title,
|
||||
kind: "Vorgang",
|
||||
href: `/matters/${record.parent_matter_id}`,
|
||||
current: false,
|
||||
children: [matter],
|
||||
}] : [matter];
|
||||
const cases = record.placements || [];
|
||||
if (cases.length < 2) return rooted;
|
||||
return [
|
||||
...rooted,
|
||||
...cases.map((item) => ({
|
||||
id: item.case_id,
|
||||
title: String(item.label || "Akte").replaceAll("Unterakte ", "").replaceAll("Akte ", "").replaceAll(" → ", " / "),
|
||||
kind: "Akte",
|
||||
href: `/matters/${record.id}?context_kind=case&context_id=${item.case_id}`,
|
||||
current: false,
|
||||
children: [],
|
||||
})),
|
||||
];
|
||||
}
|
||||
|
||||
function objectTrail(record, query) {
|
||||
const items = [{ label: "Vorgänge", href: "/matters" }];
|
||||
if (record.parent_matter_id && record.parent_title) {
|
||||
@@ -144,8 +54,6 @@ export function MatterDetail() {
|
||||
const [view, setView] = useState("contents");
|
||||
const { width, structureOpen, setStructureOpen } = useWorkspaceLayout();
|
||||
const listRef = useRef(null);
|
||||
const [caseTree, setCaseTree] = useState(null);
|
||||
const [parentTree, setParentTree] = useState(null);
|
||||
const pendingChapter = useRef("");
|
||||
const entryId = params.get("eintrag") || "";
|
||||
|
||||
@@ -240,33 +148,6 @@ export function MatterDetail() {
|
||||
setParams(next, { replace: true });
|
||||
}, [record, id, inherited?.kind]);
|
||||
|
||||
useEffect(() => {
|
||||
if (inherited?.kind !== "case") {
|
||||
setCaseTree(null);
|
||||
setParentTree(null);
|
||||
return undefined;
|
||||
}
|
||||
let alive = true;
|
||||
api(`/api/v1/cases/${inherited.id}`).then((detail) => {
|
||||
if (!alive) return;
|
||||
setCaseTree(detail);
|
||||
if (!detail.parent_case_id) {
|
||||
setParentTree(null);
|
||||
return;
|
||||
}
|
||||
api(`/api/v1/cases/${detail.parent_case_id}`).then((parent) => {
|
||||
if (alive) setParentTree(parent);
|
||||
}).catch(() => {
|
||||
if (alive) setParentTree(null);
|
||||
});
|
||||
}).catch(() => {
|
||||
if (alive) setCaseTree(null);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [inherited?.kind, inherited?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!record || record.id !== id || !entryId) return;
|
||||
if ((record.bindings || []).some((item) => item.id === entryId)) return;
|
||||
@@ -342,6 +223,25 @@ export function MatterDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
useLibraryFocus(
|
||||
record && record.id === id
|
||||
? {
|
||||
kind: "matter",
|
||||
id,
|
||||
contextId: inherited?.kind === "case" ? inherited.id : "",
|
||||
chapterId,
|
||||
canEdit: Boolean(record.rights?.edit),
|
||||
canReorder: Boolean(record.rights?.edit) && (record.chapters || []).length > 1,
|
||||
stamp: outlineSignature(record),
|
||||
}
|
||||
: null,
|
||||
{ addChapter: (parentId) => openChapter(parentId), moveChapter },
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setView("contents");
|
||||
}, [chapterId]);
|
||||
|
||||
if (error && !record) return <main className="page"><ErrorNote error={error} /></main>;
|
||||
if (!record) return <main className="page"><p className="muted">Vorgang wird geladen …</p></main>;
|
||||
|
||||
@@ -353,12 +253,6 @@ export function MatterDetail() {
|
||||
...chapter,
|
||||
count: (record.bindings || []).filter((item) => item.chapter_id === chapter.id).length,
|
||||
}));
|
||||
const contexts = (record.placements || []).map((item) => ({
|
||||
id: item.case_id,
|
||||
label: String(item.label || "Akte").replaceAll("Unterakte ", "").replaceAll("Akte ", "").replaceAll(" → ", " / "),
|
||||
}));
|
||||
const contextValue = inherited?.kind === "case" ? inherited.id : (contexts.length === 1 ? contexts[0].id : "");
|
||||
const nodes = caseTree && inherited ? caseNodes(caseTree, parentTree, id, inherited.id) : placementNodes(record);
|
||||
const links = [
|
||||
...(record.cross_links || []).map((item) => ({
|
||||
id: `cross-${item.id}`,
|
||||
@@ -384,28 +278,6 @@ export function MatterDetail() {
|
||||
setStructureOpen={setStructureOpen}
|
||||
hasEntry={Boolean(entry)}
|
||||
listRef={listRef}
|
||||
nav={(
|
||||
<StructureNavigator
|
||||
contexts={contexts.length > 1 && !inherited ? [{ id: "", label: "Keine Akte gewählt" }, ...contexts] : contexts}
|
||||
contextValue={contextValue}
|
||||
onContext={contexts.length > 1 ? switchContext : null}
|
||||
nodes={nodes}
|
||||
chapters={chapters}
|
||||
chapterId={chapterId}
|
||||
allLabel=""
|
||||
allCount={(record.bindings || []).length}
|
||||
chapterHeading={`Kapitel in ${record.title}`}
|
||||
onChapter={chooseChapter}
|
||||
onAddChapter={canEdit ? () => openChapter(chapterId) : null}
|
||||
onAddRootChapter={canEdit ? () => openChapter("") : null}
|
||||
canAddChapter={canEdit}
|
||||
onMoveChapter={moveChapter}
|
||||
canReorder={canEdit && chapters.length > 1}
|
||||
links={links}
|
||||
onNavigate={() => setStructureOpen(false)}
|
||||
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
||||
/>
|
||||
)}
|
||||
reader={entry ? (
|
||||
<ReadingPane
|
||||
binding={entry}
|
||||
@@ -427,13 +299,22 @@ export function MatterDetail() {
|
||||
<div>
|
||||
<Trail items={trailWithChapter(record.trail?.length ? record.trail : objectTrail(record, query), record.chapters, chapterId, `/matters/${id}${query}`)} />
|
||||
<Placements items={record.placements} />
|
||||
{links.length ? (
|
||||
<p className="placements">
|
||||
{links.map((item, index) => (
|
||||
<span key={item.id}>
|
||||
{index ? <span aria-hidden="true"> · </span> : null}
|
||||
<span className="muted">{item.kind}: </span><Link to={item.href}>{item.title}</Link>
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="title-row">
|
||||
<h1>{record.title}</h1>
|
||||
<span className={record.status === "open" ? "status-pill" : "status-pill is-closed"}>{record.status === "open" ? "Offen" : "Geschlossen"}</span>
|
||||
</div>
|
||||
</div>
|
||||
<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={() => openAdd(chapterId)}>
|
||||
<NavIcon name="plus" /> Inhalt hinzufügen
|
||||
|
||||
@@ -17,12 +17,17 @@ export function useWorkspaceLayout() {
|
||||
return { width, structureOpen, setStructureOpen };
|
||||
}
|
||||
|
||||
// The navigation tree of the library sits left of the page on wide screens and takes this much room.
|
||||
const TREE_WIDTH = 264;
|
||||
|
||||
export function Workspace({ width, structureOpen, setStructureOpen, hasEntry, nav, reader, listRef, children }) {
|
||||
const phone = width < 760;
|
||||
const navColumn = width >= 1500;
|
||||
const split = width >= 1180 && hasEntry;
|
||||
const showNav = phone ? structureOpen && !hasEntry : navColumn || structureOpen;
|
||||
const showList = phone ? !structureOpen && !hasEntry : !(hasEntry && width < 1180);
|
||||
// Room for the page itself: the tree narrows it on wide screens.
|
||||
const room = width > 900 ? width - TREE_WIDTH : width;
|
||||
const navColumn = Boolean(nav) && width >= 1500;
|
||||
const split = room >= 1180 && hasEntry;
|
||||
const showNav = Boolean(nav) && (phone ? structureOpen && !hasEntry : navColumn || structureOpen);
|
||||
const showList = phone ? !structureOpen && !hasEntry : !(hasEntry && room < 1180);
|
||||
const showReader = hasEntry && (phone ? !structureOpen : true);
|
||||
const overlay = showNav && !phone && !navColumn;
|
||||
|
||||
|
||||
Reference in new issue
Block a user