Lege Anlagen und Versandbelege direkt am Schriftstueck ab, damit die Zuordnung aus dem Vorgang gezogen werden kann und mehrere Belege an einem Versand bleiben.
Deploy Development / deploy (push) Successful in 26s
Test Suite / pytest-backend (push) Successful in 1m35s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 8s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-18 10:35:32 +02:00
1 parent c138df5e68
commit c774fb7206
9 files changed
+663 -200

No files matched your search

+21
View File
@@ -14,6 +14,7 @@ from app.api.schemas import (
AttachmentDetachIn,
AttachmentOrderIn,
DispatchCorrectIn,
DispatchEvidenceDetachIn,
DispatchEvidenceIn,
DispatchIn,
FoldIn,
@@ -22,6 +23,7 @@ from app.correspondence import (
GapNote,
add_dispatch_evidence,
assign_attachments,
detach_dispatch_evidence,
correct_dispatch,
detach_attachment,
dispatch_view,
@@ -173,6 +175,25 @@ def post_evidence(
)
@router.post("/api/v1/dispatches/{dispatch_id}/evidence/{element_id}/detach", status_code=204)
def post_detach_evidence(
dispatch_id: UUID,
element_id: UUID,
body: DispatchEvidenceDetachIn,
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
detach_dispatch_evidence(
conn,
principal.account_id,
dispatch_id,
element_id,
body.expected_version,
_ctx(body.context),
_placement(body.placement),
)
@router.post("/api/v1/dispatches/{dispatch_id}/correct")
def post_correct(
dispatch_id: UUID,
+6
View File
@@ -424,6 +424,12 @@ class DispatchEvidenceIn(APIModel):
fold: Literal["keep", "evidence"] = "keep"
class DispatchEvidenceDetachIn(APIModel):
expected_version: int = Field(ge=1)
context: ContextIn
placement: ContextIn | None = None
class DispatchCorrectIn(APIModel):
expected_version: int = Field(ge=1)
context: ContextIn
+39
View File
@@ -291,6 +291,33 @@ def add_dispatch_evidence(
return row
def detach_dispatch_evidence(
conn,
actor: UUID,
dispatch_id: UUID,
element_id: UUID,
expected: int,
context: Ctx,
placement: Ctx | None,
) -> None:
container_row, page, scope = open_container(conn, actor, context, placement, "edit")
dispatch = _dispatch_in(conn, dispatch_id, scope)
_bump_dispatch(conn, dispatch_id, expected)
deleted = conn.execute(
"""
DELETE FROM dispatch_evidence
WHERE dispatch_id = %s AND element_id = %s
RETURNING id
""",
(dispatch_id, element_id),
).fetchone()
if deleted is None:
raise not_found()
_clear_evidence_fold(conn, scope, element_id)
_log(conn, dispatch_id, actor, "Nachweis aus diesem Versand gelöst")
audit(conn, actor, container_row["home_scope_id"], "dispatch_evidence_detached", "element", dispatch["host_element_id"], page)
def correct_dispatch(
conn,
actor: UUID,
@@ -1254,6 +1281,18 @@ def _set_binding_fold(conn, scope: Ctx, element_id: UUID, fold: str) -> None:
)
def _clear_evidence_fold(conn, scope: Ctx, element_id: UUID) -> None:
if _is_evidence(conn, scope, element_id):
return
conn.execute(
"""
UPDATE bindings SET list_fold = NULL
WHERE element_id = %s AND context_kind = %s AND context_id = %s AND list_fold = 'evidence'
""",
(element_id, scope.kind, scope.id),
)
def _clear_attachment_fold(conn, scope: Ctx, element_id: UUID) -> None:
if _is_attachment(conn, scope, element_id):
return
+11
View File
@@ -470,6 +470,17 @@ def test_dispatch_keeps_the_secured_stand_and_distinct_mail_parts(client, db, mo
assert {item["channel"] for item in sends} == {"email", "post"}
post_send = next(item for item in sends if item["sent_on"] == "2026-03-18")
assert {item["role"] for item in post_send["evidence"]} == {"submission", "delivery"}
ada.request(
"POST",
f"/api/v1/dispatches/{post_send['id']}/evidence/{delivery['id']}/detach",
json={"expected_version": post_send["version"], "context": _ctx(matter["id"])},
status=204,
)
final = _detail(ada, matter["id"])
sends = _binding(final, "Anschreiben")["correspondence"]["dispatches"]
post_send = next(item for item in sends if item["sent_on"] == "2026-03-18")
assert {item["role"] for item in post_send["evidence"]} == {"submission"}
assert _binding(final, "Zustellbestätigung")["correspondence"]["fold"] is None
assert _binding(final, "Zustellbestätigung")["element"]["dates"]["document_on"] == "2026-03-28"
ada.request(
"PATCH",
+1
View File
@@ -188,6 +188,7 @@ Alle schreibenden Aufrufe prüfen den Handlungskontext, `expected_version` und d
| PATCH | `/api/v1/bindings/{id}/fold` | Vorkommen als Anlage, Nachweis oder wieder eigenständig |
| POST | `/api/v1/elements/{id}/dispatches` | Versand dokumentieren und Fassung sichern oder als Lücke kennzeichnen |
| POST | `/api/v1/dispatches/{id}/evidence` | Nachweis ergänzen |
| POST | `/api/v1/dispatches/{id}/evidence/{element_id}/detach` | nur diesen Beleg vom Versand lösen |
| POST | `/api/v1/dispatches/{id}/correct` | Weg, Datum oder Gegenüber berichtigen |
| GET | `/api/v1/dispatches/{id}` | Manifest, Nachweise, Berichtigungen |
| GET | `/api/v1/dispatches/{id}/items/{item_id}/content` | gesicherte Bytes; eine Lücke liefert 404 und nicht die aktuelle Datei |
+1 -1
View File
@@ -223,7 +223,7 @@ Auth-Tabellen `auth_accounts` und `auth_sessions` folgen dem Auth-Blueprint. Ein
Akten und Vorgänge speichern `content_order` (`date` oder `position`) und `content_order_dir` (`asc` oder `desc`). Bestehende Zeilen bleiben auf `position`, damit eine schon gesetzte Einbindungsreihenfolge nicht ersetzt wird. Neue Akten und Vorgänge beginnen mit fachlichem Datum aufsteigend. `bindings.position` gehört zur Einbindung. Die Datumssortierung schreibt sie nicht um. `PATCH /api/v1/cases/{id}/content-order` und `POST /api/v1/cases/{id}/bindings/order` sowie die gleichen Pfade unter `matters` prüfen das Bearbeitungsrecht im Handlungskontext und `expected_version`. Der fachliche Verlauf liest die Datumsfelder der sichtbaren Unterlagen einmal je Element. Das Änderungsprotokoll bleibt `GET .../chronology`, seitenweise über `cursor`. `content_view` ist `structure` oder `chronology` und nur eine Darstellung. Sie schreibt Kapitel, Positionen und Datumssortierung nicht um. Der Breadcrumb eines Vorgangs ist der Objektpfad `Vorgänge` und gegebenenfalls der lesbare Elternvorgang; lesbare Aktenzuordnungen stehen separat in `placements` und wechseln den Handlungskontext nur bei bewusster Auswahl. `elements.summary` ist eine optionale gemeinsame Kurzbeschreibung. Ein Textauszug entsteht nur aus vorhandenem Notiztext. Bild- und PDF-Vorschauen verwenden denselben berechtigten Dateiabruf wie das Öffnen.
Anlagen, Versand und Nachweise sind eigene Verwendungen im Behälter der Einbindung, nicht im geerbten Aktenkontext. `attachment_uses` ordnet ein vorhandenes Element einem Hauptschriftstück zu, mit eigener Reihenfolge je Behälter und ohne Dateikopie. `bindings.list_fold` blendet nur dieses Vorkommen als Anlage oder Nachweis aus; andere Einbindungen bleiben. `dispatches` hält Weg, Versanddatum, Gegenüber, Vollständigkeit und Herkunft (`captured` oder `reconstructed`). `dispatch_items` ist das Manifest. Eine sicherbare Fassung liegt als Bytes unter `MEDIA_ROOT/dispatch/<id>` in `dispatch_snapshots`, bei Notizen zusätzlich als JSON im Manifest. Eine fehlende historische Fassung bleibt `gap` und wird nicht durch die aktuelle Arbeitsdatei ersetzt. `dispatch_evidence` verknüpft einen vorhandenen Beleg in der Rolle E-Mail, Einlieferung, Zustellung oder sonstiger Nachweis. Einlieferung setzt keinen Zustellstatus. Berichtigungen stehen in `dispatch_corrections` und ändern die gesicherten Bytes nicht. Löschen eines Elements entfernt die Bytes seiner Versandfassungen über denselben Löschpfad wie die Arbeitsdatei. Lesen des Hauptschriftstücks öffnet keine gesperrte Anlage. Exportknoten `attachment`, `dispatch_item` und `evidence` unterscheiden Arbeitsstand, gesicherte Fassung und Nachweis. Eine unvollständige Auswahl ist ein Auszug. Eine ausgewählte E-Mail bleibt das vollständige Original.
Anlagen, Versand und Nachweise sind eigene Verwendungen im Behälter der Einbindung, nicht im geerbten Aktenkontext. `attachment_uses` ordnet ein vorhandenes Element einem Hauptschriftstück zu, mit eigener Reihenfolge je Behälter und ohne Dateikopie. `bindings.list_fold` blendet nur dieses Vorkommen als Anlage oder Nachweis aus; andere Einbindungen bleiben. `dispatches` hält Weg, Versanddatum, Gegenüber, Vollständigkeit und Herkunft (`captured` oder `reconstructed`). `dispatch_items` ist das Manifest. Eine sicherbare Fassung liegt als Bytes unter `MEDIA_ROOT/dispatch/<id>` in `dispatch_snapshots`, bei Notizen zusätzlich als JSON im Manifest. Eine fehlende historische Fassung bleibt `gap` und wird nicht durch die aktuelle Arbeitsdatei ersetzt. `dispatch_evidence` verknüpft einen vorhandenen Beleg in der Rolle E-Mail, Einlieferung, Zustellung oder sonstiger Nachweis. Am Schriftstück liegt dafür ein eigenes Ablagefeld; mehrere Belege eines Versands bleiben nebeneinander. Ziehen aus der Liste ordnet zu, Ziehen zurück in die Liste löst nur diese Verwendung. Einlieferung setzt keinen Zustellstatus. Berichtigungen stehen in `dispatch_corrections` und ändern die gesicherten Bytes nicht. Löschen eines Elements entfernt die Bytes seiner Versandfassungen über denselben Löschpfad wie die Arbeitsdatei. Lesen des Hauptschriftstücks öffnet keine gesperrte Anlage. Exportknoten `attachment`, `dispatch_item` und `evidence` unterscheiden Arbeitsstand, gesicherte Fassung und Nachweis. Eine unvollständige Auswahl ist ein Auszug. Eine ausgewählte E-Mail bleibt das vollständige Original.
### 4.3 Überblick
+281 -92
View File
@@ -27,6 +27,7 @@ import {
scopeBody,
unitMarks,
UnitDetail,
writeAssign,
} from "./correspondence.jsx";
export function formatDate(value) {
@@ -839,9 +840,9 @@ function EntryActions({
) : null}
{canSort && custom ? <button type="button" disabled={pending || index === 0} onClick={() => { close(); onMove(binding.id, -1); }}>Nach oben</button> : null}
{canSort && custom ? <button type="button" disabled={pending || index === lastIndex} onClick={() => { close(); onMove(binding.id, 1); }}>Nach unten</button> : null}
{canEdit && onAttach ? <button type="button" onClick={() => { close(); onAttach(binding); }}>Anlagen zuordnen</button> : null}
{canEdit && onAttach ? <button type="button" onClick={() => { close(); onAttach(binding); }}>Anlage aus der Liste wählen</button> : null}
{canEdit && onDispatch ? <button type="button" onClick={() => { close(); onDispatch(binding); }}>Versand dokumentieren</button> : null}
{canEdit && onEvidence ? <button type="button" onClick={() => { close(); onEvidence(binding); }}>Als Versandnachweis zuordnen …</button> : null}
{canEdit && onEvidence ? <button type="button" onClick={() => { close(); onEvidence(binding); }}>Als Beleg zuordnen …</button> : null}
{canEdit ? <button type="button" onClick={() => { close(); onRemove(binding, false); }}>Aus diesem Zusammenhang entfernen</button> : null}
{canEdit && canDestroy ? <button type="button" className="danger" onClick={() => { close(); onRemove(binding, true); }}>Überall löschen</button> : null}
</MenuPopover>
@@ -857,11 +858,12 @@ function TypeGlyph({ name, tone, size = 28 }) {
width={size}
height={size}
alt=""
draggable={false}
/>
);
}
function EntryMark({ element, context }) {
function EntryMark({ element, context, assignable = false, onAssignStart, onAssignEnd }) {
const symbol = elementSymbol(element);
const photo = symbol === "image" && Boolean(element.preview?.available);
const [url, setUrl] = useState("");
@@ -883,8 +885,16 @@ function EntryMark({ element, context }) {
};
}, [photo, element.id, element.preview?.source, context?.kind, context?.id]);
return (
<span className={url ? "entry-mark entry-mark--photo" : "entry-mark"}>
{url ? <img className="entry-mark__photo" alt="" src={url} /> : (
<span
className={url ? "entry-mark entry-mark--photo" : "entry-mark"}
draggable={assignable}
role={assignable ? "button" : undefined}
tabIndex={assignable ? 0 : undefined}
aria-label={assignable ? `${element.title} als Anlage oder Beleg ziehen` : undefined}
onDragStart={assignable ? onAssignStart : undefined}
onDragEnd={assignable ? onAssignEnd : undefined}
>
{url ? <img className="entry-mark__photo" alt="" draggable={false} src={url} /> : (
<>
<TypeGlyph name={symbol} tone="light" />
<TypeGlyph name={symbol} tone="dark" />
@@ -939,14 +949,16 @@ export function ContentBoard({
const [error, setError] = useState("");
const [pending, setPending] = useState(false);
const [dialog, setDialog] = useState(null);
const [openUnits, setOpenUnits] = useState(() => new Set());
const [draggingId, setDraggingId] = useState("");
const [carry, setCarry] = useState(null);
const [indicator, setIndicator] = useState(null);
const [folded, setFolded] = useState(() => new Set());
const [picking, setPicking] = useState(false);
const [picked, setPicked] = useState(() => new Set());
const [pickTarget, setPickTarget] = useState("");
const dragRef = useRef(null);
const carryRef = useRef(null);
const releaseRef = useRef(null);
const rootRef = useRef(null);
const savingDirection = useRef(false);
const custom = record?.content_order === "position";
@@ -1081,6 +1093,10 @@ export function ContentBoard({
const node = rootRef.current;
if (!node) return undefined;
function place(event) {
if (carryRef.current) {
event.preventDefault();
return;
}
const drag = dragRef.current;
if (!drag?.html5) return;
event.preventDefault();
@@ -1096,6 +1112,17 @@ export function ContentBoard({
setIndicator({ sectionId, index: drag.index });
}
function drop(event) {
const carried = carryRef.current;
if (carried) {
if (event.target?.closest?.(".drop-well")) return;
if (carried.source === "attachment" || carried.source === "evidence") {
event.preventDefault();
releaseRef.current?.(carried);
}
carryRef.current = null;
setCarry(null);
return;
}
if (!dragRef.current?.html5) return;
place(event);
finishDragRef.current(dragRef.current);
@@ -1456,6 +1483,125 @@ export function ContentBoard({
}, 0);
}
function beginCarry(payload) {
carryRef.current = payload;
setCarry(payload);
}
function endCarry() {
carryRef.current = null;
setCarry(null);
}
function bindingByElement(elementId) {
return source.find((item) => item.element?.id === elementId) || null;
}
function dispatchOf(dispatchId) {
for (const item of source) {
const found = (item.correspondence?.dispatches || []).find((entry) => entry.id === dispatchId);
if (found) return { host: item, dispatch: found };
}
return null;
}
const correspondenceScope = () => scopeBody(actionContext(), containerKind, containerId);
async function releaseToList(payload) {
setPending(true);
setError("");
try {
const scope = correspondenceScope();
if (payload.source === "attachment") {
const host = bindingByElement(payload.hostElementId);
if (!host) return;
await api(`/api/v1/elements/${host.element.id}/attachments/${payload.elementId}/detach`, {
method: "POST",
body: { expected_version: host.element.version, ...scope },
});
} else if (payload.source === "evidence") {
const found = dispatchOf(payload.dispatchId);
if (!found) return;
await api(`/api/v1/dispatches/${found.dispatch.id}/evidence/${payload.elementId}/detach`, {
method: "POST",
body: { expected_version: found.dispatch.version, ...scope },
});
}
const item = bindingByElement(payload.elementId);
if (item?.correspondence?.fold) {
await restoreFold(item.id, item.element.version, scope);
}
onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}
releaseRef.current = releaseToList;
async function dropAttachment(hostBinding, payload) {
if (!payload || payload.elementId === hostBinding.element.id) return;
const already = (hostBinding.correspondence?.attachments || []).some((item) => item.element_id === payload.elementId);
if (payload.source === "attachment" && payload.hostElementId === hostBinding.element.id) return;
if (already) {
setError("Diese Anlage ist dem Schreiben bereits zugeordnet.");
return;
}
setPending(true);
setError("");
try {
const scope = correspondenceScope();
if (payload.source === "attachment") {
const from = bindingByElement(payload.hostElementId);
if (!from) return;
await api(`/api/v1/elements/${from.element.id}/attachments/${payload.elementId}/detach`, {
method: "POST",
body: { expected_version: from.element.version, ...scope },
});
}
if (payload.source === "evidence") {
const found = dispatchOf(payload.dispatchId);
if (!found) return;
await api(`/api/v1/dispatches/${found.dispatch.id}/evidence/${payload.elementId}/detach`, {
method: "POST",
body: { expected_version: found.dispatch.version, ...scope },
});
}
await api(`/api/v1/elements/${hostBinding.element.id}/attachments`, {
method: "POST",
body: {
expected_version: hostBinding.element.version,
attachment_element_ids: [payload.elementId],
fold: "attachment",
...scope,
},
});
onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}
function dropReceipt(hostBinding, payload, dispatch) {
if (!payload || payload.elementId === hostBinding.element.id) return;
if (payload.source === "evidence" && dispatch && payload.dispatchId === dispatch.id) return;
const item = bindingByElement(payload.elementId);
const found = payload.source === "evidence" ? dispatchOf(payload.dispatchId) : null;
setDialog({
type: "evidence",
binding: item || { element: { id: payload.elementId, title: payload.title || "Unterlage", version: 1 } },
hosts: [hostBinding],
dispatchId: dispatch ? dispatch.id : "",
replace: found && (!dispatch || found.dispatch.id !== dispatch.id)
? { dispatchId: found.dispatch.id, version: found.dispatch.version }
: null,
});
}
function beginDrag(event, drag) {
if (pending || (event.button != null && event.button !== 0)) return;
event.preventDefault();
@@ -1509,7 +1655,7 @@ export function ContentBoard({
</select>
</label>
<button type="button" disabled={pending || picked.size === 0} onClick={() => placeMany([...picked], pickTarget)}>Einordnen</button>
<button type="button" disabled={pending || picked.size === 0} onClick={() => setDialog({ type: "bulk" })}>Als Anlagen zuordnen</button>
<button type="button" disabled={pending || picked.size === 0} onClick={() => setDialog({ type: "bulk" })}>Als Anlagen an ein Schriftstück</button>
<button type="button" className="quiet" onClick={() => { setPicking(false); setPicked(new Set()); }}>Auswahl beenden</button>
</div>
) : null}
@@ -1520,34 +1666,54 @@ export function ContentBoard({
) : (
<p className="muted">Noch keine Unterlage und keine Notiz.</p>
)}
<Modal open={dialog?.type === "attach" || dialog?.type === "bulk"} title="Anlagen zuordnen" onClose={() => setDialog(null)}>
<Modal open={dialog?.type === "attach" || dialog?.type === "bulk"} title="Anlagen" onClose={() => setDialog(null)}>
{dialog?.type === "bulk" && !dialog.host ? (
<form className="stack" onSubmit={(event) => {
<form className="stack" onSubmit={async (event) => {
event.preventDefault();
const host = listed.find((item) => item.id === new FormData(event.currentTarget).get("host"));
if (!host) return;
const candidates = listed.filter((item) => picked.has(item.id) && item.id !== host.id);
setDialog({ type: "attach", host, candidates });
const host = source.find((item) => item.id === new FormData(event.currentTarget).get("host"));
const ids = [...picked].map((id) => source.find((item) => item.id === id)).filter((item) => item && item.id !== host?.id).map((item) => item.element.id);
if (!host || !ids.length) return;
setPending(true);
setError("");
try {
await api(`/api/v1/elements/${host.element.id}/attachments`, {
method: "POST",
body: {
expected_version: host.element.version,
attachment_element_ids: ids,
fold: "attachment",
...scopeBody(actionContext(), containerKind, containerId),
},
});
setDialog(null);
setPicked(new Set());
setPicking(false);
onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}}>
<p>Hauptschriftstück für die ausgewählten Unterlagen wählen. Die Kapitel bleiben bestehen, bis sie separat aufgelöst werden.</p>
<p>Die ausgewählten Unterlagen werden Anlagen dieses Schriftstücks und verschwinden aus der normalen Liste. Zurückziehen legt sie wieder dorthin.</p>
<label>
Hauptschriftstück
Schriftstück
<select name="host" defaultValue="">
<option value="">Schriftstück wählen</option>
{listed.map((item) => <option key={item.id} value={item.id}>{item.element.title}</option>)}
{source.map((item) => <option key={item.id} value={item.id}>{item.element.title}</option>)}
</select>
</label>
<button type="submit">Weiter zur Reihenfolge</button>
<button type="submit" disabled={pending}>Als Anlagen zuordnen</button>
</form>
) : null}
{dialog?.type === "attach" && dialog.host ? (
<AttachDialog
host={dialog.host}
candidates={dialog.candidates}
host={source.find((item) => item.id === dialog.host.id) || dialog.host}
candidates={source.filter((item) => item.element.id !== (source.find((entry) => entry.id === dialog.host.id) || dialog.host).element.id)}
scope={scopeBody(actionContext(), containerKind, containerId)}
pending={pending}
onClose={() => setDialog(null)}
onDone={() => { setDialog(null); setPicked(new Set()); setPicking(false); onChange(); }}
onDone={() => onChange()}
/>
) : null}
</Modal>
@@ -1562,11 +1728,34 @@ export function ContentBoard({
/>
) : null}
</Modal>
<Modal open={dialog?.type === "evidence"} title="Als Versandnachweis zuordnen" onClose={() => setDialog(null)}>
<Modal open={dialog?.type === "receipt-source"} title="Beleg wählen" onClose={() => setDialog(null)}>
{dialog?.type === "receipt-source" ? (
<div className="stack">
<p>Unterlage aus diesem Vorgang als Beleg von <strong>{dialog.host.element.title}</strong>.</p>
<ul className="choice-list choice-list--scroll">
{source.filter((item) => item.element.id !== dialog.host.element.id).map((item) => (
<li key={item.id}>
<span>{item.element.title}</span>
<button type="button" onClick={() => setDialog({
type: "evidence",
binding: item,
hosts: [dialog.host],
dispatchId: dialog.dispatchId,
})}>Als Beleg</button>
</li>
))}
</ul>
{!source.filter((item) => item.element.id !== dialog.host.element.id).length ? <p className="muted">Keine weitere Unterlage.</p> : null}
</div>
) : null}
</Modal>
<Modal open={dialog?.type === "evidence"} title="Beleg zuordnen" onClose={() => setDialog(null)}>
{dialog?.type === "evidence" ? (
<EvidenceDialog
element={dialog.binding.element}
hosts={listed.filter((item) => item.element.id !== dialog.binding.element.id)}
hosts={dialog.hosts || source.filter((item) => item.element.id !== dialog.binding.element.id)}
presetDispatchId={dialog.dispatchId}
replace={dialog.replace || null}
scope={scopeBody(actionContext(), containerKind, containerId)}
pending={pending}
onClose={() => setDialog(null)}
@@ -1749,11 +1938,32 @@ export function ContentBoard({
<span className="handle__grip" aria-hidden="true" />
</button>
) : null}
<EntryMark element={element} context={context} />
<EntryMark
element={element}
context={context}
assignable={canEdit && !pending && !picking}
onAssignStart={(event) => {
event.stopPropagation();
beginCarry({
source: "list",
elementId: element.id,
bindingId: binding.id,
title: element.title,
});
writeAssign(event, {
source: "list",
elementId: element.id,
bindingId: binding.id,
title: element.title,
});
}}
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}
>
@@ -1770,73 +1980,56 @@ export function ContentBoard({
<BezugMenu element={element} source={source} onOpen={onOpen} itemHref={itemHref} canEdit={canEdit} onClearBezug={clearBezug} />
</div>
{text ? (
<Link className="preview-row__text" to={href} onClick={openFromList}>{text}</Link>
<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}
{(binding.correspondence?.attachments?.length || binding.correspondence?.dispatches?.length) ? (
<button
type="button"
className="quiet unit-toggle"
aria-expanded={openUnits.has(binding.id)}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
setOpenUnits((current) => {
const next = new Set(current);
if (next.has(binding.id)) next.delete(binding.id);
else next.add(binding.id);
return next;
});
}}
>
{openUnits.has(binding.id) ? "Anlagen zuklappen" : "Anlagen"}
</button>
) : null}
{openUnits.has(binding.id) ? (
<UnitDetail
binding={binding}
canEdit={canEdit}
pending={pending}
scope={scopeBody(actionContext(), containerKind, containerId)}
onOpen={(elementId) => {
const found = source.find((item) => item.element?.id === elementId);
if (found) onOpen?.(found);
}}
onDetach={async (elementId) => {
setPending(true);
setError("");
try {
await api(`/api/v1/elements/${element.id}/attachments/${elementId}/detach`, {
method: "POST",
body: {
expected_version: element.version,
...scopeBody(actionContext(), containerKind, containerId),
},
});
onChange();
} catch (err) {
setError(err.message);
} finally {
setPending(false);
}
}}
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);
}
}}
/>
) : null}
<UnitDetail
binding={binding}
canEdit={canEdit}
pending={pending}
carry={carry}
scope={scopeBody(actionContext(), containerKind, containerId)}
onCarryStart={beginCarry}
onCarryEnd={endCarry}
onOpen={(elementId) => {
const found = source.find((item) => item.element?.id === elementId);
if (found) onOpen?.(found);
}}
onDropAttachment={(payload) => dropAttachment(binding, payload)}
onDropReceipt={(payload, dispatch) => dropReceipt(binding, payload, dispatch)}
onPickAttachments={() => setDialog({ type: "attach", host: binding })}
onPickReceipt={(dispatch) => setDialog({
type: "receipt-source",
host: binding,
dispatchId: dispatch ? dispatch.id : "",
})}
onDocumentDispatch={() => setDialog({ type: "dispatch", host: binding })}
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>
<EntryActions
element={element}
@@ -1856,11 +2049,7 @@ export function ContentBoard({
onRemove={removeBinding}
onMove={move}
onPlaceChapter={placeChapter}
onAttach={(row) => setDialog({
type: "attach",
host: row,
candidates: listed.filter((item) => item.element.id !== row.element.id && !(row.correspondence?.attachments || []).some((entry) => entry.element_id === item.element.id)),
})}
onAttach={(row) => setDialog({ type: "attach", host: row })}
onDispatch={(row) => setDialog({ type: "dispatch", host: row })}
onEvidence={(row) => setDialog({ type: "evidence", binding: row })}
/>
+278 -104
View File
@@ -33,8 +33,8 @@ export function unitMarks(binding) {
if (dispatches.length === 1) parts.push(channelWord(dispatches[0].channel));
else if (dispatches.length > 1) parts.push(`${dispatches.length} Versände`);
const evidence = dispatches.reduce((sum, item) => sum + (item.evidence || []).length, 0);
if (evidence === 1) parts.push("Nachweis");
else if (evidence > 1) parts.push(`${evidence} Nachweise`);
if (evidence === 1) parts.push("1 Beleg");
else if (evidence > 1) parts.push(`${evidence} Belege`);
return parts.join(" · ");
}
@@ -62,88 +62,123 @@ function fieldBody(scope, extra) {
return body;
}
export function AttachDialog({ host, candidates, scope, pending, onClose, onDone }) {
const initial = candidates.map((item) => item.element.id);
const [order, setOrder] = useState(initial);
const [chosen, setChosen] = useState(() => new Set(initial));
const [fold, setFold] = useState("attachment");
const [error, setError] = useState("");
export const ASSIGN_MIME = "application/x-tsumugu-item";
function move(id, delta) {
setOrder((current) => {
const index = current.indexOf(id);
const target = index + delta;
if (index < 0 || target < 0 || target >= current.length) return current;
const next = [...current];
const [item] = next.splice(index, 1);
next.splice(target, 0, item);
return next;
});
export const RECEIPT_ROLES = [
["email", "E-Mail"],
["submission", "Einlieferungsbeleg"],
["delivery", "Zustellung oder Versandbestätigung"],
["other", "Sonstiger Beleg"],
];
export function receiptRoleLabel(role, fallback = "") {
return RECEIPT_ROLES.find((item) => item[0] === role)?.[1] || fallback || role;
}
export function writeAssign(event, payload) {
event.dataTransfer.effectAllowed = "copyMove";
event.dataTransfer.setData(ASSIGN_MIME, JSON.stringify(payload));
event.dataTransfer.setData("text/plain", payload.title || "");
}
export function readAssign(event) {
const raw = event.dataTransfer.getData(ASSIGN_MIME);
if (!raw) return null;
try {
return JSON.parse(raw);
} catch {
return null;
}
}
async function save(event) {
event.preventDefault();
const ids = order.filter((id) => chosen.has(id));
if (!ids.length) {
setError("Es ist keine Anlage ausgewählt.");
return;
}
function assignEvent(event) {
return [...(event.dataTransfer?.types || [])].includes(ASSIGN_MIME);
}
export function AttachDialog({ host, candidates, scope, pending, onClose, onDone }) {
const current = host.correspondence?.attachments || [];
const taken = new Set(current.map((item) => item.element_id));
const [query, setQuery] = useState("");
const [error, setError] = useState("");
const [busy, setBusy] = useState(false);
const needle = query.trim().toLowerCase();
const available = candidates.filter((item) => {
if (taken.has(item.element.id) || item.element.id === host.element.id) return false;
if (!needle) return true;
return item.element.title.toLowerCase().includes(needle);
});
async function add(elementId) {
setBusy(true);
setError("");
try {
await api(`/api/v1/elements/${host.element.id}/attachments`, {
method: "POST",
body: fieldBody(scope, {
expected_version: host.element.version,
attachment_element_ids: ids,
fold,
attachment_element_ids: [elementId],
fold: "attachment",
}),
});
onDone();
} catch (err) {
setError(err.message);
} finally {
setBusy(false);
}
}
async function remove(elementId) {
setBusy(true);
setError("");
try {
await api(`/api/v1/elements/${host.element.id}/attachments/${elementId}/detach`, {
method: "POST",
body: fieldBody(scope, { expected_version: host.element.version }),
});
onDone();
} catch (err) {
setError(err.message);
} finally {
setBusy(false);
}
}
return (
<form className="stack" onSubmit={save}>
<p>Anlagen von <strong>{host.element.title}</strong>. Die Dateien bleiben an ihrem Ort. Die aktuelle Liste ist nur die Zuordnung in diesem Zusammenhang.</p>
<ol className="choice-list">
{order.map((id, index) => {
const item = candidates.find((entry) => entry.element.id === id);
if (!item) return null;
return (
<li key={id}>
<label>
<input
type="checkbox"
checked={chosen.has(id)}
onChange={() => setChosen((current) => {
const next = new Set(current);
if (next.has(id)) next.delete(id);
else next.add(id);
return next;
})}
/>
<span>{item.element.title}</span>
<span className="muted">{formatDate(item.element.dates?.document_on)}</span>
</label>
<span className="choice-list__move">
<button type="button" disabled={index === 0} onClick={() => move(id, -1)} aria-label={`${item.element.title} nach oben`}>↑</button>
<button type="button" disabled={index === order.length - 1} onClick={() => move(id, 1)} aria-label={`${item.element.title} nach unten`}>↓</button>
</span>
<div className="stack">
<p>Anlagen von <strong>{host.element.title}</strong>. Bereits zugeordnete Anlagen stehen oben. Eine weitere Unterlage aus diesem Vorgang wird daraus genommen und nur noch hier gezeigt.</p>
<section>
<h3>Zugeordnet</h3>
{current.length ? (
<ol className="choice-list">
{current.map((item, index) => (
<li key={item.id}>
<span>{index + 1}. {item.title}</span>
<span className="muted">{formatDate(item.document_on)}</span>
<button type="button" className="quiet" disabled={pending || busy} onClick={() => remove(item.element_id)}>Lösen</button>
</li>
))}
</ol>
) : <p className="muted">Noch keine Anlage an diesem Schriftstück.</p>}
</section>
<label>
Weitere Unterlage
<input value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Titel suchen" />
</label>
{available.length ? (
<ul className="choice-list choice-list--scroll">
{available.map((item) => (
<li key={item.id}>
<span>{item.element.title}</span>
<span className="muted">{formatDate(item.element.dates?.document_on)}</span>
<button type="button" disabled={pending || busy} onClick={() => add(item.element.id)}>Als Anlage</button>
</li>
);
})}
</ol>
<fieldset>
<legend>Vorkommen in der Liste</legend>
<label><input type="radio" name="fold" checked={fold === "keep"} onChange={() => setFold("keep")} /> Zusätzlich als eigenständige Einträge behalten</label>
<label><input type="radio" name="fold" checked={fold === "attachment"} onChange={() => setFold("attachment")} /> Nur in der Anlagenansicht zeigen</label>
</fieldset>
))}
</ul>
) : <p className="muted">Keine weitere passende Unterlage in diesem Vorgang.</p>}
{error ? <p className="error">{error}</p> : null}
<button type="submit" disabled={pending}>Anlagen zuordnen</button>
<button type="button" className="quiet" onClick={onClose}>Abbrechen</button>
</form>
<button type="button" className="quiet" onClick={onClose}>Schließen</button>
</div>
);
}
@@ -251,12 +286,14 @@ export function DispatchDialog({ host, scope, pending, onClose, onDone }) {
);
}
export function EvidenceDialog({ element, hosts, scope, pending, onClose, onDone }) {
export function EvidenceDialog({ element, hosts, scope, pending, presetDispatchId, replace = null, onClose, onDone }) {
const [hostId, setHostId] = useState(hosts[0]?.element.id || "");
const host = hosts.find((item) => item.element.id === hostId) || null;
const [dispatchId, setDispatchId] = useState(host?.correspondence?.dispatches?.[0]?.id || "");
const [dispatchId, setDispatchId] = useState(
presetDispatchId !== undefined ? presetDispatchId : (host?.correspondence?.dispatches?.[0]?.id || ""),
);
const [role, setRole] = useState("email");
const [fold, setFold] = useState("keep");
const [fold, setFold] = useState("evidence");
const [channel, setChannel] = useState("email");
const [sentOn, setSentOn] = useState("");
const [counterpart, setCounterpart] = useState("");
@@ -268,6 +305,12 @@ export function EvidenceDialog({ element, hosts, scope, pending, onClose, onDone
if (!host) return;
setError("");
try {
if (replace?.dispatchId && replace.dispatchId !== dispatchId) {
await api(`/api/v1/dispatches/${replace.dispatchId}/evidence/${element.id}/detach`, {
method: "POST",
body: fieldBody(scope, { expected_version: replace.version }),
});
}
let target = dispatchId;
if (!target) {
const created = await api(`/api/v1/elements/${host.element.id}/dispatches`, {
@@ -306,7 +349,7 @@ export function EvidenceDialog({ element, hosts, scope, pending, onClose, onDone
return (
<form className="stack" onSubmit={save}>
<p><strong>{element.title}</strong> als Nachweis zuordnen. Das Original bleibt vollständig erhalten.</p>
<p><strong>{element.title}</strong> als Beleg zu diesem Versand. E-Mail, Notiz, Foto und Paperless-Dokument bleiben das Original. An einem Versand können mehrere Belege liegen.</p>
<label>
Hauptschriftstück
<select value={hostId} onChange={(event) => {
@@ -346,20 +389,17 @@ export function EvidenceDialog({ element, hosts, scope, pending, onClose, onDone
<label>
Rolle
<select value={role} onChange={(event) => setRole(event.target.value)}>
<option value="email">E-Mail/Versanddokumentation</option>
<option value="submission">Einlieferung</option>
<option value="delivery">Zustellung</option>
<option value="other">sonstiger Nachweis</option>
{RECEIPT_ROLES.map(([value, label]) => <option key={value} value={value}>{label}</option>)}
</select>
</label>
<fieldset>
<legend>Darstellung hier</legend>
<label><input type="radio" name="evidence-fold" checked={fold === "evidence"} onChange={() => setFold("evidence")} /> Hier als Nachweis darstellen</label>
<label><input type="radio" name="evidence-fold" checked={fold === "keep"} onChange={() => setFold("keep")} /> Zusätzlich als eigenständigen Eintrag behalten</label>
<legend>Darstellung in der Liste</legend>
<label><input type="radio" name="evidence-fold" checked={fold === "evidence"} onChange={() => setFold("evidence")} /> Nur am Versand zeigen</label>
<label><input type="radio" name="evidence-fold" checked={fold === "keep"} onChange={() => setFold("keep")} /> Zusätzlich als eigenen Eintrag behalten</label>
</fieldset>
{result ? <ComparisonList comparisons={result.comparisons || []} state={result.source_state} reason={result.gap_reason} /> : null}
{error ? <p className="error">{error}</p> : null}
<button type="submit" disabled={pending || !host}>Nachweis zuordnen</button>
<button type="submit" disabled={pending || !host}>Beleg zuordnen</button>
<button type="button" className="quiet" onClick={onClose}>Schließen</button>
</form>
);
@@ -385,32 +425,130 @@ export function ComparisonList({ comparisons = [], state, reason }) {
);
}
export function UnitDetail({ binding, canEdit, pending, scope, onOpen, onDetach, onUnfold }) {
function DropWell({ label, hint, armed, onDrop, onPick }) {
const [over, setOver] = useState(false);
return (
<div
className={["drop-well", armed ? "is-armed" : "", over ? "is-over" : ""].filter(Boolean).join(" ")}
onDragEnter={(event) => {
if (!assignEvent(event)) return;
event.preventDefault();
event.stopPropagation();
setOver(true);
}}
onDragOver={(event) => {
if (!assignEvent(event)) return;
event.preventDefault();
event.stopPropagation();
event.dataTransfer.dropEffect = "move";
}}
onDragLeave={(event) => {
if (event.currentTarget.contains(event.relatedTarget)) return;
setOver(false);
}}
onDrop={(event) => {
if (!assignEvent(event)) return;
event.preventDefault();
event.stopPropagation();
setOver(false);
const payload = readAssign(event);
if (payload) onDrop(payload);
}}
>
<span>{over ? hint : label}</span>
{onPick ? <button type="button" className="quiet" onClick={onPick}>Wählen</button> : null}
</div>
);
}
function chipDrag(enabled, payload, onCarryStart, onCarryEnd) {
return {
role: "button",
tabIndex: enabled ? 0 : undefined,
draggable: enabled,
onDragStart(event) {
event.stopPropagation();
writeAssign(event, payload);
onCarryStart?.(payload);
},
onDragEnd() {
onCarryEnd?.();
},
};
}
export function UnitDetail({
binding,
canEdit,
pending,
scope,
carry,
onOpen,
onDetach,
onDetachEvidence,
onUnfold,
onCarryStart,
onCarryEnd,
onDropAttachment,
onDropReceipt,
onPickAttachments,
onPickReceipt,
}) {
const pack = binding.correspondence || {};
const attachments = pack.attachments || [];
const dispatches = pack.dispatches || [];
if (!attachments.length && !dispatches.length && !(pack.hosts || []).length) return null;
const show = canEdit || attachments.length || dispatches.length || (pack.hosts || []).length;
if (!show) return null;
const armed = Boolean(carry && carry.elementId !== binding.element.id);
if (!attachments.length && !dispatches.length) {
if (!canEdit) return null;
return (
<div className="use-strip">
<DropWell label="Anlage hier ablegen" hint="Als Anlage zuordnen" armed={armed} onDrop={onDropAttachment} onPick={onPickAttachments} />
<DropWell label="Beleg hier ablegen" hint="Versand mit diesem Beleg anlegen" armed={armed} onDrop={(payload) => onDropReceipt(payload, null)} onPick={() => onPickReceipt(null)} />
</div>
);
}
return (
<div className="unit-detail">
{attachments.length ? (
<section>
<h4>Anlagen</h4>
<section>
<h4>Anlagen</h4>
{canEdit ? (
<DropWell
label="Anlage hier ablegen"
hint="Als Anlage zuordnen"
armed={armed}
onDrop={onDropAttachment}
onPick={onPickAttachments}
/>
) : null}
{attachments.length ? (
<ol>
{attachments.map((item, index) => (
<li key={item.id}>
<li key={item.id} className="use-chip">
<span
className="use-chip__grip"
aria-label={`${item.title} aus den Anlagen ziehen`}
{...chipDrag(canEdit && !pending, {
source: "attachment",
elementId: item.element_id,
hostElementId: binding.element.id,
title: item.title,
}, onCarryStart, onCarryEnd)}
/>
<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)}>Anlage lösen</button>
<button type="button" className="quiet" disabled={pending} onClick={() => onDetach(item.element_id)}>In die Liste</button>
) : null}
</li>
))}
</ol>
</section>
) : null}
) : null}
</section>
{dispatches.map((item) => (
<section key={item.id}>
<h4>
@@ -422,40 +560,76 @@ export function UnitDetail({ binding, canEdit, pending, scope, onOpen, onDetach,
{item.completeness === "secured" ? "Inhaltsstand gesichert." : null}
{item.completeness === "partial" ? "Inhaltsstand nur teilweise gesichert." : null}
{item.completeness === "gap" ? "Kein vollständiger gesicherter Inhaltsstand." : null}
{item.recorded_at ? ` Erfasst ${formatDate(item.recorded_at.slice(0, 10))}.` : ""}
</p>
<ol>
{item.items.map((part) => (
<li key={part.id}>
<span>{part.role === "host" ? "Schreiben" : "Anlage"}: {part.title}</span>
<span className="muted">Dokumentdatum {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)}>Gesicherte Fassung</a>
) : <span>Gesicherte Fassung</span>}
</li>
))}
</ol>
{canEdit ? (
<DropWell
label="Beleg hier ablegen"
hint="Als Beleg dieses Versands"
armed={armed}
onDrop={(payload) => onDropReceipt(payload, item)}
onPick={() => onPickReceipt(item)}
/>
) : null}
{item.evidence?.length ? (
<ul>
{item.evidence.map((proof) => (
<li key={proof.id}>
<li key={proof.id} className="use-chip">
<span
className="use-chip__grip"
aria-label={`${proof.title} aus den Belegen ziehen`}
{...chipDrag(canEdit && !pending, {
source: "evidence",
elementId: proof.element_id,
dispatchId: item.id,
version: item.version,
title: proof.title,
}, onCarryStart, onCarryEnd)}
/>
<button type="button" className="quiet" onClick={() => onOpen(proof.element_id)}>
{proof.role_label}: {proof.title}
{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}
<ComparisonList comparisons={proof.comparisons} state={proof.source_state} reason={proof.gap_reason} />
{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)}>
Wieder als eigenständigen Eintrag zeigen
Zusätzlich in der Liste zeigen
</button>
) : null}
</li>
))}
</ul>
) : <p className="muted">Vom Nutzer dokumentiert, noch ohne Nachweis.</p>}
) : null}
<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">Dokumentdatum {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>
))}
{canEdit ? (
<DropWell
label="Beleg für einen weiteren Versand"
hint="Neuen Versand mit diesem Beleg anlegen"
armed={armed}
onDrop={(payload) => onDropReceipt(payload, null)}
onPick={() => onPickReceipt(null)}
/>
) : null}
</div>
);
}
@@ -483,10 +657,10 @@ export function Chronology({ bindings, direction, itemHref, selectedId, onOpen }
dispatch.undated ? "Versand undatiert" : `Versanddatum ${formatDate(dispatch.sent_on)}`,
dispatch.channel_label,
(dispatch.evidence || []).length === 1
? "1 Nachweis"
? "1 Beleg"
: (dispatch.evidence || []).length
? `${dispatch.evidence.length} Nachweise`
: "ohne Nachweis",
? `${dispatch.evidence.length} Belege`
: "ohne Beleg",
].join(" · "),
binding,
dispatch,
+25 -3
View File
@@ -1327,12 +1327,34 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
}
.choice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.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-detail, .comparison, .chrono { display: grid; gap: 6px; margin-top: 4px; }
.unit-detail h4, .chrono h3 { margin: 6px 0 0; font-size: 13px; }
.unit-detail ol, .unit-detail ul, .comparison ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 4px; }
.unit-detail, .comparison, .chrono { display: grid; gap: 8px; margin-top: 8px; }
.unit-detail h4, .chrono h3 { margin: 0; font-size: 13px; }
.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 ol, .unit-detail ul, .comparison ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.unit-detail li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; min-width: 0; max-width: 100%; }
.unit-detail li .muted { white-space: nowrap; }
.use-strip { display: grid; gap: 4px; margin-top: 6px; }
.use-strip .drop-well { min-height: 32px; padding-top: 0; padding-bottom: 0; background: transparent; }
.drop-well {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
min-height: 44px;
padding: 4px 8px 4px 12px;
border: 1px dashed var(--border);
border-radius: 8px;
color: var(--text2);
background: var(--surface);
}
.drop-well.is-armed { border-color: var(--brand); color: var(--text1); background: var(--accent-light); }
.drop-well.is-over { outline: 2px solid var(--brand); background: var(--accent-light); }
.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; }
.entry-mark[draggable="true"] { cursor: grab; }
.use-editions summary { cursor: pointer; color: var(--text2); font-size: 13px; }
.unit-toggle { min-height: 32px; }
.count { white-space: normal; }
.chapter-children { display: grid; gap: 8px; margin-top: 8px; }