Gib ein Uebergabepaket aus der bestaetigten Auswahl aus.
Die Dev-Umgebung soll die hierarchische Auswahl und das Paket pruefen koennen. Vorhandene Symbolaktionen der Inhaltszeilen bleiben im selben Stand. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7626c56f3d
commit
27cde035e8
21 files changed
+2427
-54
No files matched your search
@@ -8,7 +8,7 @@ import { ErrorNote, ShareBox } from "./widgets.jsx";
|
||||
import { ContentBoard, DirectionChoice, MarkdownEditor, ObjectMenu, OrderChoice, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, saveChapterOrder, writeSelection } from "./content.jsx";
|
||||
import { ReadingPane } from "./ReadingPane.jsx";
|
||||
import { StructureNavigator, Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
import { IconButton, NavIcon } from "./icons.jsx";
|
||||
|
||||
export function CaseList() {
|
||||
const { session } = useContext(SessionContext);
|
||||
@@ -519,6 +519,13 @@ export function CaseDetail() {
|
||||
<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>
|
||||
{record.rights.edit ? (
|
||||
<span className="record-tools">
|
||||
<IconButton name="pencil" label="Umbenennen" onClick={renameCase} />
|
||||
<IconButton name={record.status === "closed" ? "restore" : "archive"} label={record.status === "closed" ? "Wieder öffnen" : "Archivieren"} onClick={archiveCase} />
|
||||
<IconButton name="trash" label="Löschen" onClick={deleteCase} />
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="page-actions">
|
||||
@@ -533,9 +540,6 @@ export function CaseDetail() {
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("assign")}>Vorhandenen Vorgang zuordnen</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={() => setModal("subcase")}>Unterakte anlegen</button> : null}
|
||||
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={renameCase}>Umbenennen</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={archiveCase}>{record.status === "closed" ? "Wieder öffnen" : "Archivieren"}</button> : null}
|
||||
{record.rights.edit ? <button type="button" className="quiet" onClick={deleteCase}>Löschen</button> : null}
|
||||
</ObjectMenu>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { api, downloadPost } from "../api.js";
|
||||
|
||||
function leafIds(node, into = []) {
|
||||
if (!node) return into;
|
||||
if (node.kind === "binding" || node.kind === "annotation") into.push(node.id);
|
||||
(node.children || []).forEach((child) => leafIds(child, into));
|
||||
return into;
|
||||
}
|
||||
|
||||
function checkState(node, selected) {
|
||||
const ids = leafIds(node);
|
||||
if (!ids.length) return "off";
|
||||
const count = ids.filter((id) => selected.has(id)).length;
|
||||
if (count === 0) return "off";
|
||||
if (count === ids.length) return "on";
|
||||
return "mixed";
|
||||
}
|
||||
|
||||
function withNode(node, selected, on) {
|
||||
const next = new Set(selected);
|
||||
leafIds(node).forEach((id) => {
|
||||
if (on) next.add(id);
|
||||
else next.delete(id);
|
||||
});
|
||||
return next;
|
||||
}
|
||||
|
||||
function initialSelection(node) {
|
||||
const next = new Set();
|
||||
function visit(current) {
|
||||
if ((current.kind === "binding" || current.kind === "annotation") && current.exportable) {
|
||||
next.add(current.id);
|
||||
}
|
||||
(current.children || []).forEach(visit);
|
||||
}
|
||||
visit(node);
|
||||
return next;
|
||||
}
|
||||
|
||||
function CheckBox({ state, disabled, onChange, label }) {
|
||||
const ref = useRef(null);
|
||||
useEffect(() => {
|
||||
if (ref.current) ref.current.indeterminate = state === "mixed";
|
||||
}, [state]);
|
||||
return (
|
||||
<input
|
||||
ref={ref}
|
||||
type="checkbox"
|
||||
checked={state === "on"}
|
||||
disabled={disabled}
|
||||
aria-checked={state === "mixed" ? "mixed" : state === "on"}
|
||||
aria-label={label}
|
||||
onChange={onChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function TreeRows({ node, depth, selected, onToggle }) {
|
||||
const state = checkState(node, selected);
|
||||
const ids = leafIds(node);
|
||||
return (
|
||||
<>
|
||||
<label className="export-tree__row" style={{ paddingLeft: `${depth * 16}px` }}>
|
||||
<CheckBox
|
||||
state={state}
|
||||
disabled={!ids.length}
|
||||
label={node.title}
|
||||
onChange={() => onToggle(node, state !== "on")}
|
||||
/>
|
||||
<span>
|
||||
<strong>{node.title}</strong>
|
||||
{node.label ? <span className="muted"> {node.label}</span> : null}
|
||||
{node.reason ? <span className="export-reason"> {node.reason}</span> : null}
|
||||
</span>
|
||||
</label>
|
||||
{(node.children || []).map((child) => (
|
||||
<TreeRows key={child.id} node={child} depth={depth + 1} selected={selected} onToggle={onToggle} />
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function ExportPackage({ matterId, context, onClose }) {
|
||||
const [tree, setTree] = useState(null);
|
||||
const [selected, setSelected] = useState(() => new Set());
|
||||
const [review, setReview] = useState(null);
|
||||
const [assignments, setAssignments] = useState({});
|
||||
const [error, setError] = useState("");
|
||||
const [pending, setPending] = useState(false);
|
||||
const [downloaded, setDownloaded] = useState(false);
|
||||
const query = context?.kind && context?.id ? `?context_kind=${context.kind}&context_id=${context.id}` : "";
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
api(`/api/v1/matters/${matterId}/export-tree${query}`).then((payload) => {
|
||||
if (!alive) return;
|
||||
setTree(payload.tree);
|
||||
setSelected(initialSelection(payload.tree));
|
||||
}).catch((err) => {
|
||||
if (alive) setError(err.message);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [matterId, query]);
|
||||
|
||||
function toggle(node, on) {
|
||||
setSelected((current) => withNode(node, current, on));
|
||||
setReview(null);
|
||||
setDownloaded(false);
|
||||
}
|
||||
|
||||
async function examine() {
|
||||
setError("");
|
||||
setPending(true);
|
||||
setDownloaded(false);
|
||||
try {
|
||||
const payload = await api(`/api/v1/matters/${matterId}/export/review`, {
|
||||
method: "POST",
|
||||
body: {
|
||||
context: context || null,
|
||||
selected: [...selected],
|
||||
assignments,
|
||||
},
|
||||
});
|
||||
setReview(payload);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function download() {
|
||||
setError("");
|
||||
setPending(true);
|
||||
try {
|
||||
await downloadPost(`/api/v1/matters/${matterId}/export`, {
|
||||
context: context || null,
|
||||
selected: [...selected],
|
||||
assignments,
|
||||
}, "uebergabe.zip");
|
||||
setDownloaded(true);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}
|
||||
|
||||
const ambiguous = (review?.issues || []).filter((issue) => issue.choices?.length);
|
||||
|
||||
return (
|
||||
<div className="stack export-package">
|
||||
<p className="muted">
|
||||
Die Auswahl gilt für diese Ausgabe. Ein bereits heruntergeladenes Paket verändert sich nicht,
|
||||
wenn danach Inhalte geändert oder ergänzt werden.
|
||||
</p>
|
||||
{error ? <p className="export-reason">{error}</p> : null}
|
||||
{!tree ? <p className="muted">Auswahl wird geladen …</p> : null}
|
||||
{tree && !review ? (
|
||||
<>
|
||||
<div className="export-tree" role="group" aria-label="Exportauswahl">
|
||||
<TreeRows node={tree} depth={0} selected={selected} onToggle={toggle} />
|
||||
</div>
|
||||
<div className="export-actions">
|
||||
<button type="button" onClick={examine} disabled={pending || selected.size === 0}>
|
||||
{pending ? "Prüfung läuft …" : "Auswahl prüfen"}
|
||||
</button>
|
||||
<button type="button" className="quiet" onClick={onClose}>Abbrechen</button>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
{review ? (
|
||||
<>
|
||||
<div className="export-review">
|
||||
{review.issues?.length ? review.issues.map((issue) => (
|
||||
<p key={`${issue.node_id}-${issue.code}`} className="export-reason">
|
||||
{issue.title}: {issue.message}
|
||||
</p>
|
||||
)) : <p>Die Auswahl ist vollständig und kann ausgegeben werden.</p>}
|
||||
{review.notices?.map((notice) => (
|
||||
<p key={`${notice.node_id}-${notice.message}`} className="export-notice">{notice.message}</p>
|
||||
))}
|
||||
{ambiguous.map((issue) => (
|
||||
<label key={`${issue.node_id}-choice`}>
|
||||
Zugang für {issue.title}
|
||||
<select
|
||||
value={assignments[issue.node_id] || ""}
|
||||
onChange={(event) => {
|
||||
setAssignments((current) => ({ ...current, [issue.node_id]: event.target.value }));
|
||||
setReview(null);
|
||||
}}
|
||||
>
|
||||
<option value="">Zugang wählen</option>
|
||||
{issue.choices.map((choice) => (
|
||||
<option key={choice.id} value={choice.id}>{choice.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
<ul className="export-entries">
|
||||
{(review.entries || []).map((entry) => (
|
||||
<li key={entry.node_id}>
|
||||
{entry.kind_label}: {entry.title}
|
||||
{entry.path ? <span className="muted"> · {entry.path}</span> : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
{downloaded ? (
|
||||
<p className="muted">Das Paket wurde heruntergeladen. Es hält den Stand dieses Zeitpunkts fest.</p>
|
||||
) : null}
|
||||
<div className="export-actions">
|
||||
<button type="button" className="quiet" onClick={() => setReview(null)}>Zurück zur Auswahl</button>
|
||||
{review.ready ? (
|
||||
<button type="button" onClick={download} disabled={pending}>
|
||||
{pending ? "Paket wird erzeugt …" : "Paket herunterladen"}
|
||||
</button>
|
||||
) : (
|
||||
<button type="button" onClick={examine} disabled={pending}>Erneut prüfen</button>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import { ChapterForm, FileForm, NoteForm } from "./Cases.jsx";
|
||||
import { ContentBoard, ObjectMenu, Placements, RecordTree, SurfaceView, TargetLine, Trail, WorkLists, WorkSwitch, matterOpenHref, saveChapterOrder, writeChapter } from "./content.jsx";
|
||||
import { ReadingPane } from "./ReadingPane.jsx";
|
||||
import { StructureNavigator, Workspace, rememberScroll, restoreScroll, useWorkspaceLayout } from "./workspace.jsx";
|
||||
import { NavIcon } from "./icons.jsx";
|
||||
import { IconButton, NavIcon } from "./icons.jsx";
|
||||
import { ExportPackage } from "./ExportPackage.jsx";
|
||||
|
||||
function pageContext(params) {
|
||||
const kind = params.get("context_kind");
|
||||
@@ -466,10 +467,19 @@ export function MatterDetail() {
|
||||
<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>
|
||||
{canEdit ? (
|
||||
<span className="record-tools">
|
||||
<IconButton name="pencil" label="Umbenennen" onClick={renameMatter} />
|
||||
<IconButton name={record.status === "closed" ? "restore" : "archive"} label={record.status === "closed" ? "Wieder öffnen" : "Archivieren"} onClick={archiveMatter} />
|
||||
<IconButton name="move" label="Verschieben" onClick={() => setModal("move")} />
|
||||
<IconButton name="trash" label="Löschen" onClick={deleteMatter} />
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="page-actions">
|
||||
{width < 1500 ? <button type="button" className="quiet" onClick={() => setStructureOpen(true)}>Struktur</button> : null}
|
||||
<button type="button" className="quiet" onClick={() => setModal("export")}>Übergabepaket</button>
|
||||
{canEdit ? (
|
||||
<button type="button" className="desktop-add" onClick={() => setModal("add")}>
|
||||
<NavIcon name="plus" /> Inhalt hinzufügen
|
||||
@@ -479,10 +489,6 @@ export function MatterDetail() {
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("submatter")}>Teilvorgang anlegen</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("cross")}>Querverweis</button> : null}
|
||||
{record.rights.share || record.is_owner ? <button type="button" className="quiet" onClick={() => setModal("share")}>Teilen</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={renameMatter}>Umbenennen</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={archiveMatter}>{record.status === "closed" ? "Wieder öffnen" : "Archivieren"}</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={() => setModal("move")}>Verschieben</button> : null}
|
||||
{canEdit ? <button type="button" className="quiet" onClick={deleteMatter}>Löschen</button> : null}
|
||||
</ObjectMenu>
|
||||
</div>
|
||||
</header>
|
||||
@@ -538,6 +544,9 @@ export function MatterDetail() {
|
||||
</button>
|
||||
) : null}
|
||||
</Workspace>
|
||||
<Modal open={modal === "export"} title="Übergabepaket erstellen" wide onClose={() => setModal("")}>
|
||||
<ExportPackage matterId={id} context={rightsContext} onClose={() => setModal("")} />
|
||||
</Modal>
|
||||
<Modal open={modal === "work"} title="Aufgabe oder Frist" onClose={() => setModal("")}>
|
||||
<WorkForms matterId={id} context={inherited} deadlines={record.deadlines || []} onChange={() => { setModal(""); load(); }} />
|
||||
</Modal>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Link } from "react-router-dom";
|
||||
import { api, fetchFile, fetchPaperless } from "../api.js";
|
||||
import { contentSourceSymbol, contentSymbol } from "../content-symbol.mjs";
|
||||
import { MarkdownView } from "../markdown.jsx";
|
||||
import { IconButton, NavIcon } from "./icons.jsx";
|
||||
import { Modal } from "./Modal.jsx";
|
||||
import { ErrorNote } from "./widgets.jsx";
|
||||
|
||||
@@ -933,8 +934,8 @@ export function ContentBoard({
|
||||
<h3 className="chapter-title">{section.title}</h3>
|
||||
{canEdit && section.id !== "loose" ? (
|
||||
<span className="chapter-menu">
|
||||
<button type="button" className="quiet" onClick={() => renameChapter(section)}>Umbenennen</button>
|
||||
<button type="button" className="quiet" onClick={() => removeChapter(section)}>Löschen</button>
|
||||
<IconButton name="pencil" label={`Kapitel ${section.title} umbenennen`} onClick={() => renameChapter(section)} />
|
||||
<IconButton name="trash" label={`Kapitel ${section.title} löschen`} onClick={() => removeChapter(section)} />
|
||||
</span>
|
||||
) : null}
|
||||
{section.id !== "loose" ? (
|
||||
@@ -955,8 +956,8 @@ export function ContentBoard({
|
||||
) : null}
|
||||
{movable ? (
|
||||
<span className="chapter-move">
|
||||
<button type="button" className="quiet" aria-label={`${section.title} nach oben`} disabled={pending || chapters[0]?.id === section.id} onClick={() => moveChapter(section.id, -1)}>Nach oben</button>
|
||||
<button type="button" className="quiet" aria-label={`${section.title} nach unten`} disabled={pending || chapters[chapters.length - 1]?.id === section.id} onClick={() => moveChapter(section.id, 1)}>Nach unten</button>
|
||||
<IconButton name="up" label={`${section.title} nach oben`} disabled={pending || chapters[0]?.id === section.id} onClick={() => moveChapter(section.id, -1)} />
|
||||
<IconButton name="down" label={`${section.title} nach unten`} disabled={pending || chapters[chapters.length - 1]?.id === section.id} onClick={() => moveChapter(section.id, 1)} />
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -1026,7 +1027,7 @@ export function ContentBoard({
|
||||
<div className="preview-row__actions">
|
||||
{canEdit ? (
|
||||
<details className="row-menu">
|
||||
<summary>Bezug</summary>
|
||||
<summary aria-label="Bezug" title="Bezug"><NavIcon name="link" /></summary>
|
||||
<label>
|
||||
Bezug auf
|
||||
<select value="" disabled={pending} onChange={(event) => setBezug(element.id, event.target.value)}>
|
||||
@@ -1047,21 +1048,20 @@ export function ContentBoard({
|
||||
) : null}
|
||||
{canEdit ? (
|
||||
<details className="row-menu">
|
||||
<summary>Entfernen</summary>
|
||||
<summary aria-label="Entfernen" title="Entfernen"><NavIcon name="trash" /></summary>
|
||||
<button type="button" onClick={() => removeBinding(binding, false)}>Aus diesem Zusammenhang entfernen</button>
|
||||
{canDestroy ? <button type="button" className="danger" onClick={() => removeBinding(binding, true)}>Überall löschen</button> : null}
|
||||
</details>
|
||||
) : null}
|
||||
{canSort && custom ? (
|
||||
<details className="row-menu">
|
||||
<summary>Reihenfolge</summary>
|
||||
<button type="button" aria-label={`${element.title} nach oben`} disabled={pending || index === 0} onClick={() => move(binding.id, -1)}>Nach oben</button>
|
||||
<button type="button" aria-label={`${element.title} nach unten`} disabled={pending || index === section.items.length - 1} onClick={() => move(binding.id, 1)}>Nach unten</button>
|
||||
</details>
|
||||
<span className="chapter-move">
|
||||
<IconButton name="up" label={`${element.title} nach oben`} disabled={pending || index === 0} onClick={() => move(binding.id, -1)} />
|
||||
<IconButton name="down" label={`${element.title} nach unten`} disabled={pending || index === section.items.length - 1} onClick={() => move(binding.id, 1)} />
|
||||
</span>
|
||||
) : null}
|
||||
{canSort && chapters.length ? (
|
||||
<details className="row-menu">
|
||||
<summary>In Kapitel einordnen</summary>
|
||||
<summary aria-label="In Kapitel einordnen" title="In Kapitel einordnen"><NavIcon name="chapter" /></summary>
|
||||
<label>
|
||||
Kapitel
|
||||
<select value={binding.chapter_id || ""} disabled={pending} onChange={(event) => placeChapter(binding.id, event.target.value)}>
|
||||
|
||||
@@ -28,9 +28,24 @@ export function NavIcon({ name }) {
|
||||
if (name === "link") return <svg {...common}><path d="M10 13a5 5 0 0 0 7.1.1l1.4-1.5a5 5 0 0 0-7.1-7.1L10 6" /><path d="M14 11a5 5 0 0 0-7.1-.1L5.5 12.4a5 5 0 0 0 7.1 7.1L14 18" /></svg>;
|
||||
if (name === "chapter") return <svg {...common}><path d="M7 4.5h8.5a2 2 0 0 1 2 2V20l-6.5-3L4.5 20V6.5a2 2 0 0 1 2-2z" /></svg>;
|
||||
if (name === "contents") return <svg {...common}><path d="M5 6h14M5 12h14M5 18h10" /></svg>;
|
||||
if (name === "pencil") return <svg {...common}><path d="M12 20h9" /><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4z" /></svg>;
|
||||
if (name === "trash") return <svg {...common}><path d="M4 7h16" /><path d="M9 7V5h6v2" /><path d="M6 7l1 13h10l1-13" /></svg>;
|
||||
if (name === "archive") return <svg {...common}><rect x="3" y="4" width="18" height="5" rx="1" /><path d="M5 9v10h14V9" /><path d="M10 13h4" /></svg>;
|
||||
if (name === "restore") return <svg {...common}><rect x="3" y="4" width="18" height="5" rx="1" /><path d="M5 9v10h14V9" /><path d="M12 17V11" /><path d="m9 14 3-3 3 3" /></svg>;
|
||||
if (name === "move") return <svg {...common}><path d="M8 7H5v12h12v-3" /><path d="M10 14 19 5" /><path d="M13 5h6v6" /></svg>;
|
||||
if (name === "up") return <svg {...common}><path d="M12 19V5" /><path d="m6 11 6-6 6 6" /></svg>;
|
||||
if (name === "down") return <svg {...common}><path d="M12 5v14" /><path d="m6 13 6 6 6-6" /></svg>;
|
||||
return <svg {...common}><circle cx="12" cy="12" r="8" /></svg>;
|
||||
}
|
||||
|
||||
export function IconButton({ name, label, onClick, disabled = false }) {
|
||||
return (
|
||||
<button type="button" className="icon-button icon-button--compact" aria-label={label} title={label} disabled={disabled} onClick={onClick}>
|
||||
<NavIcon name={name} />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export function Mark({ size = 40, motion = "none", onIntroComplete, className = "" }) {
|
||||
return (
|
||||
<JinkendoMark
|
||||
|
||||
Reference in new issue
Block a user