Schliesse das Ablegen an der Markierung ab und halte Anlagen und Belege getrennt, damit der Dialog erscheint und zugeordnete Unterlagen im Uebergabepaket nur beim Schreiben stehen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
be027a1025
commit
9f5327f3be
5 files changed
+457
-234
No files matched your search
@@ -272,6 +272,8 @@ def _matter_node(conn, actor, matter, page: Ctx, root: bool) -> ExportNode:
|
||||
children: list[ExportNode] = []
|
||||
children.extend(_chapter_nodes(conn, actor, page, chapters, grouped))
|
||||
for binding in grouped.get(None, []):
|
||||
if not _stands_in_chapter(binding):
|
||||
continue
|
||||
children.append(_binding_node(conn, actor, binding, page))
|
||||
rows = conn.execute(
|
||||
"SELECT * FROM matters WHERE parent_matter_id = %s AND deleted_at IS NULL ORDER BY title, id",
|
||||
@@ -293,6 +295,16 @@ def _matter_node(conn, actor, matter, page: Ctx, root: bool) -> ExportNode:
|
||||
)
|
||||
|
||||
|
||||
def _stands_in_chapter(binding: dict) -> bool:
|
||||
"""A folded attachment or receipt stays under its letter, not as another chapter row."""
|
||||
pack = binding.get("correspondence") or {}
|
||||
if pack.get("fold") in {"attachment", "evidence"}:
|
||||
return False
|
||||
if pack.get("hosts"):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _chapter_nodes(conn, actor, page, chapters: list[dict], grouped: dict[str | None, list]) -> list[ExportNode]:
|
||||
by_parent: dict[str | None, list[dict]] = {}
|
||||
for chapter in chapters:
|
||||
@@ -305,6 +317,8 @@ def _chapter_nodes(conn, actor, page, chapters: list[dict], grouped: dict[str |
|
||||
nested = build(chapter["id"], chapter_path)
|
||||
items = []
|
||||
for item in grouped.get(chapter["id"], []):
|
||||
if not _stands_in_chapter(item):
|
||||
continue
|
||||
node = _binding_node(conn, actor, item, page)
|
||||
node.relation = f"Kapitel: {chapter_path}"
|
||||
items.append(node)
|
||||
|
||||
@@ -311,6 +311,11 @@ def test_dispatch_keeps_the_secured_stand_and_distinct_mail_parts(client, db, mo
|
||||
assert uses == 3
|
||||
hidden = _detail(ada, matter["id"])
|
||||
assert _binding(hidden, "Gesendete Nachricht")["correspondence"]["fold"] == "evidence"
|
||||
placed = list(_walk(ada.request("GET", f"/api/v1/matters/{matter['id']}/export-tree")["tree"]))
|
||||
assert not any(node["kind"] == "binding" and node["title"] in {"Rechnung 2023", "Gesendete Nachricht"} for node in placed)
|
||||
assert sum(1 for node in placed if node["kind"] == "attachment" and node["title"] == "Rechnung 2023") == 1
|
||||
assert any(node["kind"] == "dispatch_item" and node["title"] == "Rechnung 2023" for node in placed)
|
||||
assert any(node["kind"] == "evidence" and node["title"] == "Gesendete Nachricht" for node in placed)
|
||||
ada.request(
|
||||
"PATCH",
|
||||
f"/api/v1/bindings/{_binding(hidden, 'Gesendete Nachricht')['id']}/fold",
|
||||
|
||||
+113
-82
@@ -1099,14 +1099,17 @@ export function ContentBoard({
|
||||
const carried = carryRef.current;
|
||||
if (carried) {
|
||||
event.preventDefault();
|
||||
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
||||
const useId = useDropId(event.target);
|
||||
if (useId && useId !== carried.bindingId) setIndicator({ kind: "use", bindingId: useId });
|
||||
carried.useBindingId = useId && useId !== carried.bindingId ? useId : "";
|
||||
if (carried.useBindingId) setIndicator({ kind: "use", bindingId: carried.useBindingId });
|
||||
else setIndicator(null);
|
||||
return;
|
||||
}
|
||||
const drag = dragRef.current;
|
||||
if (!drag?.html5) return;
|
||||
if (!drag?.html5 || drag.done) return;
|
||||
event.preventDefault();
|
||||
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
||||
if (drag.kind === "chapter") {
|
||||
drag.useBindingId = null;
|
||||
drag.index = chapterUnder(event.clientY, drag.parentId);
|
||||
@@ -1130,17 +1133,20 @@ export function ContentBoard({
|
||||
function drop(event) {
|
||||
const carried = carryRef.current;
|
||||
if (carried) {
|
||||
const useId = useDropId(event.target);
|
||||
event.preventDefault();
|
||||
if (carried.settled) return;
|
||||
carried.settled = true;
|
||||
const useId = useDropId(event.target) || carried.useBindingId || "";
|
||||
carryRef.current = null;
|
||||
setIndicator(null);
|
||||
if (useId) placeUseRef.current?.(useId, carried);
|
||||
if (useId && useId !== carried.bindingId) placeUseRef.current?.(useId, carried);
|
||||
else if (carried.source === "attachment" || carried.source === "evidence") releaseRef.current?.(carried);
|
||||
return;
|
||||
}
|
||||
if (!dragRef.current?.html5) return;
|
||||
const drag = dragRef.current;
|
||||
if (!drag?.html5 || drag.done) return;
|
||||
place(event);
|
||||
finishDragRef.current(dragRef.current);
|
||||
finishDragRef.current(drag);
|
||||
}
|
||||
node.addEventListener("dragover", place);
|
||||
node.addEventListener("drop", drop);
|
||||
@@ -1396,6 +1402,8 @@ export function ContentBoard({
|
||||
}
|
||||
|
||||
function finishDrag(drag) {
|
||||
if (!drag || drag.done) return;
|
||||
drag.done = true;
|
||||
dragRef.current = null;
|
||||
setDraggingId("");
|
||||
setIndicator(null);
|
||||
@@ -1491,7 +1499,7 @@ export function ContentBoard({
|
||||
window.removeEventListener("pointermove", track);
|
||||
window.removeEventListener("pointerup", release);
|
||||
window.removeEventListener("pointercancel", cancel);
|
||||
if (!drag || drag.html5 || drag.pointerId !== event.pointerId) return;
|
||||
if (!drag || drag.done || drag.pointerId !== event.pointerId) return;
|
||||
finishDrag(drag);
|
||||
}
|
||||
|
||||
@@ -1519,10 +1527,8 @@ export function ContentBoard({
|
||||
function endHtml5() {
|
||||
setTimeout(() => {
|
||||
const drag = dragRef.current;
|
||||
if (!drag?.html5) return;
|
||||
dragRef.current = null;
|
||||
setDraggingId("");
|
||||
setIndicator(null);
|
||||
if (!drag?.html5 || drag.done) return;
|
||||
finishDrag(drag);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@@ -1530,9 +1536,32 @@ export function ContentBoard({
|
||||
carryRef.current = payload;
|
||||
}
|
||||
|
||||
function endCarry() {
|
||||
function endCarry(event) {
|
||||
const carried = carryRef.current;
|
||||
if (!carried) {
|
||||
setIndicator(null);
|
||||
return;
|
||||
}
|
||||
carryRef.current = null;
|
||||
setIndicator(null);
|
||||
if (carried.settled) return;
|
||||
carried.settled = true;
|
||||
const x = event?.clientX || 0;
|
||||
const y = event?.clientY || 0;
|
||||
const pointOk = x > 0 || y > 0;
|
||||
const moved = Math.hypot(x - (carried.anchorX || 0), y - (carried.anchorY || 0));
|
||||
if (pointOk && moved < 8 && !carried.useBindingId) return;
|
||||
const hit = pointOk ? document.elementFromPoint(x, y) : null;
|
||||
if (hit && rootRef.current && !rootRef.current.contains(hit)) return;
|
||||
if (!hit && !carried.useBindingId) return;
|
||||
const useId = hit ? useDropId(hit) : (carried.useBindingId || "");
|
||||
if (useId && useId !== carried.bindingId) {
|
||||
placeUseRef.current?.(useId, carried);
|
||||
return;
|
||||
}
|
||||
if (!hit || useId) return;
|
||||
if (hit.closest?.(`[data-carry="${carried.source}:${carried.elementId}"]`)) return;
|
||||
if (carried.source === "attachment" || carried.source === "evidence") releaseRef.current?.(carried);
|
||||
}
|
||||
|
||||
function bindingByElement(elementId) {
|
||||
@@ -1992,16 +2021,9 @@ export function ContentBoard({
|
||||
type="button"
|
||||
className="handle"
|
||||
aria-label={`${element.title} ziehen`}
|
||||
draggable={!pending}
|
||||
draggable={false}
|
||||
disabled={pending}
|
||||
onPointerDown={(event) => beginDrag(event, { bindingId: binding.id, sectionId: section.id })}
|
||||
onDragStart={(event) => {
|
||||
event.dataTransfer.effectAllowed = "move";
|
||||
event.dataTransfer.setData("text/plain", binding.id);
|
||||
markHtml5({ bindingId: binding.id, sectionId: section.id, targetSectionId: section.id });
|
||||
setDraggingId(binding.id);
|
||||
}}
|
||||
onDragEnd={endHtml5}
|
||||
>
|
||||
<span className="handle__grip" aria-hidden="true" />
|
||||
</button>
|
||||
@@ -2018,6 +2040,8 @@ export function ContentBoard({
|
||||
elementId: element.id,
|
||||
bindingId: binding.id,
|
||||
title: element.title,
|
||||
anchorX: event.clientX,
|
||||
anchorY: event.clientY,
|
||||
});
|
||||
writeAssign(event, {
|
||||
source: "list",
|
||||
@@ -2028,68 +2052,75 @@ export function ContentBoard({
|
||||
}}
|
||||
onAssignEnd={endCarry}
|
||||
/>
|
||||
<div className="preview-row__body">
|
||||
<Link
|
||||
className="preview-row__title"
|
||||
to={href}
|
||||
draggable={false}
|
||||
aria-current={selectedId === binding.id ? "true" : undefined}
|
||||
onClick={openFromList}
|
||||
>
|
||||
<strong>{element.title}</strong>
|
||||
</Link>
|
||||
<div className="preview-row__meta">
|
||||
{sourceSymbol ? (
|
||||
<span className="source-mark">
|
||||
<TypeGlyph name={sourceSymbol} tone="light" size={16} />
|
||||
<TypeGlyph name={sourceSymbol} tone="dark" size={16} />
|
||||
</span>
|
||||
) : null}
|
||||
<span className="preview-row__facts">{facts}</span>
|
||||
<BezugMenu element={element} source={source} onOpen={onOpen} itemHref={itemHref} canEdit={canEdit} onClearBezug={clearBezug} />
|
||||
</div>
|
||||
{text ? (
|
||||
<Link className="preview-row__text" to={href} draggable={false} onClick={openFromList}>{text}</Link>
|
||||
) : null}
|
||||
{samePiece ? <span className="preview-row__origin">{samePiece}</span> : null}
|
||||
{originText ? <span className="preview-row__origin">{originText}</span> : null}
|
||||
<UnitDetail
|
||||
binding={binding}
|
||||
canEdit={canEdit}
|
||||
pending={pending}
|
||||
scope={scopeBody(actionContext(), containerKind, containerId)}
|
||||
onCarryStart={beginCarry}
|
||||
onCarryEnd={endCarry}
|
||||
onOpen={(elementId) => {
|
||||
const found = source.find((item) => item.element?.id === elementId);
|
||||
if (found) onOpen?.(found);
|
||||
}}
|
||||
onDetach={(elementId) => releaseToList({
|
||||
source: "attachment",
|
||||
elementId,
|
||||
hostElementId: element.id,
|
||||
})}
|
||||
onDetachEvidence={(proof, dispatch) => releaseToList({
|
||||
source: "evidence",
|
||||
elementId: proof.element_id,
|
||||
dispatchId: dispatch.id,
|
||||
})}
|
||||
onUnfold={async (elementId) => {
|
||||
const found = source.find((item) => item.element?.id === elementId);
|
||||
if (!found) return;
|
||||
setPending(true);
|
||||
setError("");
|
||||
try {
|
||||
await restoreFold(found.id, found.element.version, scopeBody(actionContext(), containerKind, containerId));
|
||||
onChange();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<UnitDetail
|
||||
binding={binding}
|
||||
canEdit={canEdit}
|
||||
pending={pending}
|
||||
scope={scopeBody(actionContext(), containerKind, containerId)}
|
||||
onCarryStart={beginCarry}
|
||||
onCarryEnd={endCarry}
|
||||
onOpen={(elementId) => {
|
||||
const found = source.find((item) => item.element?.id === elementId);
|
||||
if (found) onOpen?.(found);
|
||||
}}
|
||||
onDetach={(elementId) => releaseToList({
|
||||
source: "attachment",
|
||||
elementId,
|
||||
hostElementId: element.id,
|
||||
})}
|
||||
onDetachEvidence={(proof, dispatch) => releaseToList({
|
||||
source: "evidence",
|
||||
elementId: proof.element_id,
|
||||
dispatchId: dispatch.id,
|
||||
})}
|
||||
onUnfold={async (elementId) => {
|
||||
const found = source.find((item) => item.element?.id === elementId);
|
||||
if (!found) return;
|
||||
setPending(true);
|
||||
setError("");
|
||||
try {
|
||||
await restoreFold(found.id, found.element.version, scopeBody(actionContext(), containerKind, containerId));
|
||||
onChange();
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
} finally {
|
||||
setPending(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{(switches, lists) => (
|
||||
<div className="preview-row__body">
|
||||
<div className="preview-row__headline">
|
||||
<Link
|
||||
className="preview-row__title"
|
||||
to={href}
|
||||
draggable={false}
|
||||
aria-current={selectedId === binding.id ? "true" : undefined}
|
||||
onClick={openFromList}
|
||||
>
|
||||
<strong>{element.title}</strong>
|
||||
</Link>
|
||||
{switches}
|
||||
</div>
|
||||
<div className="preview-row__meta">
|
||||
{sourceSymbol ? (
|
||||
<span className="source-mark">
|
||||
<TypeGlyph name={sourceSymbol} tone="light" size={16} />
|
||||
<TypeGlyph name={sourceSymbol} tone="dark" size={16} />
|
||||
</span>
|
||||
) : null}
|
||||
<span className="preview-row__facts">{facts}</span>
|
||||
<BezugMenu element={element} source={source} onOpen={onOpen} itemHref={itemHref} canEdit={canEdit} onClearBezug={clearBezug} />
|
||||
</div>
|
||||
{text ? (
|
||||
<Link className="preview-row__text" to={href} draggable={false} onClick={openFromList}>{text}</Link>
|
||||
) : null}
|
||||
{samePiece ? <span className="preview-row__origin">{samePiece}</span> : null}
|
||||
{originText ? <span className="preview-row__origin">{originText}</span> : null}
|
||||
{lists}
|
||||
</div>
|
||||
)}
|
||||
</UnitDetail>
|
||||
<EntryActions
|
||||
element={element}
|
||||
binding={binding}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api } from "../api.js";
|
||||
import { buildChapterSections, sectionCounts } from "./chapters.js";
|
||||
@@ -113,6 +113,32 @@ function branchVisible(section, needle) {
|
||||
return (section.children || []).some((child) => branchVisible(child, needle));
|
||||
}
|
||||
|
||||
function PickBox({ checked, mixed = false, disabled = false, label, onChange }) {
|
||||
const ref = useRef(null);
|
||||
useEffect(() => {
|
||||
if (ref.current) ref.current.indeterminate = mixed;
|
||||
}, [mixed]);
|
||||
return (
|
||||
<input
|
||||
ref={ref}
|
||||
type="checkbox"
|
||||
checked={checked}
|
||||
disabled={disabled}
|
||||
aria-checked={mixed ? "mixed" : checked}
|
||||
aria-label={label}
|
||||
onChange={onChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function selectionState(ids, selected) {
|
||||
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";
|
||||
}
|
||||
|
||||
export function StructureAssignDialog({ host, bindings, chapters, scope, pending, onClose, onDone }) {
|
||||
const tree = useMemo(() => buildChapterSections(chapters, bindings), [chapters, bindings]);
|
||||
const [opened, setOpened] = useState(() => new Set(host.chapter_id ? ancestorIds(chapters, host.chapter_id) : ["loose"]));
|
||||
@@ -252,34 +278,40 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
|
||||
}
|
||||
}
|
||||
|
||||
function renderRow(item, depth) {
|
||||
function renderRow(item) {
|
||||
const id = item.element.id;
|
||||
const isHost = id === host.element.id;
|
||||
const notes = [
|
||||
formatDate(item.element.dates?.document_on),
|
||||
isHost ? "dieses Schriftstück" : "",
|
||||
taken.has(id) ? "Anlage" : "",
|
||||
].filter(Boolean).join(" · ");
|
||||
return (
|
||||
<li key={item.id} className="pick-tree__row" style={{ "--depth": depth }}>
|
||||
<label>
|
||||
<input type="checkbox" checked={selected.has(id)} disabled={isHost} onChange={() => toggle(id)} />
|
||||
<span>{item.element.title}</span>
|
||||
<span className="muted">{formatDate(item.element.dates?.document_on)}</span>
|
||||
{isHost ? <span className="muted">dieses Schriftstück</span> : null}
|
||||
{taken.has(id) ? <span className="muted">Anlage</span> : null}
|
||||
<li key={item.id}>
|
||||
<label className="pick-tree__row">
|
||||
<PickBox checked={selected.has(id)} disabled={isHost} label={item.element.title} onChange={() => toggle(id)} />
|
||||
<span className="pick-tree__title">{item.element.title}</span>
|
||||
<span className="pick-tree__kind">{notes}</span>
|
||||
</label>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function renderSection(section, depth) {
|
||||
function renderSection(section) {
|
||||
if (!branchVisible(section, needle)) return null;
|
||||
const expanded = Boolean(needle) || opened.has(section.id);
|
||||
const counts = sectionCounts(section);
|
||||
const total = counts.direct + counts.nested;
|
||||
const ids = branchItems(section).map((item) => item.element.id).filter((id) => id !== host.element.id);
|
||||
const state = selectionState(ids, selected);
|
||||
return (
|
||||
<li key={section.id}>
|
||||
<div className="pick-tree__chapter" style={{ "--depth": depth }}>
|
||||
<div className="pick-tree__row">
|
||||
<button
|
||||
type="button"
|
||||
className="quiet"
|
||||
className="pick-tree__twist"
|
||||
aria-expanded={expanded}
|
||||
aria-label={`${section.title} ${expanded ? "zuklappen" : "aufklappen"}`}
|
||||
onClick={() => setOpened((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(section.id)) next.delete(section.id);
|
||||
@@ -287,15 +319,24 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
|
||||
return next;
|
||||
})}
|
||||
>
|
||||
{expanded ? "▾" : "▸"} {section.title}
|
||||
<span className="muted">{total}</span>
|
||||
{expanded ? "▾" : "▸"}
|
||||
</button>
|
||||
<button type="button" className="quiet" aria-label={`Alle in ${section.title} auswählen`} onClick={() => toggleChapter(section)}>alle</button>
|
||||
<label>
|
||||
<PickBox
|
||||
checked={state === "on"}
|
||||
mixed={state === "mixed"}
|
||||
disabled={!ids.length}
|
||||
label={`Alle in ${section.title}`}
|
||||
onChange={() => toggleChapter(section)}
|
||||
/>
|
||||
<span className="pick-tree__title">{section.title}</span>
|
||||
<span className="pick-tree__kind">{total}</span>
|
||||
</label>
|
||||
</div>
|
||||
{expanded ? (
|
||||
<ul className="pick-tree__items">
|
||||
{(section.items || []).filter((item) => titleMatches(item, needle)).map((item) => renderRow(item, depth + 1))}
|
||||
{(section.children || []).map((child) => renderSection(child, depth + 1))}
|
||||
<ul>
|
||||
{(section.items || []).filter((item) => titleMatches(item, needle)).map((item) => renderRow(item))}
|
||||
{(section.children || []).map((child) => renderSection(child))}
|
||||
</ul>
|
||||
) : null}
|
||||
</li>
|
||||
@@ -305,24 +346,29 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
|
||||
const loose = tree.loose.filter((item) => titleMatches(item, needle));
|
||||
const roots = tree.roots.map((section) => renderSection(section, 0)).filter(Boolean);
|
||||
|
||||
const looseIds = loose.map((item) => item.element.id).filter((id) => id !== host.element.id);
|
||||
const looseState = selectionState(looseIds, selected);
|
||||
const looseOpen = Boolean(needle) || opened.has("loose");
|
||||
|
||||
return (
|
||||
<div className="stack pick-tree">
|
||||
<p>Zuordnen an <strong>{host.element.title}</strong>. Kapitel bleiben geschlossen, bis sie geöffnet werden.</p>
|
||||
<label>
|
||||
<div className="stack pick-tree-dialog">
|
||||
<p className="pick-tree__lead">Zuordnen an {host.element.title}</p>
|
||||
<label className="pick-tree__find">
|
||||
Suchen
|
||||
<input value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Titel" />
|
||||
</label>
|
||||
{step === "pick" ? (
|
||||
<>
|
||||
<ul className="pick-tree__list">
|
||||
<ul className="pick-tree">
|
||||
{roots}
|
||||
{loose.length ? (
|
||||
<li>
|
||||
<div className="pick-tree__chapter">
|
||||
<div className="pick-tree__row">
|
||||
<button
|
||||
type="button"
|
||||
className="quiet"
|
||||
aria-expanded={Boolean(needle) || opened.has("loose")}
|
||||
className="pick-tree__twist"
|
||||
aria-expanded={looseOpen}
|
||||
aria-label={`Ohne Kapitel ${looseOpen ? "zuklappen" : "aufklappen"}`}
|
||||
onClick={() => setOpened((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has("loose")) next.delete("loose");
|
||||
@@ -330,19 +376,28 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
|
||||
return next;
|
||||
})}
|
||||
>
|
||||
{needle || opened.has("loose") ? "▾" : "▸"} Ohne Kapitel
|
||||
<span className="muted">{loose.length}</span>
|
||||
{looseOpen ? "▾" : "▸"}
|
||||
</button>
|
||||
<button type="button" className="quiet" onClick={() => toggleIds(loose.map((item) => item.element.id).filter((id) => id !== host.element.id))}>alle</button>
|
||||
<label>
|
||||
<PickBox
|
||||
checked={looseState === "on"}
|
||||
mixed={looseState === "mixed"}
|
||||
disabled={!looseIds.length}
|
||||
label="Alle ohne Kapitel"
|
||||
onChange={() => toggleIds(looseIds)}
|
||||
/>
|
||||
<span className="pick-tree__title">Ohne Kapitel</span>
|
||||
<span className="pick-tree__kind">{loose.length}</span>
|
||||
</label>
|
||||
</div>
|
||||
{needle || opened.has("loose") ? (
|
||||
<ul className="pick-tree__items">
|
||||
{loose.map((item) => renderRow(item, 1))}
|
||||
{looseOpen ? (
|
||||
<ul>
|
||||
{loose.map((item) => renderRow(item))}
|
||||
</ul>
|
||||
) : null}
|
||||
</li>
|
||||
) : null}
|
||||
{!roots.length && !loose.length ? <li className="muted">Nichts mit diesem Titel.</li> : null}
|
||||
{!roots.length && !loose.length ? <li className="pick-tree__empty">Nichts mit diesem Titel.</li> : null}
|
||||
</ul>
|
||||
<div className="pick-tree__bar">
|
||||
<span>{selected.size} ausgewählt</span>
|
||||
@@ -645,16 +700,41 @@ export function ComparisonList({ comparisons = [], state, reason }) {
|
||||
|
||||
function chipDrag(enabled, payload, onCarryStart, onCarryEnd) {
|
||||
return {
|
||||
role: "button",
|
||||
tabIndex: enabled ? 0 : undefined,
|
||||
draggable: enabled,
|
||||
onDragStart(event) {
|
||||
if (event.target.closest("button, a")) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
event.stopPropagation();
|
||||
payload.anchorX = event.clientX;
|
||||
payload.anchorY = event.clientY;
|
||||
event.currentTarget.dataset.dragged = "1";
|
||||
writeAssign(event, payload);
|
||||
onCarryStart?.(payload);
|
||||
},
|
||||
onDragEnd() {
|
||||
onCarryEnd?.();
|
||||
onDragEnd(event) {
|
||||
onCarryEnd?.(event);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function openTitleProps(onOpen) {
|
||||
return {
|
||||
role: "link",
|
||||
tabIndex: 0,
|
||||
onClick(event) {
|
||||
const row = event.currentTarget.closest(".use-chip");
|
||||
if (row?.dataset.dragged === "1") {
|
||||
delete row.dataset.dragged;
|
||||
return;
|
||||
}
|
||||
onOpen();
|
||||
},
|
||||
onKeyDown(event) {
|
||||
if (event.key !== "Enter" && event.key !== " ") return;
|
||||
event.preventDefault();
|
||||
onOpen();
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -670,113 +750,134 @@ export function UnitDetail({
|
||||
onUnfold,
|
||||
onCarryStart,
|
||||
onCarryEnd,
|
||||
children,
|
||||
}) {
|
||||
const pack = binding.correspondence || {};
|
||||
const attachments = pack.attachments || [];
|
||||
const dispatches = pack.dispatches || [];
|
||||
const [open, setOpen] = useState(false);
|
||||
if (!attachments.length && !dispatches.length) return null;
|
||||
const summary = unitMarks(binding) || "Anlagen und Belege";
|
||||
const [attachmentsOpen, setAttachmentsOpen] = useState(false);
|
||||
const [receiptsOpen, setReceiptsOpen] = useState(false);
|
||||
if (!attachments.length && !dispatches.length) {
|
||||
return typeof children === "function" ? children(null, null) : null;
|
||||
}
|
||||
const evidenceCount = dispatches.reduce((sum, item) => sum + (item.evidence || []).length, 0);
|
||||
const attachmentLabel = attachments.length === 1 ? "1 Anlage" : `${attachments.length} Anlagen`;
|
||||
const receiptParts = [];
|
||||
if (dispatches.length === 1) receiptParts.push("1 Versand");
|
||||
else if (dispatches.length > 1) receiptParts.push(`${dispatches.length} Versände`);
|
||||
if (evidenceCount === 1) receiptParts.push("1 Beleg");
|
||||
else if (evidenceCount > 1) receiptParts.push(`${evidenceCount} Belege`);
|
||||
const switches = (
|
||||
<span className="unit-switches">
|
||||
{attachments.length ? (
|
||||
<button type="button" className="unit-switch" aria-expanded={attachmentsOpen} onClick={() => setAttachmentsOpen((value) => !value)}>
|
||||
{attachmentLabel}
|
||||
</button>
|
||||
) : null}
|
||||
{dispatches.length ? (
|
||||
<button type="button" className="unit-switch" aria-expanded={receiptsOpen} onClick={() => setReceiptsOpen((value) => !value)}>
|
||||
{receiptParts.join(" · ") || "Belege"}
|
||||
</button>
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
const lists = attachmentsOpen || receiptsOpen ? (
|
||||
<div className="unit-detail unit-detail--slim">
|
||||
{attachmentsOpen && attachments.length ? (
|
||||
<section>
|
||||
<h4>Anlagen</h4>
|
||||
<ol>
|
||||
{attachments.map((item, index) => (
|
||||
<li
|
||||
key={item.id}
|
||||
className="use-chip"
|
||||
data-carry={`attachment:${item.element_id}`}
|
||||
{...(canEdit ? chipDrag(!pending, {
|
||||
source: "attachment",
|
||||
elementId: item.element_id,
|
||||
hostElementId: binding.element.id,
|
||||
bindingId: item.binding_id || "",
|
||||
title: item.title,
|
||||
}, onCarryStart, onCarryEnd) : {})}
|
||||
>
|
||||
{canEdit ? <span className="use-chip__grip" aria-hidden="true" /> : null}
|
||||
<span className="use-chip__title" {...openTitleProps(() => onOpen(item.element_id))}>
|
||||
{index + 1}. {item.title}
|
||||
</span>
|
||||
<span className="muted">{formatDate(item.document_on)}</span>
|
||||
{canEdit ? (
|
||||
<button type="button" className="quiet" disabled={pending} onClick={() => onDetach(item.element_id)}>In die Liste</button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
) : null}
|
||||
{receiptsOpen ? dispatches.map((item) => (
|
||||
<section key={item.id}>
|
||||
<h4>
|
||||
Versand {item.undated ? "undatiert" : formatDate(item.sent_on)} · {item.channel_label}
|
||||
{item.counterpart ? ` · ${item.counterpart}` : ""}
|
||||
</h4>
|
||||
{item.evidence?.length ? (
|
||||
<ul>
|
||||
{item.evidence.map((proof) => (
|
||||
<li
|
||||
key={proof.id}
|
||||
className="use-chip"
|
||||
data-carry={`evidence:${proof.element_id}`}
|
||||
{...(canEdit ? chipDrag(!pending, {
|
||||
source: "evidence",
|
||||
elementId: proof.element_id,
|
||||
dispatchId: item.id,
|
||||
hostElementId: binding.element.id,
|
||||
version: item.version,
|
||||
title: proof.title,
|
||||
}, onCarryStart, onCarryEnd) : {})}
|
||||
>
|
||||
{canEdit ? <span className="use-chip__grip" aria-hidden="true" /> : null}
|
||||
<span className="use-chip__title" {...openTitleProps(() => onOpen(proof.element_id))}>
|
||||
{receiptRoleLabel(proof.role, proof.role_label)}: {proof.title}
|
||||
</span>
|
||||
<span className="muted">{formatDate(proof.document_on)}</span>
|
||||
{proof.source_state === "gap" ? <span>Lücke: {proof.gap_reason}</span> : null}
|
||||
{canEdit ? (
|
||||
<button type="button" className="quiet" disabled={pending} onClick={() => onDetachEvidence(proof, item)}>
|
||||
In die Liste
|
||||
</button>
|
||||
) : null}
|
||||
{canEdit && proof.listed_fold === "evidence" ? (
|
||||
<button type="button" className="quiet" disabled={pending} onClick={() => onUnfold(proof.element_id)}>
|
||||
Zusätzlich in der Liste zeigen
|
||||
</button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="muted">Ohne Beleg</p>}
|
||||
<details className="use-editions">
|
||||
<summary>Gesicherte Fassung</summary>
|
||||
<ol>
|
||||
{item.items.map((part) => (
|
||||
<li key={part.id}>
|
||||
<span>{part.role === "host" ? "Schreiben" : "Anlage"}: {part.title}</span>
|
||||
<span className="muted">{formatDate(part.document_on)}</span>
|
||||
{part.source_state === "gap" ? <span>Lücke: {part.gap_reason}</span> : scope ? (
|
||||
<a href={snapshotHref(item.id, part.id, scope)}>Öffnen</a>
|
||||
) : <span>Gesichert</span>}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</details>
|
||||
</section>
|
||||
)) : null}
|
||||
</div>
|
||||
) : null;
|
||||
if (typeof children === "function") return children(switches, lists);
|
||||
return (
|
||||
<div className="unit-fold">
|
||||
<button type="button" className="quiet unit-toggle" aria-expanded={open} onClick={() => setOpen((value) => !value)}>
|
||||
{open ? "Zuklappen" : summary}
|
||||
</button>
|
||||
{open ? (
|
||||
<div className="unit-detail unit-detail--slim">
|
||||
{attachments.length ? (
|
||||
<section>
|
||||
<h4>Anlagen</h4>
|
||||
<ol>
|
||||
{attachments.map((item, index) => (
|
||||
<li key={item.id} className="use-chip">
|
||||
{canEdit ? (
|
||||
<span
|
||||
className="use-chip__grip"
|
||||
aria-label={`${item.title} aus den Anlagen ziehen`}
|
||||
{...chipDrag(!pending, {
|
||||
source: "attachment",
|
||||
elementId: item.element_id,
|
||||
hostElementId: binding.element.id,
|
||||
bindingId: item.binding_id || "",
|
||||
title: item.title,
|
||||
}, onCarryStart, onCarryEnd)}
|
||||
/>
|
||||
) : null}
|
||||
<span>{index + 1}. {item.title}</span>
|
||||
<span className="muted">{formatDate(item.document_on)}</span>
|
||||
{item.binding_id ? (
|
||||
<button type="button" className="quiet" onClick={() => onOpen(item.element_id)}>Öffnen</button>
|
||||
) : null}
|
||||
{canEdit ? (
|
||||
<button type="button" className="quiet" disabled={pending} onClick={() => onDetach(item.element_id)}>In die Liste</button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
) : null}
|
||||
{dispatches.map((item) => (
|
||||
<section key={item.id}>
|
||||
<h4>
|
||||
Versand {item.undated ? "undatiert" : formatDate(item.sent_on)} · {item.channel_label}
|
||||
{item.counterpart ? ` · ${item.counterpart}` : ""}
|
||||
</h4>
|
||||
{item.evidence?.length ? (
|
||||
<ul>
|
||||
{item.evidence.map((proof) => (
|
||||
<li key={proof.id} className="use-chip">
|
||||
{canEdit ? (
|
||||
<span
|
||||
className="use-chip__grip"
|
||||
aria-label={`${proof.title} aus den Belegen ziehen`}
|
||||
{...chipDrag(!pending, {
|
||||
source: "evidence",
|
||||
elementId: proof.element_id,
|
||||
dispatchId: item.id,
|
||||
hostElementId: binding.element.id,
|
||||
version: item.version,
|
||||
title: proof.title,
|
||||
}, onCarryStart, onCarryEnd)}
|
||||
/>
|
||||
) : null}
|
||||
<button type="button" className="quiet" onClick={() => onOpen(proof.element_id)}>
|
||||
{receiptRoleLabel(proof.role, proof.role_label)}: {proof.title}
|
||||
</button>
|
||||
<span className="muted">{formatDate(proof.document_on)}</span>
|
||||
{proof.source_state === "gap" ? <span>Lücke: {proof.gap_reason}</span> : null}
|
||||
{canEdit ? (
|
||||
<button type="button" className="quiet" disabled={pending} onClick={() => onDetachEvidence(proof, item)}>
|
||||
In die Liste
|
||||
</button>
|
||||
) : null}
|
||||
{canEdit && proof.listed_fold === "evidence" ? (
|
||||
<button type="button" className="quiet" disabled={pending} onClick={() => onUnfold(proof.element_id)}>
|
||||
Zusätzlich in der Liste zeigen
|
||||
</button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : <p className="muted">Ohne Beleg</p>}
|
||||
<details className="use-editions">
|
||||
<summary>Gesicherte Fassung</summary>
|
||||
<ol>
|
||||
{item.items.map((part) => (
|
||||
<li key={part.id}>
|
||||
<span>{part.role === "host" ? "Schreiben" : "Anlage"}: {part.title}</span>
|
||||
<span className="muted">{formatDate(part.document_on)}</span>
|
||||
{part.source_state === "gap" ? <span>Lücke: {part.gap_reason}</span> : scope ? (
|
||||
<a href={snapshotHref(item.id, part.id, scope)}>Öffnen</a>
|
||||
) : <span>Gesichert</span>}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</details>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
{switches}
|
||||
{lists}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
+87
-15
@@ -721,6 +721,7 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
.preview-row > .insert-line { grid-column: 1 / -1; }
|
||||
.preview-row.is-dragging { opacity: 0.4; }
|
||||
.preview-row__body { display: grid; gap: 2px; min-width: 0; }
|
||||
.preview-row__headline { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-start; gap: 2px 12px; min-width: 0; }
|
||||
.preview-row__title, .preview-row__text { color: inherit; text-decoration: none; min-width: 0; }
|
||||
.preview-row__title strong, .preview-row__main strong {
|
||||
display: -webkit-box;
|
||||
@@ -1329,33 +1330,104 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
||||
.choice-list li, .choice-list label { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
||||
.choice-list--scroll { max-height: 240px; overflow: auto; }
|
||||
.choice-list__move { display: inline-flex; gap: 4px; margin-left: auto; }
|
||||
.unit-fold { margin-top: 2px; }
|
||||
.unit-fold { display: grid; justify-items: start; gap: 2px; margin-top: 2px; }
|
||||
.unit-switches { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 2px 12px; }
|
||||
button.unit-switch {
|
||||
min-height: 22px;
|
||||
height: 22px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--text2);
|
||||
font-size: 13px;
|
||||
font-weight: 650;
|
||||
line-height: 22px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
button.unit-switch[aria-expanded="true"] { color: var(--brand); }
|
||||
.unit-detail, .comparison, .chrono { display: grid; gap: 8px; margin-top: 8px; }
|
||||
.unit-detail--slim { gap: 4px; margin-top: 2px; }
|
||||
.unit-detail h4, .chrono h3 { margin: 0; font-size: 13px; }
|
||||
.unit-detail--slim { gap: 4px; margin-top: 2px; justify-items: start; text-align: left; }
|
||||
.unit-detail h4, .chrono h3 { margin: 0; font-size: 13px; text-align: left; }
|
||||
.unit-detail section { display: grid; gap: 4px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: color-mix(in srgb, var(--surface) 88%, var(--bg)); }
|
||||
.unit-detail--slim section { padding: 0; border: 0; border-radius: 0; background: transparent; gap: 2px; }
|
||||
.unit-detail--slim section { padding: 0 0 0 8px; border: 0; border-left: 1px solid var(--border); border-radius: 0; background: transparent; gap: 2px; }
|
||||
.unit-detail--slim button.quiet, .unit-detail--slim summary { min-height: 22px; height: 22px; padding: 0 6px; font-size: 12px; }
|
||||
.unit-detail ol, .unit-detail ul, .comparison ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
|
||||
.unit-detail--slim ol, .unit-detail--slim ul { gap: 0; }
|
||||
.unit-detail li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; min-width: 0; max-width: 100%; }
|
||||
.unit-detail li { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 2px 10px; align-items: center; min-width: 0; max-width: 100%; min-height: 22px; text-align: left; }
|
||||
.unit-detail li .muted { white-space: nowrap; }
|
||||
.use-chip { cursor: default; }
|
||||
.use-chip__grip { width: 14px; height: 22px; border: 0; padding: 0; border-left: 2px dotted var(--text3); border-right: 2px dotted var(--text3); background: transparent; flex: none; cursor: grab; }
|
||||
.use-chip { cursor: grab; }
|
||||
.use-chip__grip { width: 10px; height: 14px; border: 0; padding: 0; border-left: 2px dotted var(--text3); border-right: 2px dotted var(--text3); background: transparent; flex: none; }
|
||||
.use-chip__title { cursor: pointer; font-weight: 600; text-align: left; }
|
||||
.entry-mark[draggable="true"] { cursor: grab; }
|
||||
.use-editions summary { cursor: pointer; color: var(--text2); font-size: 13px; }
|
||||
.unit-toggle { min-height: 22px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
|
||||
.use-editions summary { cursor: pointer; color: var(--text2); font-size: 13px; text-align: left; }
|
||||
.preview-row.is-use-target .direction-trigger,
|
||||
.preview-row.is-use-target .entry-mark {
|
||||
box-shadow: inset 0 0 0 2px var(--accent);
|
||||
background: var(--accent-light);
|
||||
}
|
||||
.pick-tree__list { max-height: 60vh; overflow: auto; margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
|
||||
.pick-tree__items { margin: 0; padding: 0; list-style: none; }
|
||||
.pick-tree__chapter, .pick-tree__row { display: flex; gap: 8px; align-items: center; min-height: 28px; padding-left: calc(var(--depth, 0) * 14px); }
|
||||
.pick-tree__chapter > span, .pick-tree__row label { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
|
||||
.pick-tree button.quiet { min-height: 28px; height: 28px; padding: 0 8px; font-size: 13px; }
|
||||
.pick-tree__bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }
|
||||
.pick-tree-dialog { justify-items: start; text-align: left; gap: 8px; }
|
||||
.pick-tree__lead { margin: 0; text-align: left; font-size: 13px; font-weight: 400; color: var(--text2); }
|
||||
.pick-tree__find { width: 100%; font-size: 13px; font-weight: 500; gap: 4px; text-align: left; }
|
||||
.pick-tree__find input { min-height: 32px; padding: 4px 8px; font-size: 13px; }
|
||||
.pick-tree, .pick-tree ul { list-style: none; margin: 0; padding: 0; text-align: left; }
|
||||
.pick-tree { max-height: min(60vh, 520px); overflow: auto; width: 100%; }
|
||||
.pick-tree ul { margin-left: 11px; padding-left: 8px; border-left: 1px solid var(--border); }
|
||||
.pick-tree__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
min-height: 28px;
|
||||
margin: 0;
|
||||
padding: 1px 4px;
|
||||
text-align: left;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.pick-tree__row > label {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: flex-start;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
color: inherit;
|
||||
}
|
||||
.pick-tree__row input[type="checkbox"] {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
min-width: 14px;
|
||||
min-height: 14px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
flex: 0 0 14px;
|
||||
accent-color: var(--accent);
|
||||
background: transparent;
|
||||
border-radius: 2px;
|
||||
}
|
||||
button.pick-tree__twist {
|
||||
width: 22px;
|
||||
min-width: 22px;
|
||||
height: 22px;
|
||||
min-height: 22px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: var(--text2);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
}
|
||||
.pick-tree__title { font-weight: 600; text-align: left; min-width: 0; overflow-wrap: anywhere; }
|
||||
.pick-tree__kind { color: var(--text3); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; }
|
||||
.pick-tree__empty { padding: 4px; color: var(--text3); font-size: 13px; text-align: left; }
|
||||
.pick-tree__bar { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; align-items: center; position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; width: 100%; }
|
||||
.count { white-space: normal; }
|
||||
.chapter-children { display: grid; gap: 8px; margin-top: 8px; }
|
||||
.pick-bar {
|
||||
|
||||
Reference in new issue
Block a user