Halte den Zug an der ganzen Zeile fest und zaehle im Dialog nur die sichtbaren Unterlagen, damit das Ablegen ankommt und Einzelbelege nicht doppelt erscheinen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
20fa183c1c
commit
f8cb9f8d4b
3 files changed
+174
-68
No files matched your search
+130
-58
@@ -951,6 +951,7 @@ export function ContentBoard({
|
||||
const [dialog, setDialog] = useState(null);
|
||||
const [draggingId, setDraggingId] = useState("");
|
||||
const [indicator, setIndicator] = useState(null);
|
||||
const [carrying, setCarrying] = useState(null);
|
||||
const [folded, setFolded] = useState(() => new Set());
|
||||
const [picking, setPicking] = useState(false);
|
||||
const [picked, setPicked] = useState(() => new Set());
|
||||
@@ -1080,13 +1081,19 @@ export function ContentBoard({
|
||||
|
||||
useEffect(() => {
|
||||
function onKey(event) {
|
||||
if (event.key !== "Escape" || !dragRef.current) return;
|
||||
dragRef.current = null;
|
||||
setDraggingId("");
|
||||
setIndicator(null);
|
||||
if (event.key !== "Escape") return;
|
||||
if (dragRef.current) {
|
||||
dragRef.current = null;
|
||||
setDraggingId("");
|
||||
setIndicator(null);
|
||||
}
|
||||
carryRef.current?.cancel?.();
|
||||
}
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onKey);
|
||||
document.body.classList.remove("is-carrying");
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -1097,10 +1104,21 @@ export function ContentBoard({
|
||||
if (carried) {
|
||||
event.preventDefault();
|
||||
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
||||
const useId = useDropId(event.target);
|
||||
carried.useBindingId = useId && useId !== carried.bindingId ? useId : "";
|
||||
if (carried.useBindingId) setIndicator({ kind: "use", bindingId: carried.useBindingId });
|
||||
else setIndicator(null);
|
||||
const release = event.target?.closest?.("[data-release-drop]");
|
||||
if (release && (carried.source === "attachment" || carried.source === "evidence")) {
|
||||
carried.useBindingId = "";
|
||||
carried.release = true;
|
||||
setIndicator({ kind: "release" });
|
||||
return;
|
||||
}
|
||||
const row = event.target?.closest?.(".preview-row");
|
||||
const useId = row?.getAttribute("data-binding") || "";
|
||||
const blocked = !useId || useId === carried.bindingId || useId === carried.hostBindingId || carried.sourceNode?.contains(row);
|
||||
if (!blocked) {
|
||||
carried.useBindingId = useId;
|
||||
carried.release = false;
|
||||
setIndicator({ kind: "use", bindingId: useId });
|
||||
}
|
||||
return;
|
||||
}
|
||||
const drag = dragRef.current;
|
||||
@@ -1133,11 +1151,15 @@ export function ContentBoard({
|
||||
event.preventDefault();
|
||||
if (carried.settled) return;
|
||||
carried.settled = true;
|
||||
const useId = useDropId(event.target) || carried.useBindingId || "";
|
||||
const release = event.target?.closest?.("[data-release-drop]");
|
||||
const row = event.target?.closest?.(".preview-row");
|
||||
const useId = row?.getAttribute("data-binding") || carried.useBindingId || "";
|
||||
carryRef.current = null;
|
||||
setIndicator(null);
|
||||
if (useId && useId !== carried.bindingId) placeUseRef.current?.(useId, carried);
|
||||
else if (carried.source === "attachment" || carried.source === "evidence") releaseRef.current?.(carried);
|
||||
setCarrying(null);
|
||||
document.body.classList.remove("is-carrying");
|
||||
if (release && (carried.source === "attachment" || carried.source === "evidence")) releaseRef.current?.(carried);
|
||||
else if (useId && useId !== carried.bindingId && useId !== carried.hostBindingId) placeUseRef.current?.(useId, carried);
|
||||
return;
|
||||
}
|
||||
const drag = dragRef.current;
|
||||
@@ -1532,7 +1554,9 @@ export function ContentBoard({
|
||||
function beginCarryPointer(event, payload) {
|
||||
if (pending || (event.button != null && event.button !== 0)) return;
|
||||
if (event.target.closest("button, input, textarea, select, label")) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const opener = event.target.closest?.("a.preview-row__title, a.preview-row__text, .use-chip__title");
|
||||
const carried = {
|
||||
...payload,
|
||||
pointerId: event.pointerId,
|
||||
@@ -1546,28 +1570,55 @@ export function ContentBoard({
|
||||
release: false,
|
||||
sourceNode: event.target.closest?.(".preview-row, .use-chip") || event.target,
|
||||
};
|
||||
function blockNativeDrag(native) {
|
||||
function blockBrowserGesture(native) {
|
||||
native.preventDefault();
|
||||
native.stopPropagation();
|
||||
}
|
||||
function pointOf(x, y) {
|
||||
return document.elementsFromPoint(x, y).find((node) => !carried.sourceNode?.contains(node)) || null;
|
||||
function hitAt(x, y) {
|
||||
const nodes = document.elementsFromPoint(x, y);
|
||||
if (nodes.some((node) => node.closest?.("[data-release-drop]"))) return { release: true };
|
||||
for (const node of nodes) {
|
||||
if (carried.sourceNode?.contains(node)) continue;
|
||||
const row = node.closest?.(".preview-row");
|
||||
if (!row || carried.sourceNode?.contains(row)) continue;
|
||||
const useId = row.getAttribute("data-binding") || "";
|
||||
if (!useId || useId === carried.bindingId || useId === carried.hostBindingId) continue;
|
||||
return { useId };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
function remember(x, y, sticky) {
|
||||
const hit = pointOf(x, y);
|
||||
const useId = useDropId(hit);
|
||||
const ownChip = hit?.closest?.(`[data-carry="${carried.source}:${carried.elementId}"]`);
|
||||
if (useId && useId !== carried.bindingId) {
|
||||
carried.useBindingId = useId;
|
||||
carried.release = false;
|
||||
setIndicator({ kind: "use", bindingId: useId });
|
||||
const found = hitAt(x, y);
|
||||
if (found.release) {
|
||||
carried.useBindingId = "";
|
||||
carried.release = true;
|
||||
setIndicator({ kind: "release" });
|
||||
return;
|
||||
}
|
||||
if (found.useId) {
|
||||
carried.useBindingId = found.useId;
|
||||
carried.release = false;
|
||||
setIndicator({ kind: "use", bindingId: found.useId });
|
||||
return;
|
||||
}
|
||||
if (sticky && carried.useBindingId) {
|
||||
carried.release = false;
|
||||
setIndicator({ kind: "use", bindingId: carried.useBindingId });
|
||||
return;
|
||||
}
|
||||
if (sticky && (carried.useBindingId || carried.release)) return;
|
||||
carried.useBindingId = "";
|
||||
const inside = Boolean(hit && rootRef.current?.contains(hit));
|
||||
carried.release = Boolean(inside && !ownChip && (carried.source === "attachment" || carried.source === "evidence"));
|
||||
setIndicator(carried.release ? { kind: "release" } : null);
|
||||
carried.release = false;
|
||||
setIndicator(null);
|
||||
}
|
||||
function cleanup() {
|
||||
window.removeEventListener("pointermove", track, true);
|
||||
window.removeEventListener("pointerup", finish, true);
|
||||
window.removeEventListener("dragstart", blockBrowserGesture, true);
|
||||
window.removeEventListener("selectstart", blockBrowserGesture, true);
|
||||
try { carried.sourceNode?.releasePointerCapture?.(carried.pointerId); } catch { /* already released */ }
|
||||
document.body.classList.remove("is-carrying");
|
||||
if (carryRef.current === carried) carryRef.current = null;
|
||||
setCarrying(null);
|
||||
setIndicator(null);
|
||||
}
|
||||
function track(pointer) {
|
||||
if (carryRef.current !== carried || (pointer.pointerId !== carried.pointerId && pointer.pointerId !== 0)) return;
|
||||
@@ -1575,47 +1626,61 @@ export function ContentBoard({
|
||||
carried.lastX = pointer.clientX;
|
||||
carried.lastY = pointer.clientY;
|
||||
}
|
||||
if (!carried.moved && Math.hypot(carried.lastX - carried.anchorX, carried.lastY - carried.anchorY) > 6) {
|
||||
if (!carried.moved && Math.hypot(carried.lastX - carried.anchorX, carried.lastY - carried.anchorY) > 4) {
|
||||
carried.moved = true;
|
||||
if (carried.sourceNode) carried.sourceNode.dataset.dragged = "1";
|
||||
document.body.classList.add("is-carrying");
|
||||
setCarrying({
|
||||
source: carried.source,
|
||||
bindingId: carried.bindingId || "",
|
||||
hostBindingId: carried.hostBindingId || "",
|
||||
});
|
||||
}
|
||||
if (!carried.moved) return;
|
||||
pointer.preventDefault();
|
||||
remember(carried.lastX, carried.lastY, false);
|
||||
}
|
||||
function finish(pointer) {
|
||||
if (carried.settled) return;
|
||||
if (pointer && pointer.type !== "dragend" && pointer.pointerId !== carried.pointerId && pointer.pointerId !== 0) return;
|
||||
carried.settled = true;
|
||||
window.removeEventListener("pointermove", track, true);
|
||||
window.removeEventListener("pointerup", finish, true);
|
||||
window.removeEventListener("pointercancel", finish, true);
|
||||
window.removeEventListener("dragend", finish, true);
|
||||
window.removeEventListener("dragstart", blockNativeDrag, true);
|
||||
if (carryRef.current !== carried) return;
|
||||
carryRef.current = null;
|
||||
setIndicator(null);
|
||||
if (!carried.moved) return;
|
||||
const x = pointer && pointer.type !== "dragend" && (pointer.clientX || pointer.clientY) ? pointer.clientX : carried.lastX;
|
||||
const y = pointer && pointer.type !== "dragend" && (pointer.clientX || pointer.clientY) ? pointer.clientY : carried.lastY;
|
||||
remember(x, y, true);
|
||||
if (carried.useBindingId && carried.useBindingId !== carried.bindingId) {
|
||||
window.addEventListener("click", (click) => {
|
||||
click.preventDefault();
|
||||
click.stopPropagation();
|
||||
}, { capture: true, once: true });
|
||||
placeUseRef.current?.(carried.useBindingId, carried);
|
||||
if (pointer && pointer.pointerId !== carried.pointerId && pointer.pointerId !== 0) return;
|
||||
if (carried.settled) {
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
if (carried.release && (carried.source === "attachment" || carried.source === "evidence")) releaseRef.current?.(carried);
|
||||
carried.settled = true;
|
||||
const moved = carried.moved;
|
||||
const x = pointer && (pointer.clientX || pointer.clientY) ? pointer.clientX : carried.lastX;
|
||||
const y = pointer && (pointer.clientX || pointer.clientY) ? pointer.clientY : carried.lastY;
|
||||
if (moved) remember(x, y, true);
|
||||
const useId = carried.useBindingId;
|
||||
const release = carried.release;
|
||||
cleanup();
|
||||
if (!moved) {
|
||||
opener?.click();
|
||||
return;
|
||||
}
|
||||
window.addEventListener("click", (click) => {
|
||||
if (click.target.closest("button, [role=dialog]")) return;
|
||||
click.preventDefault();
|
||||
click.stopPropagation();
|
||||
}, { capture: true, once: true });
|
||||
if (useId && useId !== carried.bindingId && useId !== carried.hostBindingId) {
|
||||
placeUseRef.current?.(useId, carried);
|
||||
return;
|
||||
}
|
||||
if (release && (carried.source === "attachment" || carried.source === "evidence")) releaseRef.current?.(carried);
|
||||
}
|
||||
if (event.target.closest(".entry-mark")) event.preventDefault();
|
||||
carried.cancel = () => {
|
||||
if (carried.settled) return;
|
||||
carried.settled = true;
|
||||
carried.moved = false;
|
||||
cleanup();
|
||||
};
|
||||
carryRef.current = carried;
|
||||
window.addEventListener("dragstart", blockNativeDrag, true);
|
||||
try { carried.sourceNode?.setPointerCapture?.(event.pointerId); } catch { /* the window listeners still follow the pointer */ }
|
||||
window.addEventListener("dragstart", blockBrowserGesture, true);
|
||||
window.addEventListener("selectstart", blockBrowserGesture, true);
|
||||
window.addEventListener("pointermove", track, true);
|
||||
window.addEventListener("pointerup", finish, true);
|
||||
window.addEventListener("pointercancel", finish, true);
|
||||
window.addEventListener("dragend", finish, true);
|
||||
}
|
||||
|
||||
function bindingByElement(elementId) {
|
||||
@@ -1813,8 +1878,16 @@ export function ContentBoard({
|
||||
}
|
||||
|
||||
return (
|
||||
<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={carrying ? "contents is-carrying" : "contents"} ref={rootRef}>
|
||||
{carrying ? (
|
||||
carrying.source === "attachment" || carrying.source === "evidence" ? (
|
||||
<div className={indicator?.kind === "release" ? "release-lane is-hot" : "release-lane"} data-release-drop="1">
|
||||
In den Vorgang legen
|
||||
</div>
|
||||
) : (
|
||||
<div className="release-lane">Auf ein Schriftstück loslassen</div>
|
||||
)
|
||||
) : null}
|
||||
<div className="content-toolbar">
|
||||
<h2>{viewMode === "chronology" ? "Chronologie" : (activePath || listTitle || "Inhalte")} <span className="count">{shownCount}</span></h2>
|
||||
<div className="content-toolbar__tools">
|
||||
@@ -2151,8 +2224,7 @@ export function ContentBoard({
|
||||
<EntryMark
|
||||
element={element}
|
||||
context={context}
|
||||
dropId={canEdit ? binding.id : ""}
|
||||
assignable={canEdit && !pending && !picking}
|
||||
assignable={false}
|
||||
/>
|
||||
<UnitDetail
|
||||
binding={binding}
|
||||
|
||||
Reference in new issue
Block a user