Lege einen Beleg ohne Versandfassung ab und markiere das Zurueckziehen, damit der Drop an der Markierung ankommt und ein Nachweis kein E-Mail-Versand wird.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
9f5327f3be
commit
7846830765
6 files changed
+241
-158
No files matched your search
@@ -146,6 +146,7 @@ def post_dispatch(
|
|||||||
body.attachment_element_ids,
|
body.attachment_element_ids,
|
||||||
[item.model_dump() for item in body.evidence],
|
[item.model_dump() for item in body.evidence],
|
||||||
body.historical_gap,
|
body.historical_gap,
|
||||||
|
body.capture_editions,
|
||||||
request.app.state.settings.media_root,
|
request.app.state.settings.media_root,
|
||||||
request.state.cleanup_files,
|
request.state.cleanup_files,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -413,6 +413,7 @@ class DispatchIn(APIModel):
|
|||||||
attachment_element_ids: list[UUID] = Field(default_factory=list, max_length=100)
|
attachment_element_ids: list[UUID] = Field(default_factory=list, max_length=100)
|
||||||
evidence: list[EvidenceIn] = Field(default_factory=list, max_length=20)
|
evidence: list[EvidenceIn] = Field(default_factory=list, max_length=20)
|
||||||
historical_gap: bool = False
|
historical_gap: bool = False
|
||||||
|
capture_editions: bool = True
|
||||||
|
|
||||||
|
|
||||||
class DispatchEvidenceIn(APIModel):
|
class DispatchEvidenceIn(APIModel):
|
||||||
|
|||||||
@@ -196,11 +196,16 @@ def record_dispatch(
|
|||||||
attachment_ids: list[UUID],
|
attachment_ids: list[UUID],
|
||||||
evidence: list[dict],
|
evidence: list[dict],
|
||||||
historical_gap: bool,
|
historical_gap: bool,
|
||||||
|
capture_editions: bool,
|
||||||
media_root: str,
|
media_root: str,
|
||||||
cleanup: list[Path],
|
cleanup: list[Path],
|
||||||
) -> dict:
|
) -> dict:
|
||||||
if channel not in CHANNELS:
|
if channel not in CHANNELS:
|
||||||
raise unprocessable("Der Versandweg ist nicht vorgesehen.")
|
raise unprocessable("Der Versandweg ist nicht vorgesehen.")
|
||||||
|
if not capture_editions and attachment_ids:
|
||||||
|
raise unprocessable("Ein Beleg sichert das Schreiben nicht als Versandfassung.")
|
||||||
|
if not capture_editions and not evidence:
|
||||||
|
raise unprocessable("Ein Beleg braucht mindestens einen Nachweis.")
|
||||||
if len(attachment_ids) != len(set(attachment_ids)):
|
if len(attachment_ids) != len(set(attachment_ids)):
|
||||||
raise unprocessable("Dieselbe Anlage ist mehrfach im Versand genannt.")
|
raise unprocessable("Dieselbe Anlage ist mehrfach im Versand genannt.")
|
||||||
container_row, page, scope = open_container(conn, actor, context, placement, "edit")
|
container_row, page, scope = open_container(conn, actor, context, placement, "edit")
|
||||||
@@ -231,17 +236,19 @@ def record_dispatch(
|
|||||||
actor,
|
actor,
|
||||||
),
|
),
|
||||||
).fetchone()
|
).fetchone()
|
||||||
states = [_capture_item(conn, actor, dispatch, host, "host", 0, page, historical_gap, media_root, cleanup)]
|
states = []
|
||||||
ordered = [row for row in _uses(conn, scope, host_id) if row["attachment_element_id"] in set(attachment_ids)]
|
if capture_editions:
|
||||||
position_of = {item: index for index, item in enumerate(attachment_ids)}
|
states.append(_capture_item(conn, actor, dispatch, host, "host", 0, page, historical_gap, media_root, cleanup))
|
||||||
ordered.sort(key=lambda row: position_of[row["attachment_element_id"]])
|
ordered = [row for row in _uses(conn, scope, host_id) if row["attachment_element_id"] in set(attachment_ids)]
|
||||||
for index, row in enumerate(ordered, start=1):
|
position_of = {item: index for index, item in enumerate(attachment_ids)}
|
||||||
element = _readable(conn, actor, row["attachment_element_id"], page)
|
ordered.sort(key=lambda row: position_of[row["attachment_element_id"]])
|
||||||
if element is None:
|
for index, row in enumerate(ordered, start=1):
|
||||||
raise not_found()
|
element = _readable(conn, actor, row["attachment_element_id"], page)
|
||||||
states.append(
|
if element is None:
|
||||||
_capture_item(conn, actor, dispatch, element, "attachment", index, page, historical_gap, media_root, cleanup)
|
raise not_found()
|
||||||
)
|
states.append(
|
||||||
|
_capture_item(conn, actor, dispatch, element, "attachment", index, page, historical_gap, media_root, cleanup)
|
||||||
|
)
|
||||||
evidence_rows = []
|
evidence_rows = []
|
||||||
for item in evidence:
|
for item in evidence:
|
||||||
evidence_rows.append(
|
evidence_rows.append(
|
||||||
@@ -260,7 +267,7 @@ def record_dispatch(
|
|||||||
log=False,
|
log=False,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
completeness = _completeness(states)
|
completeness = _completeness(states) if capture_editions else "secured"
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"UPDATE dispatches SET completeness = %s, updated_at = now() WHERE id = %s",
|
"UPDATE dispatches SET completeness = %s, updated_at = now() WHERE id = %s",
|
||||||
(completeness, dispatch["id"]),
|
(completeness, dispatch["id"]),
|
||||||
@@ -314,7 +321,16 @@ def detach_dispatch_evidence(
|
|||||||
if deleted is None:
|
if deleted is None:
|
||||||
raise not_found()
|
raise not_found()
|
||||||
_clear_evidence_fold(conn, scope, element_id)
|
_clear_evidence_fold(conn, scope, element_id)
|
||||||
_log(conn, dispatch_id, actor, "Nachweis aus diesem Versand gelöst")
|
leftover_evidence = conn.execute(
|
||||||
|
"SELECT id FROM dispatch_evidence WHERE dispatch_id = %s", (dispatch_id,)
|
||||||
|
).fetchone()
|
||||||
|
leftover_items = conn.execute(
|
||||||
|
"SELECT id FROM dispatch_items WHERE dispatch_id = %s", (dispatch_id,)
|
||||||
|
).fetchone()
|
||||||
|
if leftover_evidence is None and leftover_items is None:
|
||||||
|
conn.execute("DELETE FROM dispatches WHERE id = %s", (dispatch_id,))
|
||||||
|
else:
|
||||||
|
_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)
|
audit(conn, actor, container_row["home_scope_id"], "dispatch_evidence_detached", "element", dispatch["host_element_id"], page)
|
||||||
|
|
||||||
|
|
||||||
@@ -1020,6 +1036,7 @@ def _public_evidence(conn, proof, element, page: Ctx) -> dict:
|
|||||||
"id": str(proof["id"]),
|
"id": str(proof["id"]),
|
||||||
"element_id": str(element["id"]),
|
"element_id": str(element["id"]),
|
||||||
"title": element["title"],
|
"title": element["title"],
|
||||||
|
"kind": element["kind"],
|
||||||
"role": proof["role"],
|
"role": proof["role"],
|
||||||
"role_label": EVIDENCE_ROLES[proof["role"]],
|
"role_label": EVIDENCE_ROLES[proof["role"]],
|
||||||
"source_state": proof["source_state"],
|
"source_state": proof["source_state"],
|
||||||
|
|||||||
+144
-79
@@ -26,7 +26,6 @@ import {
|
|||||||
scopeBody,
|
scopeBody,
|
||||||
StructureAssignDialog,
|
StructureAssignDialog,
|
||||||
UnitDetail,
|
UnitDetail,
|
||||||
writeAssign,
|
|
||||||
} from "./correspondence.jsx";
|
} from "./correspondence.jsx";
|
||||||
|
|
||||||
export function formatDate(value) {
|
export function formatDate(value) {
|
||||||
@@ -890,12 +889,10 @@ function EntryMark({ element, context, assignable = false, dropId = "", onAssign
|
|||||||
<span
|
<span
|
||||||
className={url ? "entry-mark entry-mark--photo" : "entry-mark"}
|
className={url ? "entry-mark entry-mark--photo" : "entry-mark"}
|
||||||
data-use-drop={dropId || undefined}
|
data-use-drop={dropId || undefined}
|
||||||
draggable={assignable}
|
|
||||||
role={assignable ? "button" : undefined}
|
role={assignable ? "button" : undefined}
|
||||||
tabIndex={assignable ? 0 : undefined}
|
tabIndex={assignable ? 0 : undefined}
|
||||||
aria-label={assignable ? `${element.title} als Anlage oder Beleg ziehen` : undefined}
|
aria-label={assignable ? `${element.title} als Anlage oder Beleg ziehen` : undefined}
|
||||||
onDragStart={assignable ? onAssignStart : undefined}
|
onPointerDown={assignable ? onAssignStart : undefined}
|
||||||
onDragEnd={assignable ? onAssignEnd : undefined}
|
|
||||||
>
|
>
|
||||||
{url ? <img className="entry-mark__photo" alt="" draggable={false} src={url} /> : (
|
{url ? <img className="entry-mark__photo" alt="" draggable={false} src={url} /> : (
|
||||||
<>
|
<>
|
||||||
@@ -1532,36 +1529,74 @@ export function ContentBoard({
|
|||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function beginCarry(payload) {
|
function beginCarryPointer(event, payload) {
|
||||||
carryRef.current = payload;
|
if (pending || (event.button != null && event.button !== 0)) return;
|
||||||
}
|
if (event.target.closest("button, a, input, textarea, select")) return;
|
||||||
|
event.stopPropagation();
|
||||||
function endCarry(event) {
|
const carried = {
|
||||||
const carried = carryRef.current;
|
...payload,
|
||||||
if (!carried) {
|
pointerId: event.pointerId,
|
||||||
|
anchorX: event.clientX,
|
||||||
|
anchorY: event.clientY,
|
||||||
|
moved: false,
|
||||||
|
useBindingId: "",
|
||||||
|
sourceNode: event.target.closest?.("[data-carry], .entry-mark") || event.target,
|
||||||
|
};
|
||||||
|
function pointOf(pointer) {
|
||||||
|
return document.elementFromPoint(pointer.clientX, pointer.clientY);
|
||||||
|
}
|
||||||
|
function track(pointer) {
|
||||||
|
if (carryRef.current !== carried || pointer.pointerId !== carried.pointerId) return;
|
||||||
|
if (Math.hypot(pointer.clientX - carried.anchorX, pointer.clientY - carried.anchorY) > 4) {
|
||||||
|
carried.moved = true;
|
||||||
|
if (carried.sourceNode) carried.sourceNode.dataset.dragged = "1";
|
||||||
|
}
|
||||||
|
if (!carried.moved) return;
|
||||||
|
const hit = pointOf(pointer);
|
||||||
|
const useId = useDropId(hit);
|
||||||
|
const ownChip = hit?.closest?.(`[data-carry="${carried.source}:${carried.elementId}"]`);
|
||||||
|
if (useId && useId !== carried.bindingId) {
|
||||||
|
carried.useBindingId = useId;
|
||||||
|
setIndicator({ kind: "use", bindingId: useId });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
carried.useBindingId = "";
|
||||||
|
const inside = Boolean(hit && rootRef.current?.contains(hit));
|
||||||
|
if (inside && !ownChip && (carried.source === "attachment" || carried.source === "evidence")) {
|
||||||
|
setIndicator({ kind: "release" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
setIndicator(null);
|
setIndicator(null);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
carryRef.current = null;
|
function finish(pointer) {
|
||||||
setIndicator(null);
|
if (pointer && pointer.pointerId !== carried.pointerId) return;
|
||||||
if (carried.settled) return;
|
window.removeEventListener("pointermove", track);
|
||||||
carried.settled = true;
|
window.removeEventListener("pointerup", finish);
|
||||||
const x = event?.clientX || 0;
|
window.removeEventListener("pointercancel", finish);
|
||||||
const y = event?.clientY || 0;
|
if (carryRef.current !== carried) return;
|
||||||
const pointOk = x > 0 || y > 0;
|
carryRef.current = null;
|
||||||
const moved = Math.hypot(x - (carried.anchorX || 0), y - (carried.anchorY || 0));
|
setIndicator(null);
|
||||||
if (pointOk && moved < 8 && !carried.useBindingId) return;
|
if (!carried.moved) return;
|
||||||
const hit = pointOk ? document.elementFromPoint(x, y) : null;
|
const hit = pointer ? pointOf(pointer) : null;
|
||||||
if (hit && rootRef.current && !rootRef.current.contains(hit)) return;
|
const useId = useDropId(hit) || carried.useBindingId;
|
||||||
if (!hit && !carried.useBindingId) return;
|
if (useId && useId !== carried.bindingId) {
|
||||||
const useId = hit ? useDropId(hit) : (carried.useBindingId || "");
|
placeUseRef.current?.(useId, carried);
|
||||||
if (useId && useId !== carried.bindingId) {
|
return;
|
||||||
placeUseRef.current?.(useId, carried);
|
}
|
||||||
return;
|
const inside = Boolean(hit && rootRef.current?.contains(hit));
|
||||||
|
if (!inside) return;
|
||||||
|
if (hit.closest?.(`[data-carry="${carried.source}:${carried.elementId}"]`)) return;
|
||||||
|
if (carried.source === "attachment" || carried.source === "evidence") releaseRef.current?.(carried);
|
||||||
|
}
|
||||||
|
carryRef.current = carried;
|
||||||
|
window.addEventListener("pointermove", track);
|
||||||
|
window.addEventListener("pointerup", finish);
|
||||||
|
window.addEventListener("pointercancel", finish);
|
||||||
|
try {
|
||||||
|
carried.sourceNode.setPointerCapture?.(event.pointerId);
|
||||||
|
} catch {
|
||||||
|
// Window listeners still follow the pointer.
|
||||||
}
|
}
|
||||||
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) {
|
function bindingByElement(elementId) {
|
||||||
@@ -1657,6 +1692,73 @@ export function ContentBoard({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function placeReceipt(hostBinding, payload, element) {
|
||||||
|
if (!payload || payload.elementId === hostBinding.element.id) return;
|
||||||
|
const role = element?.external?.source === "imap" ? "email" : "other";
|
||||||
|
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 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let expected = hostBinding.element.version;
|
||||||
|
if (payload.source === "attachment") {
|
||||||
|
const from = bindingByElement(payload.hostElementId);
|
||||||
|
if (from?.element.id === hostBinding.element.id) expected += 1;
|
||||||
|
}
|
||||||
|
const holder = (hostBinding.correspondence?.dispatches || []).find((item) => (
|
||||||
|
item.channel === "other"
|
||||||
|
&& !(item.items || []).some((part) => part.role === "host" || part.role === "attachment")
|
||||||
|
));
|
||||||
|
if (!holder) {
|
||||||
|
await api(`/api/v1/elements/${hostBinding.element.id}/dispatches`, {
|
||||||
|
method: "POST",
|
||||||
|
body: {
|
||||||
|
expected_version: expected,
|
||||||
|
channel: "other",
|
||||||
|
sent_on: null,
|
||||||
|
counterpart: null,
|
||||||
|
attachment_element_ids: [],
|
||||||
|
evidence: [{ element_id: payload.elementId, role, fold: "evidence" }],
|
||||||
|
historical_gap: false,
|
||||||
|
capture_editions: false,
|
||||||
|
...scope,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await api(`/api/v1/dispatches/${holder.id}/evidence`, {
|
||||||
|
method: "POST",
|
||||||
|
body: {
|
||||||
|
expected_version: holder.version,
|
||||||
|
element_id: payload.elementId,
|
||||||
|
role,
|
||||||
|
fold: "evidence",
|
||||||
|
...scope,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
onChange();
|
||||||
|
} catch (err) {
|
||||||
|
setError(err.message);
|
||||||
|
} finally {
|
||||||
|
setPending(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function openPlace(hostBindingId, payload) {
|
function openPlace(hostBindingId, payload) {
|
||||||
const host = source.find((item) => item.id === hostBindingId);
|
const host = source.find((item) => item.id === hostBindingId);
|
||||||
if (!host || !payload || host.element.id === payload.elementId) return;
|
if (!host || !payload || host.element.id === payload.elementId) return;
|
||||||
@@ -1692,7 +1794,8 @@ export function ContentBoard({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="contents" ref={rootRef}>
|
<div className={indicator?.kind === "release" ? "contents is-release-target" : "contents"} ref={rootRef}>
|
||||||
|
{indicator?.kind === "release" ? <div className="release-mark">In den Vorgang legen</div> : null}
|
||||||
<div className="content-toolbar">
|
<div className="content-toolbar">
|
||||||
<h2>{viewMode === "chronology" ? "Chronologie" : (activePath || listTitle || "Inhalte")} <span className="count">{shownCount}</span></h2>
|
<h2>{viewMode === "chronology" ? "Chronologie" : (activePath || listTitle || "Inhalte")} <span className="count">{shownCount}</span></h2>
|
||||||
<div className="content-toolbar__tools">
|
<div className="content-toolbar__tools">
|
||||||
@@ -1812,33 +1915,8 @@ export function ContentBoard({
|
|||||||
setDialog(null);
|
setDialog(null);
|
||||||
}}>Als Anlage</button>
|
}}>Als Anlage</button>
|
||||||
<button type="button" disabled={pending} onClick={async () => {
|
<button type="button" disabled={pending} onClick={async () => {
|
||||||
const payload = dialog.payload;
|
await placeReceipt(dialog.host, dialog.payload, dialog.binding.element);
|
||||||
if (payload.source === "attachment") {
|
setDialog(null);
|
||||||
const from = bindingByElement(payload.hostElementId);
|
|
||||||
if (from) {
|
|
||||||
setPending(true);
|
|
||||||
setError("");
|
|
||||||
try {
|
|
||||||
await api(`/api/v1/elements/${from.element.id}/attachments/${payload.elementId}/detach`, {
|
|
||||||
method: "POST",
|
|
||||||
body: { expected_version: from.element.version, ...correspondenceScope() },
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
setError(err.message);
|
|
||||||
setPending(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setPending(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const found = payload.source === "evidence" ? dispatchOf(payload.dispatchId) : null;
|
|
||||||
setDialog({
|
|
||||||
type: "evidence",
|
|
||||||
binding: dialog.binding,
|
|
||||||
hosts: [dialog.host],
|
|
||||||
dispatchId: dialog.host.correspondence?.dispatches?.[0]?.id || "",
|
|
||||||
replace: found ? { dispatchId: found.dispatch.id, version: found.dispatch.version } : null,
|
|
||||||
});
|
|
||||||
}}>Als Beleg</button>
|
}}>Als Beleg</button>
|
||||||
<button type="button" className="quiet" onClick={() => setDialog(null)}>Abbrechen</button>
|
<button type="button" className="quiet" onClick={() => setDialog(null)}>Abbrechen</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -2033,32 +2111,19 @@ export function ContentBoard({
|
|||||||
context={context}
|
context={context}
|
||||||
dropId={canEdit ? binding.id : ""}
|
dropId={canEdit ? binding.id : ""}
|
||||||
assignable={canEdit && !pending && !picking}
|
assignable={canEdit && !pending && !picking}
|
||||||
onAssignStart={(event) => {
|
onAssignStart={(event) => beginCarryPointer(event, {
|
||||||
event.stopPropagation();
|
source: "list",
|
||||||
beginCarry({
|
elementId: element.id,
|
||||||
source: "list",
|
bindingId: binding.id,
|
||||||
elementId: element.id,
|
title: element.title,
|
||||||
bindingId: binding.id,
|
})}
|
||||||
title: element.title,
|
|
||||||
anchorX: event.clientX,
|
|
||||||
anchorY: event.clientY,
|
|
||||||
});
|
|
||||||
writeAssign(event, {
|
|
||||||
source: "list",
|
|
||||||
elementId: element.id,
|
|
||||||
bindingId: binding.id,
|
|
||||||
title: element.title,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
onAssignEnd={endCarry}
|
|
||||||
/>
|
/>
|
||||||
<UnitDetail
|
<UnitDetail
|
||||||
binding={binding}
|
binding={binding}
|
||||||
canEdit={canEdit}
|
canEdit={canEdit}
|
||||||
pending={pending}
|
pending={pending}
|
||||||
scope={scopeBody(actionContext(), containerKind, containerId)}
|
scope={scopeBody(actionContext(), containerKind, containerId)}
|
||||||
onCarryStart={beginCarry}
|
onCarryStart={beginCarryPointer}
|
||||||
onCarryEnd={endCarry}
|
|
||||||
onOpen={(elementId) => {
|
onOpen={(elementId) => {
|
||||||
const found = source.find((item) => item.element?.id === elementId);
|
const found = source.find((item) => item.element?.id === elementId);
|
||||||
if (found) onOpen?.(found);
|
if (found) onOpen?.(found);
|
||||||
|
|||||||
@@ -45,18 +45,6 @@ export function hostMark(binding) {
|
|||||||
return `Dieselbe Unterlage · Anlage zu ${hosts.map((item) => item.title).join(", ")}`;
|
return `Dieselbe Unterlage · Anlage zu ${hosts.map((item) => item.title).join(", ")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function snapshotHref(dispatchId, itemId, scope) {
|
|
||||||
const search = new URLSearchParams({
|
|
||||||
context_kind: scope.context.kind,
|
|
||||||
context_id: scope.context.id,
|
|
||||||
});
|
|
||||||
if (scope.placement) {
|
|
||||||
search.set("placement_kind", scope.placement.kind);
|
|
||||||
search.set("placement_id", scope.placement.id);
|
|
||||||
}
|
|
||||||
return `/api/v1/dispatches/${dispatchId}/items/${itemId}/content?${search}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fieldBody(scope, extra) {
|
function fieldBody(scope, extra) {
|
||||||
const body = { ...extra, context: scope.context };
|
const body = { ...extra, context: scope.context };
|
||||||
if (scope.placement) body.placement = scope.placement;
|
if (scope.placement) body.placement = scope.placement;
|
||||||
@@ -76,6 +64,25 @@ export function receiptRoleLabel(role, fallback = "") {
|
|||||||
return RECEIPT_ROLES.find((item) => item[0] === role)?.[1] || fallback || role;
|
return RECEIPT_ROLES.find((item) => item[0] === role)?.[1] || fallback || role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function receiptCaption(proof) {
|
||||||
|
if (proof.role === "email" && proof.kind === "file") return "Beleg";
|
||||||
|
return receiptRoleLabel(proof.role, proof.role_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isShipment(item) {
|
||||||
|
const proofs = item.evidence || [];
|
||||||
|
if (item.channel === "other") return false;
|
||||||
|
if (proofs.length > 0 && proofs.every((proof) => proof.kind === "file")) return false;
|
||||||
|
return (item.items || []).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function receiptHeading(item) {
|
||||||
|
const who = item.counterpart ? ` · ${item.counterpart}` : "";
|
||||||
|
if (!isShipment(item)) return `${item.sent_on ? formatDate(item.sent_on) : "Beleg"}${who}`;
|
||||||
|
const when = item.undated ? "undatiert" : formatDate(item.sent_on);
|
||||||
|
return `Versand ${when} · ${item.channel_label}${who}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function writeAssign(event, payload) {
|
export function writeAssign(event, payload) {
|
||||||
event.dataTransfer.effectAllowed = "copyMove";
|
event.dataTransfer.effectAllowed = "copyMove";
|
||||||
event.dataTransfer.setData(ASSIGN_MIME, JSON.stringify(payload));
|
event.dataTransfer.setData(ASSIGN_MIME, JSON.stringify(payload));
|
||||||
@@ -145,10 +152,10 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
|
|||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [selected, setSelected] = useState(() => new Set());
|
const [selected, setSelected] = useState(() => new Set());
|
||||||
const [step, setStep] = useState("pick");
|
const [step, setStep] = useState("pick");
|
||||||
const [role, setRole] = useState("email");
|
const [role, setRole] = useState("other");
|
||||||
const [fold, setFold] = useState("evidence");
|
const [fold, setFold] = useState("evidence");
|
||||||
const [dispatchId, setDispatchId] = useState(host.correspondence?.dispatches?.[0]?.id || "");
|
const [dispatchId, setDispatchId] = useState(host.correspondence?.dispatches?.[0]?.id || "");
|
||||||
const [channel, setChannel] = useState("email");
|
const [channel, setChannel] = useState("other");
|
||||||
const [sentOn, setSentOn] = useState("");
|
const [sentOn, setSentOn] = useState("");
|
||||||
const [counterpart, setCounterpart] = useState("");
|
const [counterpart, setCounterpart] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
@@ -241,9 +248,10 @@ export function StructureAssignDialog({ host, bindings, chapters, scope, pending
|
|||||||
channel,
|
channel,
|
||||||
sent_on: sentOn || null,
|
sent_on: sentOn || null,
|
||||||
counterpart: counterpart.trim() || null,
|
counterpart: counterpart.trim() || null,
|
||||||
attachment_element_ids: (host.correspondence?.attachments || []).map((item) => item.element_id),
|
attachment_element_ids: [],
|
||||||
evidence: ids.map((id) => ({ element_id: id, role, fold })),
|
evidence: ids.map((id) => ({ element_id: id, role, fold })),
|
||||||
historical_gap: false,
|
historical_gap: false,
|
||||||
|
capture_editions: false,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -565,9 +573,9 @@ export function EvidenceDialog({ element, hosts, scope, pending, presetDispatchI
|
|||||||
const [dispatchId, setDispatchId] = useState(
|
const [dispatchId, setDispatchId] = useState(
|
||||||
presetDispatchId !== undefined ? presetDispatchId : (host?.correspondence?.dispatches?.[0]?.id || ""),
|
presetDispatchId !== undefined ? presetDispatchId : (host?.correspondence?.dispatches?.[0]?.id || ""),
|
||||||
);
|
);
|
||||||
const [role, setRole] = useState("email");
|
const [role, setRole] = useState("other");
|
||||||
const [fold, setFold] = useState("evidence");
|
const [fold, setFold] = useState("evidence");
|
||||||
const [channel, setChannel] = useState("email");
|
const [channel, setChannel] = useState("other");
|
||||||
const [sentOn, setSentOn] = useState("");
|
const [sentOn, setSentOn] = useState("");
|
||||||
const [counterpart, setCounterpart] = useState("");
|
const [counterpart, setCounterpart] = useState("");
|
||||||
const [result, setResult] = useState(null);
|
const [result, setResult] = useState(null);
|
||||||
@@ -593,9 +601,10 @@ export function EvidenceDialog({ element, hosts, scope, pending, presetDispatchI
|
|||||||
channel,
|
channel,
|
||||||
sent_on: sentOn || null,
|
sent_on: sentOn || null,
|
||||||
counterpart: counterpart.trim() || null,
|
counterpart: counterpart.trim() || null,
|
||||||
attachment_element_ids: (host.correspondence?.attachments || []).map((item) => item.element_id),
|
attachment_element_ids: [],
|
||||||
evidence: [{ element_id: element.id, role, fold }],
|
evidence: [{ element_id: element.id, role, fold }],
|
||||||
historical_gap: false,
|
historical_gap: false,
|
||||||
|
capture_editions: false,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
const proof = (created.evidence || []).find((item) => item.element_id === element.id);
|
const proof = (created.evidence || []).find((item) => item.element_id === element.id);
|
||||||
@@ -698,23 +707,11 @@ export function ComparisonList({ comparisons = [], state, reason }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function chipDrag(enabled, payload, onCarryStart, onCarryEnd) {
|
function chipPointer(enabled, payload, onCarryStart) {
|
||||||
|
if (!enabled) return {};
|
||||||
return {
|
return {
|
||||||
draggable: enabled,
|
onPointerDown(event) {
|
||||||
onDragStart(event) {
|
onCarryStart?.(event, payload);
|
||||||
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(event) {
|
|
||||||
onCarryEnd?.(event);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -743,13 +740,11 @@ export function UnitDetail({
|
|||||||
binding,
|
binding,
|
||||||
canEdit,
|
canEdit,
|
||||||
pending,
|
pending,
|
||||||
scope,
|
|
||||||
onOpen,
|
onOpen,
|
||||||
onDetach,
|
onDetach,
|
||||||
onDetachEvidence,
|
onDetachEvidence,
|
||||||
onUnfold,
|
onUnfold,
|
||||||
onCarryStart,
|
onCarryStart,
|
||||||
onCarryEnd,
|
|
||||||
children,
|
children,
|
||||||
}) {
|
}) {
|
||||||
const pack = binding.correspondence || {};
|
const pack = binding.correspondence || {};
|
||||||
@@ -761,12 +756,14 @@ export function UnitDetail({
|
|||||||
return typeof children === "function" ? children(null, null) : null;
|
return typeof children === "function" ? children(null, null) : null;
|
||||||
}
|
}
|
||||||
const evidenceCount = dispatches.reduce((sum, item) => sum + (item.evidence || []).length, 0);
|
const evidenceCount = dispatches.reduce((sum, item) => sum + (item.evidence || []).length, 0);
|
||||||
|
const shipmentCount = dispatches.filter(isShipment).length;
|
||||||
const attachmentLabel = attachments.length === 1 ? "1 Anlage" : `${attachments.length} Anlagen`;
|
const attachmentLabel = attachments.length === 1 ? "1 Anlage" : `${attachments.length} Anlagen`;
|
||||||
const receiptParts = [];
|
const receiptParts = [];
|
||||||
if (dispatches.length === 1) receiptParts.push("1 Versand");
|
if (shipmentCount === 1) receiptParts.push("1 Versand");
|
||||||
else if (dispatches.length > 1) receiptParts.push(`${dispatches.length} Versände`);
|
else if (shipmentCount > 1) receiptParts.push(`${shipmentCount} Versände`);
|
||||||
if (evidenceCount === 1) receiptParts.push("1 Beleg");
|
if (evidenceCount === 1) receiptParts.push("1 Beleg");
|
||||||
else if (evidenceCount > 1) receiptParts.push(`${evidenceCount} Belege`);
|
else if (evidenceCount > 1) receiptParts.push(`${evidenceCount} Belege`);
|
||||||
|
const receiptLabel = receiptParts.join(" · ");
|
||||||
const switches = (
|
const switches = (
|
||||||
<span className="unit-switches">
|
<span className="unit-switches">
|
||||||
{attachments.length ? (
|
{attachments.length ? (
|
||||||
@@ -776,7 +773,7 @@ export function UnitDetail({
|
|||||||
) : null}
|
) : null}
|
||||||
{dispatches.length ? (
|
{dispatches.length ? (
|
||||||
<button type="button" className="unit-switch" aria-expanded={receiptsOpen} onClick={() => setReceiptsOpen((value) => !value)}>
|
<button type="button" className="unit-switch" aria-expanded={receiptsOpen} onClick={() => setReceiptsOpen((value) => !value)}>
|
||||||
{receiptParts.join(" · ") || "Belege"}
|
{receiptLabel || "Belege"}
|
||||||
</button>
|
</button>
|
||||||
) : null}
|
) : null}
|
||||||
</span>
|
</span>
|
||||||
@@ -792,13 +789,13 @@ export function UnitDetail({
|
|||||||
key={item.id}
|
key={item.id}
|
||||||
className="use-chip"
|
className="use-chip"
|
||||||
data-carry={`attachment:${item.element_id}`}
|
data-carry={`attachment:${item.element_id}`}
|
||||||
{...(canEdit ? chipDrag(!pending, {
|
{...chipPointer(canEdit && !pending, {
|
||||||
source: "attachment",
|
source: "attachment",
|
||||||
elementId: item.element_id,
|
elementId: item.element_id,
|
||||||
hostElementId: binding.element.id,
|
hostElementId: binding.element.id,
|
||||||
bindingId: item.binding_id || "",
|
bindingId: item.binding_id || "",
|
||||||
title: item.title,
|
title: item.title,
|
||||||
}, onCarryStart, onCarryEnd) : {})}
|
}, onCarryStart)}
|
||||||
>
|
>
|
||||||
{canEdit ? <span className="use-chip__grip" aria-hidden="true" /> : null}
|
{canEdit ? <span className="use-chip__grip" aria-hidden="true" /> : null}
|
||||||
<span className="use-chip__title" {...openTitleProps(() => onOpen(item.element_id))}>
|
<span className="use-chip__title" {...openTitleProps(() => onOpen(item.element_id))}>
|
||||||
@@ -815,10 +812,7 @@ export function UnitDetail({
|
|||||||
) : null}
|
) : null}
|
||||||
{receiptsOpen ? dispatches.map((item) => (
|
{receiptsOpen ? dispatches.map((item) => (
|
||||||
<section key={item.id}>
|
<section key={item.id}>
|
||||||
<h4>
|
<h4>{receiptHeading(item)}</h4>
|
||||||
Versand {item.undated ? "undatiert" : formatDate(item.sent_on)} · {item.channel_label}
|
|
||||||
{item.counterpart ? ` · ${item.counterpart}` : ""}
|
|
||||||
</h4>
|
|
||||||
{item.evidence?.length ? (
|
{item.evidence?.length ? (
|
||||||
<ul>
|
<ul>
|
||||||
{item.evidence.map((proof) => (
|
{item.evidence.map((proof) => (
|
||||||
@@ -826,18 +820,18 @@ export function UnitDetail({
|
|||||||
key={proof.id}
|
key={proof.id}
|
||||||
className="use-chip"
|
className="use-chip"
|
||||||
data-carry={`evidence:${proof.element_id}`}
|
data-carry={`evidence:${proof.element_id}`}
|
||||||
{...(canEdit ? chipDrag(!pending, {
|
{...chipPointer(canEdit && !pending, {
|
||||||
source: "evidence",
|
source: "evidence",
|
||||||
elementId: proof.element_id,
|
elementId: proof.element_id,
|
||||||
dispatchId: item.id,
|
dispatchId: item.id,
|
||||||
hostElementId: binding.element.id,
|
hostElementId: binding.element.id,
|
||||||
version: item.version,
|
version: item.version,
|
||||||
title: proof.title,
|
title: proof.title,
|
||||||
}, onCarryStart, onCarryEnd) : {})}
|
}, onCarryStart)}
|
||||||
>
|
>
|
||||||
{canEdit ? <span className="use-chip__grip" aria-hidden="true" /> : null}
|
{canEdit ? <span className="use-chip__grip" aria-hidden="true" /> : null}
|
||||||
<span className="use-chip__title" {...openTitleProps(() => onOpen(proof.element_id))}>
|
<span className="use-chip__title" {...openTitleProps(() => onOpen(proof.element_id))}>
|
||||||
{receiptRoleLabel(proof.role, proof.role_label)}: {proof.title}
|
{receiptCaption(proof)}: {proof.title}
|
||||||
</span>
|
</span>
|
||||||
<span className="muted">{formatDate(proof.document_on)}</span>
|
<span className="muted">{formatDate(proof.document_on)}</span>
|
||||||
{proof.source_state === "gap" ? <span>Lücke: {proof.gap_reason}</span> : null}
|
{proof.source_state === "gap" ? <span>Lücke: {proof.gap_reason}</span> : null}
|
||||||
@@ -854,21 +848,7 @@ export function UnitDetail({
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
) : <p className="muted">Ohne Beleg</p>}
|
) : <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>
|
</section>
|
||||||
)) : null}
|
)) : null}
|
||||||
</div>
|
</div>
|
||||||
@@ -899,7 +879,7 @@ export function Chronology({ bindings, direction, itemHref, selectedId, onOpen }
|
|||||||
events.push({
|
events.push({
|
||||||
key: `send-${dispatch.id}`,
|
key: `send-${dispatch.id}`,
|
||||||
date: dispatch.sent_on || "",
|
date: dispatch.sent_on || "",
|
||||||
label: "Versand",
|
label: isShipment(dispatch) ? "Versand" : "Beleg",
|
||||||
title: binding.element?.title || "",
|
title: binding.element?.title || "",
|
||||||
detail: [
|
detail: [
|
||||||
dispatch.undated ? "Versand undatiert" : `Versanddatum ${formatDate(dispatch.sent_on)}`,
|
dispatch.undated ? "Versand undatiert" : `Versanddatum ${formatDate(dispatch.sent_on)}`,
|
||||||
|
|||||||
+21
-2
@@ -1359,12 +1359,31 @@ button.unit-switch[aria-expanded="true"] { color: var(--brand); }
|
|||||||
.use-chip { 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__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; }
|
.use-chip__title { cursor: pointer; font-weight: 600; text-align: left; }
|
||||||
.entry-mark[draggable="true"] { cursor: grab; }
|
.entry-mark[role="button"] { cursor: grab; touch-action: none; }
|
||||||
|
.contents.is-release-target { box-shadow: inset 0 0 0 2px var(--accent); }
|
||||||
|
.release-mark {
|
||||||
|
position: sticky;
|
||||||
|
top: 36px;
|
||||||
|
z-index: 3;
|
||||||
|
margin: 0 0 4px;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: var(--accent-light);
|
||||||
|
color: var(--brand);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 650;
|
||||||
|
line-height: 22px;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
.use-editions summary { cursor: pointer; color: var(--text2); font-size: 13px; text-align: left; }
|
.use-editions summary { cursor: pointer; color: var(--text2); font-size: 13px; text-align: left; }
|
||||||
|
.preview-row.is-use-target {
|
||||||
|
background: var(--accent-light);
|
||||||
|
box-shadow: inset 3px 0 0 var(--accent);
|
||||||
|
}
|
||||||
.preview-row.is-use-target .direction-trigger,
|
.preview-row.is-use-target .direction-trigger,
|
||||||
.preview-row.is-use-target .entry-mark {
|
.preview-row.is-use-target .entry-mark {
|
||||||
box-shadow: inset 0 0 0 2px var(--accent);
|
box-shadow: inset 0 0 0 2px var(--accent);
|
||||||
background: var(--accent-light);
|
background: #fff;
|
||||||
}
|
}
|
||||||
.pick-tree-dialog { justify-items: start; text-align: left; gap: 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__lead { margin: 0; text-align: left; font-size: 13px; font-weight: 400; color: var(--text2); }
|
||||||
|
|||||||
Reference in new issue
Block a user