Aktualisiere den Ablagebaum nach dem Lösen eines Vorgangs aus einer Akte.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
07e46c77f1
commit
1d3c938def
2 files changed
+19
-4
No files matched your search
@@ -80,6 +80,17 @@ export function LibraryLayout() {
|
|||||||
}
|
}
|
||||||
}, [outlines]);
|
}, [outlines]);
|
||||||
|
|
||||||
|
// After a change elsewhere (a matter detached): fetch the lists and every outline held in memory again.
|
||||||
|
const held = useRef(outlines);
|
||||||
|
held.current = outlines;
|
||||||
|
const refreshAll = useCallback(() => {
|
||||||
|
reload();
|
||||||
|
for (const key of held.current.keys()) {
|
||||||
|
const [kind, id, contextId] = key.split(":");
|
||||||
|
loadOutline(kind, id, contextId, true);
|
||||||
|
}
|
||||||
|
}, [reload, loadOutline]);
|
||||||
|
|
||||||
// The open entry changed (a chapter added, a matter moved): fetch its outline and the lists again.
|
// The open entry changed (a chapter added, a matter moved): fetch its outline and the lists again.
|
||||||
const stamp = focus?.stamp || "";
|
const stamp = focus?.stamp || "";
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -157,6 +168,7 @@ export function LibraryLayout() {
|
|||||||
const value = {
|
const value = {
|
||||||
...data,
|
...data,
|
||||||
reload,
|
reload,
|
||||||
|
refreshAll,
|
||||||
notify,
|
notify,
|
||||||
share,
|
share,
|
||||||
unshare,
|
unshare,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { ChapterForm, FileForm, NoteForm } from "./Cases.jsx";
|
|||||||
import { ContentBoard, DateField, ObjectMenu, Placements, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, matterOpenHref, saveChapterOrder, writeChapter } from "./content.jsx";
|
import { ContentBoard, DateField, ObjectMenu, Placements, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, matterOpenHref, saveChapterOrder, writeChapter } from "./content.jsx";
|
||||||
import { ReadingPane } from "./ReadingPane.jsx";
|
import { ReadingPane } from "./ReadingPane.jsx";
|
||||||
import { Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
import { Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||||
import { useLibraryFocus } from "../library/LibraryLayout.jsx";
|
import { useLibrary, useLibraryFocus } from "../library/LibraryLayout.jsx";
|
||||||
import { outlineSignature } from "../library/library-core.js";
|
import { outlineSignature } from "../library/library-core.js";
|
||||||
import { NavIcon } from "./icons.jsx";
|
import { NavIcon } from "./icons.jsx";
|
||||||
import { ExportPackage } from "./ExportPackage.jsx";
|
import { ExportPackage } from "./ExportPackage.jsx";
|
||||||
@@ -41,6 +41,7 @@ function objectTrail(record, query) {
|
|||||||
export function MatterDetail() {
|
export function MatterDetail() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const library = useLibrary();
|
||||||
const [params, setParams] = useSearchParams();
|
const [params, setParams] = useSearchParams();
|
||||||
const inherited = pageContext(params);
|
const inherited = pageContext(params);
|
||||||
const chapterId = params.get("kapitel") || "";
|
const chapterId = params.get("kapitel") || "";
|
||||||
@@ -443,9 +444,11 @@ export function MatterDetail() {
|
|||||||
<Modal open={modal === "unlink"} title="Aus Akte lösen" onClose={() => setModal("")}>
|
<Modal open={modal === "unlink"} title="Aus Akte lösen" onClose={() => setModal("")}>
|
||||||
<UnlinkMatter
|
<UnlinkMatter
|
||||||
title={record.title}
|
title={record.title}
|
||||||
links={record.case_links || []}
|
links={[...(record.case_links || [])].sort((a, b) => Number(b.case_id === inherited?.id) - Number(a.case_id === inherited?.id))}
|
||||||
|
currentId={inherited?.kind === "case" ? inherited.id : ""}
|
||||||
onDone={(link) => {
|
onDone={(link) => {
|
||||||
setModal("");
|
setModal("");
|
||||||
|
library?.refreshAll();
|
||||||
if (inherited?.kind === "case" && inherited.id === link.case_id) navigate(`/matters/${id}`, { replace: true });
|
if (inherited?.kind === "case" && inherited.id === link.case_id) navigate(`/matters/${id}`, { replace: true });
|
||||||
else load();
|
else load();
|
||||||
}}
|
}}
|
||||||
@@ -465,7 +468,7 @@ export function MatterDetail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detaches the matter from one case. The matter itself and its content stay.
|
// Detaches the matter from one case. The matter itself and its content stay.
|
||||||
function UnlinkMatter({ title, links, onDone }) {
|
function UnlinkMatter({ title, links, currentId = "", onDone }) {
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const [pending, setPending] = useState("");
|
const [pending, setPending] = useState("");
|
||||||
|
|
||||||
@@ -487,7 +490,7 @@ function UnlinkMatter({ title, links, onDone }) {
|
|||||||
<ErrorNote error={error} />
|
<ErrorNote error={error} />
|
||||||
{links.map((link) => (
|
{links.map((link) => (
|
||||||
<div key={link.id} className="inline-actions">
|
<div key={link.id} className="inline-actions">
|
||||||
<span>Akte {link.title}</span>
|
<span>Akte {link.title}{link.case_id === currentId ? " (hier geöffnet)" : ""}</span>
|
||||||
<button type="button" className="quiet" disabled={Boolean(pending)} onClick={() => unlink(link)}>
|
<button type="button" className="quiet" disabled={Boolean(pending)} onClick={() => unlink(link)}>
|
||||||
{pending === link.id ? "Wird gelöst …" : "Aus dieser Akte lösen"}
|
{pending === link.id ? "Wird gelöst …" : "Aus dieser Akte lösen"}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in new issue
Block a user