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) {
|
function mergedCaseItems(record, direction, caseId) {
|
||||||
const rows = [
|
const rows = [
|
||||||
...(record.bindings || []).map((binding) => ({
|
...(record.bindings || []).filter((binding) => binding?.element).map((binding) => ({
|
||||||
...binding,
|
...binding,
|
||||||
origin: chapterOrigin("Direkt in dieser Akte", record.chapters, binding.chapter_id),
|
origin: chapterOrigin("Direkt in dieser Akte", record.chapters, binding.chapter_id),
|
||||||
readerHref: `/cases/${caseId}?eintrag=${binding.id}${binding.chapter_id ? `&kapitel=${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,
|
...binding,
|
||||||
origin: chapterOrigin(matterOrigin(group), group.chapters, binding.chapter_id),
|
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}` : ""}`,
|
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]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
if (entryId) return;
|
if (entryId) return;
|
||||||
restoreScroll(listRef.current, `tsumugu-scroll:case:${id}:${chapterId}:${overview ? "over" : "direct"}`);
|
restoreScroll(listRef.current, `tsumugu-scroll:case:${id}:${chapterId}:${overview ? "over" : "direct"}`);
|
||||||
@@ -486,7 +494,7 @@ export function CaseDetail() {
|
|||||||
width={width}
|
width={width}
|
||||||
structureOpen={structureOpen}
|
structureOpen={structureOpen}
|
||||||
setStructureOpen={setStructureOpen}
|
setStructureOpen={setStructureOpen}
|
||||||
hasEntry={Boolean(entryId) && !overview}
|
hasEntry={Boolean(entry) && !overview}
|
||||||
listRef={listRef}
|
listRef={listRef}
|
||||||
nav={(
|
nav={(
|
||||||
<StructureNavigator
|
<StructureNavigator
|
||||||
@@ -511,7 +519,7 @@ export function CaseDetail() {
|
|||||||
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
reader={entryId && !overview ? (
|
reader={entry ? (
|
||||||
<ReadingPane
|
<ReadingPane
|
||||||
binding={entry}
|
binding={entry}
|
||||||
context={context}
|
context={context}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ function placementNodes(record) {
|
|||||||
...rooted,
|
...rooted,
|
||||||
...cases.map((item) => ({
|
...cases.map((item) => ({
|
||||||
id: item.case_id,
|
id: item.case_id,
|
||||||
title: item.label.replaceAll("Unterakte ", "").replaceAll("Akte ", "").replaceAll(" → ", " / "),
|
title: String(item.label || "Akte").replaceAll("Unterakte ", "").replaceAll("Akte ", "").replaceAll(" → ", " / "),
|
||||||
kind: "Akte",
|
kind: "Akte",
|
||||||
href: `/matters/${record.id}?context_kind=case&context_id=${item.case_id}`,
|
href: `/matters/${record.id}?context_kind=case&context_id=${item.case_id}`,
|
||||||
current: false,
|
current: false,
|
||||||
@@ -328,6 +328,14 @@ export function MatterDetail() {
|
|||||||
};
|
};
|
||||||
}, [inherited?.kind, inherited?.id]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
if (entryId) return;
|
if (entryId) return;
|
||||||
restoreScroll(listRef.current, `tsumugu-scroll:${id}:${chapterId}`);
|
restoreScroll(listRef.current, `tsumugu-scroll:${id}:${chapterId}`);
|
||||||
@@ -408,10 +416,10 @@ export function MatterDetail() {
|
|||||||
}));
|
}));
|
||||||
const contexts = (record.placements || []).map((item) => ({
|
const contexts = (record.placements || []).map((item) => ({
|
||||||
id: item.case_id,
|
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 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 = [
|
const links = [
|
||||||
...(record.cross_links || []).map((item) => ({
|
...(record.cross_links || []).map((item) => ({
|
||||||
id: `cross-${item.id}`,
|
id: `cross-${item.id}`,
|
||||||
@@ -435,7 +443,7 @@ export function MatterDetail() {
|
|||||||
width={width}
|
width={width}
|
||||||
structureOpen={structureOpen}
|
structureOpen={structureOpen}
|
||||||
setStructureOpen={setStructureOpen}
|
setStructureOpen={setStructureOpen}
|
||||||
hasEntry={Boolean(entryId)}
|
hasEntry={Boolean(entry)}
|
||||||
listRef={listRef}
|
listRef={listRef}
|
||||||
nav={(
|
nav={(
|
||||||
<StructureNavigator
|
<StructureNavigator
|
||||||
@@ -459,7 +467,7 @@ export function MatterDetail() {
|
|||||||
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
onClose={width < 1500 ? () => setStructureOpen(false) : null}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
reader={entryId ? (
|
reader={entry ? (
|
||||||
<ReadingPane
|
<ReadingPane
|
||||||
binding={entry}
|
binding={entry}
|
||||||
context={rightsContext}
|
context={rightsContext}
|
||||||
|
|||||||
@@ -282,9 +282,10 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
|||||||
const task = { cancel: null };
|
const task = { cancel: null };
|
||||||
pdf.getPage(page).then((pdfPage) => {
|
pdf.getPage(page).then((pdfPage) => {
|
||||||
if (!alive) return;
|
if (!alive) return;
|
||||||
const viewport = pdfPage.getViewport({ scale });
|
|
||||||
const canvas = canvasRef.current;
|
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.width = viewport.width;
|
||||||
canvas.height = viewport.height;
|
canvas.height = viewport.height;
|
||||||
const render = pdfPage.render({ canvasContext: context2d, viewport });
|
const render = pdfPage.render({ canvasContext: context2d, viewport });
|
||||||
@@ -440,16 +441,28 @@ export function ReadingPane({ binding, context, backLabel, onClose, onReload, ca
|
|||||||
const search = new URLSearchParams();
|
const search = new URLSearchParams();
|
||||||
search.set("context_kind", context.kind);
|
search.set("context_kind", context.kind);
|
||||||
search.set("context_id", context.id);
|
search.set("context_id", context.id);
|
||||||
await api(`/api/v1/bindings/${binding.id}?${search}`, { method: "DELETE" });
|
setError("");
|
||||||
onClose();
|
try {
|
||||||
onReload();
|
await api(`/api/v1/bindings/${binding.id}?${search}`, { method: "DELETE" });
|
||||||
|
markDirty(false);
|
||||||
|
onClose();
|
||||||
|
onReload();
|
||||||
|
} catch (err) {
|
||||||
|
setError(err.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function destroy() {
|
async function destroy() {
|
||||||
if (!window.confirm("Überall löschen? Alle Einbindungen verschwinden. Eine Paperless-Quelle bleibt unangetastet.")) return;
|
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 } });
|
setError("");
|
||||||
onClose();
|
try {
|
||||||
onReload();
|
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) {
|
if (!binding) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useContext, useEffect, useRef, useState } from "react";
|
import { Component, useContext, useEffect, useRef, useState } from "react";
|
||||||
import { NavLink, Outlet, useNavigate } from "react-router-dom";
|
import { NavLink, Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||||
import { SessionContext } from "../session.js";
|
import { SessionContext } from "../session.js";
|
||||||
import { Mark, NavIcon } from "./icons.jsx";
|
import { Mark, NavIcon } from "./icons.jsx";
|
||||||
|
|
||||||
@@ -24,9 +24,40 @@ const MOBILE = [
|
|||||||
{ to: "/search", label: "Suche", short: "Suche", icon: "search" },
|
{ 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() {
|
export function Shell() {
|
||||||
const { session, logout } = useContext(SessionContext);
|
const { session, logout } = useContext(SessionContext);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
const [expanded, setExpanded] = useState(() => {
|
const [expanded, setExpanded] = useState(() => {
|
||||||
try {
|
try {
|
||||||
return localStorage.getItem(NAV_KEY) !== "0";
|
return localStorage.getItem(NAV_KEY) !== "0";
|
||||||
@@ -170,7 +201,9 @@ export function Shell() {
|
|||||||
) : null}
|
) : null}
|
||||||
</header>
|
</header>
|
||||||
<div className="app-main">
|
<div className="app-main">
|
||||||
<Outlet />
|
<PageBoundary resetKey={`${location.pathname}${location.search}`}>
|
||||||
|
<Outlet />
|
||||||
|
</PageBoundary>
|
||||||
</div>
|
</div>
|
||||||
<nav className="bottom-nav" aria-label="Hauptnavigation">
|
<nav className="bottom-nav" aria-label="Hauptnavigation">
|
||||||
{MOBILE.map((item) => (
|
{MOBILE.map((item) => (
|
||||||
|
|||||||
@@ -541,7 +541,8 @@ export function MarkdownEditor({ value, onChange, disabled, rows = 12 }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function blurb(element) {
|
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();
|
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) {
|
async function removeBinding(binding, everywhere) {
|
||||||
const element = binding.element;
|
const element = binding?.element;
|
||||||
if (everywhere) {
|
if (!element) return;
|
||||||
if (!window.confirm("Überall löschen? Alle Einbindungen verschwinden. Eine Paperless-Quelle bleibt unangetastet.")) return;
|
setError("");
|
||||||
await api(`/api/v1/elements/${element.id}/delete`, { method: "POST", body: { expected_version: element.version } });
|
try {
|
||||||
} else {
|
if (everywhere) {
|
||||||
if (!window.confirm("Aus diesem Zusammenhang entfernen? Die Unterlage bleibt an anderen Stellen erhalten.")) return;
|
if (!window.confirm("Überall löschen? Alle Einbindungen verschwinden. Eine Paperless-Quelle bleibt unangetastet.")) return;
|
||||||
const action = context || (containerKind === "case" ? { kind: "case", id: containerId } : { kind: "matter", id: containerId });
|
await api(`/api/v1/elements/${element.id}/delete`, { method: "POST", body: { expected_version: element.version } });
|
||||||
const search = new URLSearchParams();
|
} else {
|
||||||
search.set("context_kind", action.kind);
|
if (!window.confirm("Aus diesem Zusammenhang entfernen? Die Unterlage bleibt an anderen Stellen erhalten.")) return;
|
||||||
search.set("context_id", action.id);
|
const action = context || (containerKind === "case" ? { kind: "case", id: containerId } : { kind: "matter", id: containerId });
|
||||||
await api(`/api/v1/bindings/${binding.id}?${search}`, { method: "DELETE" });
|
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 orderPath = `/api/v1/${containerKind === "case" ? "cases" : "matters"}/${containerId}`;
|
||||||
const orderContext = context && containerKind === "matter" ? { context } : {};
|
const orderContext = context && containerKind === "matter" ? { context } : {};
|
||||||
@@ -2305,7 +2312,7 @@ export function ContentBoard({
|
|||||||
})}>Einträge dieses Kapitels auswählen</button>
|
})}>Einträge dieses Kapitels auswählen</button>
|
||||||
) : null}
|
) : null}
|
||||||
{expanded ? <ol className="preview-list">
|
{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 element = binding.element;
|
||||||
const href = itemHref(binding);
|
const href = itemHref(binding);
|
||||||
const text = blurb(element);
|
const text = blurb(element);
|
||||||
@@ -2481,7 +2488,7 @@ export function ContentBoard({
|
|||||||
source={source}
|
source={source}
|
||||||
chapters={chapters}
|
chapters={chapters}
|
||||||
index={index}
|
index={index}
|
||||||
lastIndex={section.items.length - 1}
|
lastIndex={rows.length - 1}
|
||||||
canEdit={canEdit}
|
canEdit={canEdit}
|
||||||
canDestroy={canDestroy}
|
canDestroy={canDestroy}
|
||||||
canSort={canSort}
|
canSort={canSort}
|
||||||
|
|||||||
Reference in new issue
Block a user