Schließe den Leser, wenn eine entfernte Datei die Navigation ausblendet. #7
No files matched your search
@@ -209,12 +209,12 @@ function chapterOrigin(base, chapters, chapterId) {
|
||||
|
||||
function mergedCaseItems(record, direction, caseId) {
|
||||
const rows = [
|
||||
...(record.bindings || []).map((binding) => ({
|
||||
...(record.bindings || []).filter((binding) => binding?.element).map((binding) => ({
|
||||
...binding,
|
||||
origin: chapterOrigin("Direkt in dieser Akte", record.chapters, binding.chapter_id),
|
||||
readerHref: `/cases/${caseId}?eintrag=${binding.id}${binding.chapter_id ? `&kapitel=${binding.chapter_id}` : ""}`,
|
||||
})),
|
||||
...(record.contained || []).flatMap((group) => (group.bindings || []).map((binding) => ({
|
||||
...(record.contained || []).flatMap((group) => (group.bindings || []).filter((binding) => binding?.element).map((binding) => ({
|
||||
...binding,
|
||||
origin: chapterOrigin(matterOrigin(group), group.chapters, binding.chapter_id),
|
||||
readerHref: `/matters/${group.matter_id}?context_kind=case&context_id=${caseId}&eintrag=${binding.id}${binding.chapter_id ? `&kapitel=${binding.chapter_id}` : ""}`,
|
||||
@@ -396,6 +396,14 @@ export function CaseDetail() {
|
||||
}
|
||||
}, [record, id, rawScope, overview, chapterId, params, setParams, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!record || record.id !== id || overview || !entryId) return;
|
||||
if ((record.bindings || []).some((item) => item.id === entryId)) return;
|
||||
const updated = new URLSearchParams(params);
|
||||
updated.delete("eintrag");
|
||||
setParams(updated, { replace: true });
|
||||
}, [record, id, overview, entryId, params, setParams]);
|
||||
|
||||
useEffect(() => {
|
||||
if (entryId) return;
|
||||
restoreScroll(listRef.current, `tsumugu-scroll:case:${id}:${chapterId}:${overview ? "over" : "direct"}`);
|
||||
@@ -486,7 +494,7 @@ export function CaseDetail() {
|
||||
width={width}
|
||||
structureOpen={structureOpen}
|
||||
setStructureOpen={setStructureOpen}
|
||||
hasEntry={Boolean(entryId) && !overview}
|
||||
hasEntry={Boolean(entry) && !overview}
|
||||
listRef={listRef}
|
||||
nav={(
|
||||
<StructureNavigator
|
||||
@@ -511,7 +519,7 @@ export function CaseDetail() {
|
||||
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
||||
/>
|
||||
)}
|
||||
reader={entryId && !overview ? (
|
||||
reader={entry ? (
|
||||
<ReadingPane
|
||||
binding={entry}
|
||||
context={context}
|
||||
|
||||
@@ -171,7 +171,7 @@ function placementNodes(record) {
|
||||
...rooted,
|
||||
...cases.map((item) => ({
|
||||
id: item.case_id,
|
||||
title: item.label.replaceAll("Unterakte ", "").replaceAll("Akte ", "").replaceAll(" → ", " / "),
|
||||
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,
|
||||
@@ -328,6 +328,14 @@ export function MatterDetail() {
|
||||
};
|
||||
}, [inherited?.kind, inherited?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!record || record.id !== id || !entryId) return;
|
||||
if ((record.bindings || []).some((item) => item.id === entryId)) return;
|
||||
const updated = new URLSearchParams(params);
|
||||
updated.delete("eintrag");
|
||||
setParams(updated, { replace: true });
|
||||
}, [record, id, entryId, params, setParams]);
|
||||
|
||||
useEffect(() => {
|
||||
if (entryId) return;
|
||||
restoreScroll(listRef.current, `tsumugu-scroll:${id}:${chapterId}`);
|
||||
@@ -408,10 +416,10 @@ export function MatterDetail() {
|
||||
}));
|
||||
const contexts = (record.placements || []).map((item) => ({
|
||||
id: item.case_id,
|
||||
label: item.label.replaceAll("Unterakte ", "").replaceAll("Akte ", "").replaceAll(" → ", " / "),
|
||||
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 ? caseNodes(caseTree, parentTree, id, inherited.id) : placementNodes(record);
|
||||
const nodes = caseTree && inherited ? caseNodes(caseTree, parentTree, id, inherited.id) : placementNodes(record);
|
||||
const links = [
|
||||
...(record.cross_links || []).map((item) => ({
|
||||
id: `cross-${item.id}`,
|
||||
@@ -435,7 +443,7 @@ export function MatterDetail() {
|
||||
width={width}
|
||||
structureOpen={structureOpen}
|
||||
setStructureOpen={setStructureOpen}
|
||||
hasEntry={Boolean(entryId)}
|
||||
hasEntry={Boolean(entry)}
|
||||
listRef={listRef}
|
||||
nav={(
|
||||
<StructureNavigator
|
||||
@@ -459,7 +467,7 @@ export function MatterDetail() {
|
||||
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
||||
/>
|
||||
)}
|
||||
reader={entryId ? (
|
||||
reader={entry ? (
|
||||
<ReadingPane
|
||||
binding={entry}
|
||||
context={rightsContext}
|
||||
|
||||
@@ -282,9 +282,10 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
const task = { cancel: null };
|
||||
pdf.getPage(page).then((pdfPage) => {
|
||||
if (!alive) return;
|
||||
const viewport = pdfPage.getViewport({ scale });
|
||||
const canvas = canvasRef.current;
|
||||
const context2d = canvas.getContext("2d");
|
||||
const context2d = canvas?.getContext("2d");
|
||||
if (!canvas || !context2d) return;
|
||||
const viewport = pdfPage.getViewport({ scale });
|
||||
canvas.width = viewport.width;
|
||||
canvas.height = viewport.height;
|
||||
const render = pdfPage.render({ canvasContext: context2d, viewport });
|
||||
@@ -440,16 +441,28 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
||||
const search = new URLSearchParams();
|
||||
search.set("context_kind", context.kind);
|
||||
search.set("context_id", context.id);
|
||||
await api(`/api/v1/bindings/${binding.id}?${search}`, { method: "DELETE" });
|
||||
onClose();
|
||||
onReload();
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/bindings/${binding.id}?${search}`, { method: "DELETE" });
|
||||
markDirty(false);
|
||||
onClose();
|
||||
onReload();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function destroy() {
|
||||
if (!window.confirm("Überall löschen? Alle Einbindungen verschwinden. Eine Paperless-Quelle bleibt unangetastet.")) return;
|
||||
await api(`/api/v1/elements/${element.id}/delete`, { method: "POST", body: { expected_version: element.version } });
|
||||
onClose();
|
||||
onReload();
|
||||
setError("");
|
||||
try {
|
||||
await api(`/api/v1/elements/${element.id}/delete`, { method: "POST", body: { expected_version: element.version } });
|
||||
markDirty(false);
|
||||
onClose();
|
||||
onReload();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!binding) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { NavLink, Outlet, useNavigate } from "react-router-dom";
|
||||
import { Component, useContext, useEffect, useRef, useState } from "react";
|
||||
import { NavLink, Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||
import { SessionContext } from "../session.js";
|
||||
import { Mark, NavIcon } from "./icons.jsx";
|
||||
|
||||
@@ -24,9 +24,40 @@ const MOBILE = [
|
||||
{ to: "/search", label: "Suche", short: "Suche", icon: "search" },
|
||||
];
|
||||
|
||||
class PageBoundary extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { failed: false };
|
||||
}
|
||||
|
||||
static getDerivedStateFromError() {
|
||||
return { failed: true };
|
||||
}
|
||||
|
||||
componentDidUpdate(previous) {
|
||||
if (previous.resetKey !== this.props.resetKey && this.state.failed) {
|
||||
this.setState({ failed: false });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.failed) {
|
||||
return (
|
||||
<main className="page">
|
||||
<h1>Die Ansicht ist abgebrochen.</h1>
|
||||
<p>Die Navigation bleibt verfügbar. Öffne die Seite erneut oder wechsle über das Menü.</p>
|
||||
<button type="button" onClick={() => this.setState({ failed: false })}>Erneut anzeigen</button>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
@@ -170,7 +201,9 @@ export function Shell() {
|
||||
) : null}
|
||||
</header>
|
||||
<div className="app-main">
|
||||
<Outlet />
|
||||
<PageBoundary resetKey={`${location.pathname}${location.search}`}>
|
||||
<Outlet />
|
||||
</PageBoundary>
|
||||
</div>
|
||||
<nav className="bottom-nav" aria-label="Hauptnavigation">
|
||||
{MOBILE.map((item) => (
|
||||
|
||||
@@ -541,7 +541,8 @@ export function MarkdownEditor({ value, onChange, disabled, rows = 12 }) {
|
||||
}
|
||||
|
||||
function blurb(element) {
|
||||
const raw = element.summary || element.excerpt || "";
|
||||
const raw = element?.summary || element?.excerpt || "";
|
||||
if (typeof raw !== "string") return "";
|
||||
return raw.replace(/^#{1,3}\s+/gm, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/[*`]/g, "").replace(/\s+/g, " ").trim();
|
||||
}
|
||||
|
||||
@@ -1059,19 +1060,25 @@ export function ContentBoard({
|
||||
}
|
||||
|
||||
async function removeBinding(binding, everywhere) {
|
||||
const element = binding.element;
|
||||
if (everywhere) {
|
||||
if (!window.confirm("Überall löschen? Alle Einbindungen verschwinden. Eine Paperless-Quelle bleibt unangetastet.")) return;
|
||||
await api(`/api/v1/elements/${element.id}/delete`, { method: "POST", body: { expected_version: element.version } });
|
||||
} else {
|
||||
if (!window.confirm("Aus diesem Zusammenhang entfernen? Die Unterlage bleibt an anderen Stellen erhalten.")) return;
|
||||
const action = context || (containerKind === "case" ? { kind: "case", id: containerId } : { kind: "matter", id: containerId });
|
||||
const search = new URLSearchParams();
|
||||
search.set("context_kind", action.kind);
|
||||
search.set("context_id", action.id);
|
||||
await api(`/api/v1/bindings/${binding.id}?${search}`, { method: "DELETE" });
|
||||
const element = binding?.element;
|
||||
if (!element) return;
|
||||
setError("");
|
||||
try {
|
||||
if (everywhere) {
|
||||
if (!window.confirm("Überall löschen? Alle Einbindungen verschwinden. Eine Paperless-Quelle bleibt unangetastet.")) return;
|
||||
await api(`/api/v1/elements/${element.id}/delete`, { method: "POST", body: { expected_version: element.version } });
|
||||
} else {
|
||||
if (!window.confirm("Aus diesem Zusammenhang entfernen? Die Unterlage bleibt an anderen Stellen erhalten.")) return;
|
||||
const action = context || (containerKind === "case" ? { kind: "case", id: containerId } : { kind: "matter", id: containerId });
|
||||
const search = new URLSearchParams();
|
||||
search.set("context_kind", action.kind);
|
||||
search.set("context_id", action.id);
|
||||
await api(`/api/v1/bindings/${binding.id}?${search}`, { method: "DELETE" });
|
||||
}
|
||||
await onChange();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
}
|
||||
onChange();
|
||||
}
|
||||
const orderPath = `/api/v1/${containerKind === "case" ? "cases" : "matters"}/${containerId}`;
|
||||
const orderContext = context && containerKind === "matter" ? { context } : {};
|
||||
@@ -2305,7 +2312,7 @@ export function ContentBoard({
|
||||
})}>Einträge dieses Kapitels auswählen</button>
|
||||
) : null}
|
||||
{expanded ? <ol className="preview-list">
|
||||
{section.items.map((binding, index) => {
|
||||
{section.items.filter((binding) => binding?.element).map((binding, index, rows) => {
|
||||
const element = binding.element;
|
||||
const href = itemHref(binding);
|
||||
const text = blurb(element);
|
||||
@@ -2481,7 +2488,7 @@ export function ContentBoard({
|
||||
source={source}
|
||||
chapters={chapters}
|
||||
index={index}
|
||||
lastIndex={section.items.length - 1}
|
||||
lastIndex={rows.length - 1}
|
||||
canEdit={canEdit}
|
||||
canDestroy={canDestroy}
|
||||
canSort={canSort}
|
||||
|
||||
Reference in new issue
Block a user