Oeffne den Leser aus der Anlagenliste und zeige einen Beleg mit seinem Datum, damit der Drop an der Markierung ankommt und kein Nachweis als undatierter Versand erscheint.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7846830765
commit
7e8a3e865e
4 files changed
+74
-29
No files matched your search
@@ -503,12 +503,26 @@ def export_children(conn, actor: UUID, binding: dict, page: Ctx) -> list[dict]:
|
|||||||
)
|
)
|
||||||
if not children:
|
if not children:
|
||||||
continue
|
continue
|
||||||
sent = dump_date(dispatch["sent_on"]) or "undatiert"
|
item_rows = _item_rows(conn, dispatch["id"])
|
||||||
|
sent = dump_date(dispatch["sent_on"])
|
||||||
|
if item_rows:
|
||||||
|
title = f"Versand {sent or 'undatiert'} · {CHANNELS[dispatch['channel']]}"
|
||||||
|
label = "Versand"
|
||||||
|
else:
|
||||||
|
if not sent:
|
||||||
|
for proof in _evidence_rows(conn, dispatch["id"]):
|
||||||
|
dates = _dates(conn, proof["element_id"])
|
||||||
|
sent = dump_date(dates["document_on"]) or dump_date(dates["sent_on"])
|
||||||
|
if sent:
|
||||||
|
break
|
||||||
|
title = sent or "Beleg"
|
||||||
|
label = "Beleg"
|
||||||
nodes.append(
|
nodes.append(
|
||||||
{
|
{
|
||||||
"id": f"dispatch:{dispatch['id']}",
|
"id": f"dispatch:{dispatch['id']}",
|
||||||
"kind": "dispatch",
|
"kind": "dispatch",
|
||||||
"title": f"Versand {sent} · {CHANNELS[dispatch['channel']]}",
|
"title": title,
|
||||||
|
"label": label,
|
||||||
"children": children,
|
"children": children,
|
||||||
"completeness": dispatch["completeness"],
|
"completeness": dispatch["completeness"],
|
||||||
"provenance": dispatch["provenance"],
|
"provenance": dispatch["provenance"],
|
||||||
@@ -1030,6 +1044,14 @@ def _public_dispatch(conn, actor: UUID, dispatch, page: Ctx) -> dict:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _evidence_source(conn, element_id: UUID) -> str | None:
|
||||||
|
row = conn.execute(
|
||||||
|
"SELECT source FROM external_references WHERE element_id = %s",
|
||||||
|
(element_id,),
|
||||||
|
).fetchone()
|
||||||
|
return row["source"] if row else None
|
||||||
|
|
||||||
|
|
||||||
def _public_evidence(conn, proof, element, page: Ctx) -> dict:
|
def _public_evidence(conn, proof, element, page: Ctx) -> dict:
|
||||||
del page
|
del page
|
||||||
return {
|
return {
|
||||||
@@ -1037,6 +1059,7 @@ def _public_evidence(conn, proof, element, page: Ctx) -> dict:
|
|||||||
"element_id": str(element["id"]),
|
"element_id": str(element["id"]),
|
||||||
"title": element["title"],
|
"title": element["title"],
|
||||||
"kind": element["kind"],
|
"kind": element["kind"],
|
||||||
|
"source": _evidence_source(conn, element["id"]),
|
||||||
"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"],
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ def _spec_node(spec: dict) -> ExportNode:
|
|||||||
reason=None,
|
reason=None,
|
||||||
content_kind=None,
|
content_kind=None,
|
||||||
children=[_spec_node(child) for child in spec["children"]],
|
children=[_spec_node(child) for child in spec["children"]],
|
||||||
label="Versand",
|
label=spec.get("label") or "Versand",
|
||||||
)
|
)
|
||||||
element = spec.get("element")
|
element = spec.get("element")
|
||||||
if spec["kind"] == "dispatch_item":
|
if spec["kind"] == "dispatch_item":
|
||||||
|
|||||||
@@ -1538,65 +1538,81 @@ export function ContentBoard({
|
|||||||
pointerId: event.pointerId,
|
pointerId: event.pointerId,
|
||||||
anchorX: event.clientX,
|
anchorX: event.clientX,
|
||||||
anchorY: event.clientY,
|
anchorY: event.clientY,
|
||||||
|
lastX: event.clientX,
|
||||||
|
lastY: event.clientY,
|
||||||
moved: false,
|
moved: false,
|
||||||
useBindingId: "",
|
useBindingId: "",
|
||||||
|
release: false,
|
||||||
sourceNode: event.target.closest?.("[data-carry], .entry-mark") || event.target,
|
sourceNode: event.target.closest?.("[data-carry], .entry-mark") || event.target,
|
||||||
};
|
};
|
||||||
function pointOf(pointer) {
|
function pointOf(x, y) {
|
||||||
return document.elementFromPoint(pointer.clientX, pointer.clientY);
|
const stack = document.elementsFromPoint(x, y);
|
||||||
|
return stack.find((node) => node !== carried.sourceNode && !carried.sourceNode?.contains(node)) || null;
|
||||||
}
|
}
|
||||||
function track(pointer) {
|
function track(pointer) {
|
||||||
if (carryRef.current !== carried || pointer.pointerId !== carried.pointerId) return;
|
if (carryRef.current !== carried || pointer.pointerId !== carried.pointerId) return;
|
||||||
if (Math.hypot(pointer.clientX - carried.anchorX, pointer.clientY - carried.anchorY) > 4) {
|
if (pointer.clientX || pointer.clientY) {
|
||||||
|
carried.lastX = pointer.clientX;
|
||||||
|
carried.lastY = pointer.clientY;
|
||||||
|
}
|
||||||
|
if (!carried.moved && Math.hypot(pointer.clientX - carried.anchorX, pointer.clientY - carried.anchorY) > 8) {
|
||||||
carried.moved = true;
|
carried.moved = true;
|
||||||
if (carried.sourceNode) carried.sourceNode.dataset.dragged = "1";
|
if (carried.sourceNode) carried.sourceNode.dataset.dragged = "1";
|
||||||
|
try {
|
||||||
|
carried.sourceNode?.setPointerCapture?.(pointer.pointerId);
|
||||||
|
} catch {
|
||||||
|
// The window listeners still follow the pointer.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!carried.moved) return;
|
if (!carried.moved) return;
|
||||||
const hit = pointOf(pointer);
|
pointer.preventDefault();
|
||||||
|
const hit = pointOf(carried.lastX, carried.lastY);
|
||||||
const useId = useDropId(hit);
|
const useId = useDropId(hit);
|
||||||
const ownChip = hit?.closest?.(`[data-carry="${carried.source}:${carried.elementId}"]`);
|
const ownChip = hit?.closest?.(`[data-carry="${carried.source}:${carried.elementId}"]`);
|
||||||
if (useId && useId !== carried.bindingId) {
|
if (useId && useId !== carried.bindingId) {
|
||||||
carried.useBindingId = useId;
|
carried.useBindingId = useId;
|
||||||
|
carried.release = false;
|
||||||
setIndicator({ kind: "use", bindingId: useId });
|
setIndicator({ kind: "use", bindingId: useId });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
carried.useBindingId = "";
|
carried.useBindingId = "";
|
||||||
const inside = Boolean(hit && rootRef.current?.contains(hit));
|
const inside = Boolean(hit && rootRef.current?.contains(hit));
|
||||||
if (inside && !ownChip && (carried.source === "attachment" || carried.source === "evidence")) {
|
if (inside && !ownChip && (carried.source === "attachment" || carried.source === "evidence")) {
|
||||||
|
carried.release = true;
|
||||||
setIndicator({ kind: "release" });
|
setIndicator({ kind: "release" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
carried.release = false;
|
||||||
setIndicator(null);
|
setIndicator(null);
|
||||||
}
|
}
|
||||||
function finish(pointer) {
|
function finish(pointer) {
|
||||||
if (pointer && pointer.pointerId !== carried.pointerId) return;
|
if (pointer && pointer.pointerId !== carried.pointerId && pointer.pointerId !== 0) return;
|
||||||
window.removeEventListener("pointermove", track);
|
window.removeEventListener("pointermove", track, true);
|
||||||
window.removeEventListener("pointerup", finish);
|
window.removeEventListener("pointerup", finish, true);
|
||||||
window.removeEventListener("pointercancel", finish);
|
window.removeEventListener("pointercancel", finish, true);
|
||||||
if (carryRef.current !== carried) return;
|
if (carryRef.current !== carried) return;
|
||||||
carryRef.current = null;
|
carryRef.current = null;
|
||||||
setIndicator(null);
|
setIndicator(null);
|
||||||
if (!carried.moved) return;
|
if (!carried.moved) return;
|
||||||
const hit = pointer ? pointOf(pointer) : null;
|
const x = pointer && (pointer.clientX || pointer.clientY) ? pointer.clientX : carried.lastX;
|
||||||
const useId = useDropId(hit) || carried.useBindingId;
|
const y = pointer && (pointer.clientX || pointer.clientY) ? pointer.clientY : carried.lastY;
|
||||||
|
const hit = pointOf(x, y);
|
||||||
|
const useId = (useDropId(hit) && useDropId(hit) !== carried.bindingId ? useDropId(hit) : "") || carried.useBindingId;
|
||||||
if (useId && useId !== carried.bindingId) {
|
if (useId && useId !== carried.bindingId) {
|
||||||
|
window.addEventListener("click", (click) => {
|
||||||
|
click.preventDefault();
|
||||||
|
click.stopPropagation();
|
||||||
|
}, { capture: true, once: true });
|
||||||
placeUseRef.current?.(useId, carried);
|
placeUseRef.current?.(useId, carried);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const inside = Boolean(hit && rootRef.current?.contains(hit));
|
if (!carried.release) return;
|
||||||
if (!inside) return;
|
|
||||||
if (hit.closest?.(`[data-carry="${carried.source}:${carried.elementId}"]`)) return;
|
|
||||||
if (carried.source === "attachment" || carried.source === "evidence") releaseRef.current?.(carried);
|
if (carried.source === "attachment" || carried.source === "evidence") releaseRef.current?.(carried);
|
||||||
}
|
}
|
||||||
carryRef.current = carried;
|
carryRef.current = carried;
|
||||||
window.addEventListener("pointermove", track);
|
window.addEventListener("pointermove", track, true);
|
||||||
window.addEventListener("pointerup", finish);
|
window.addEventListener("pointerup", finish, true);
|
||||||
window.addEventListener("pointercancel", finish);
|
window.addEventListener("pointercancel", finish, true);
|
||||||
try {
|
|
||||||
carried.sourceNode.setPointerCapture?.(event.pointerId);
|
|
||||||
} catch {
|
|
||||||
// Window listeners still follow the pointer.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindingByElement(elementId) {
|
function bindingByElement(elementId) {
|
||||||
@@ -1730,7 +1746,7 @@ export function ContentBoard({
|
|||||||
body: {
|
body: {
|
||||||
expected_version: expected,
|
expected_version: expected,
|
||||||
channel: "other",
|
channel: "other",
|
||||||
sent_on: null,
|
sent_on: element?.dates?.sent_on || element?.dates?.document_on || null,
|
||||||
counterpart: null,
|
counterpart: null,
|
||||||
attachment_element_ids: [],
|
attachment_element_ids: [],
|
||||||
evidence: [{ element_id: payload.elementId, role, fold: "evidence" }],
|
evidence: [{ element_id: payload.elementId, role, fold: "evidence" }],
|
||||||
|
|||||||
@@ -65,10 +65,16 @@ export function receiptRoleLabel(role, fallback = "") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function receiptCaption(proof) {
|
function receiptCaption(proof) {
|
||||||
if (proof.role === "email" && proof.kind === "file") return "Beleg";
|
if (proof.role === "email" && proof.source !== "imap") return "Beleg";
|
||||||
return receiptRoleLabel(proof.role, proof.role_label);
|
return receiptRoleLabel(proof.role, proof.role_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function receiptWhen(item) {
|
||||||
|
if (item.sent_on) return formatDate(item.sent_on);
|
||||||
|
const dated = (item.evidence || []).find((proof) => proof.document_on);
|
||||||
|
return dated ? formatDate(dated.document_on) : "";
|
||||||
|
}
|
||||||
|
|
||||||
function isShipment(item) {
|
function isShipment(item) {
|
||||||
const proofs = item.evidence || [];
|
const proofs = item.evidence || [];
|
||||||
if (item.channel === "other") return false;
|
if (item.channel === "other") return false;
|
||||||
@@ -78,9 +84,9 @@ function isShipment(item) {
|
|||||||
|
|
||||||
function receiptHeading(item) {
|
function receiptHeading(item) {
|
||||||
const who = item.counterpart ? ` · ${item.counterpart}` : "";
|
const who = item.counterpart ? ` · ${item.counterpart}` : "";
|
||||||
if (!isShipment(item)) return `${item.sent_on ? formatDate(item.sent_on) : "Beleg"}${who}`;
|
const when = receiptWhen(item);
|
||||||
const when = item.undated ? "undatiert" : formatDate(item.sent_on);
|
if (!isShipment(item)) return `${when || "Beleg"}${who}`;
|
||||||
return `Versand ${when} · ${item.channel_label}${who}`;
|
return `Versand ${when || "undatiert"} · ${item.channel_label}${who}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function writeAssign(event, payload) {
|
export function writeAssign(event, payload) {
|
||||||
|
|||||||
Reference in new issue
Block a user