Lege am Dokument-Symbol an und gib zugeordnete Unterlagen in ein Kapitel zurueck, damit der Zug im Vorgang ankommt.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f8cb9f8d4b
commit
9b9a09b97c
2 files changed
+99
-35
No files matched your search
@@ -864,7 +864,7 @@ function useDropId(node) {
|
|||||||
return node?.closest?.("[data-use-drop]")?.getAttribute("data-use-drop") || "";
|
return node?.closest?.("[data-use-drop]")?.getAttribute("data-use-drop") || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function EntryMark({ element, context, assignable = false, dropId = "", onAssignStart, onAssignEnd }) {
|
function EntryMark({ element, context, assignable = false, dropId = "", hot = false, onAssignStart, onAssignEnd }) {
|
||||||
const symbol = elementSymbol(element);
|
const symbol = elementSymbol(element);
|
||||||
const photo = symbol === "image" && Boolean(element.preview?.available);
|
const photo = symbol === "image" && Boolean(element.preview?.available);
|
||||||
const [url, setUrl] = useState("");
|
const [url, setUrl] = useState("");
|
||||||
@@ -887,8 +887,8 @@ function EntryMark({ element, context, assignable = false, dropId = "", onAssign
|
|||||||
}, [photo, element.id, element.preview?.source, context?.kind, context?.id]);
|
}, [photo, element.id, element.preview?.source, context?.kind, context?.id]);
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={url ? "entry-mark entry-mark--photo" : "entry-mark"}
|
className={[url ? "entry-mark entry-mark--photo" : "entry-mark", hot ? "is-assign-hot" : ""].filter(Boolean).join(" ")}
|
||||||
data-use-drop={dropId || undefined}
|
data-assign-drop={dropId || undefined}
|
||||||
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}
|
||||||
@@ -1104,20 +1104,29 @@ export function ContentBoard({
|
|||||||
if (carried) {
|
if (carried) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
||||||
const release = event.target?.closest?.("[data-release-drop]");
|
const mark = event.target?.closest?.("[data-assign-drop]");
|
||||||
if (release && (carried.source === "attachment" || carried.source === "evidence")) {
|
const useId = mark?.getAttribute("data-assign-drop") || "";
|
||||||
carried.useBindingId = "";
|
const blocked = !useId || useId === carried.bindingId || useId === carried.hostBindingId || carried.sourceNode?.contains(mark);
|
||||||
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) {
|
if (!blocked) {
|
||||||
carried.useBindingId = useId;
|
carried.useBindingId = useId;
|
||||||
carried.release = false;
|
carried.release = false;
|
||||||
|
carried.place = false;
|
||||||
setIndicator({ kind: "use", bindingId: useId });
|
setIndicator({ kind: "use", bindingId: useId });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (carried.source === "attachment" || carried.source === "evidence") {
|
||||||
|
const section = event.target?.closest?.("[data-section]");
|
||||||
|
carried.useBindingId = "";
|
||||||
|
carried.release = true;
|
||||||
|
carried.place = Boolean(section);
|
||||||
|
carried.chapterId = section && section.getAttribute("data-section") !== "loose" ? section.getAttribute("data-section") : "";
|
||||||
|
const loose = !section || section.getAttribute("data-section") === "loose";
|
||||||
|
setIndicator({
|
||||||
|
kind: "release",
|
||||||
|
place: carried.place,
|
||||||
|
chapterId: carried.chapterId,
|
||||||
|
title: loose ? "" : (section.getAttribute("data-chapter-title") || ""),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1151,15 +1160,22 @@ export function ContentBoard({
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (carried.settled) return;
|
if (carried.settled) return;
|
||||||
carried.settled = true;
|
carried.settled = true;
|
||||||
const release = event.target?.closest?.("[data-release-drop]");
|
const mark = event.target?.closest?.("[data-assign-drop]");
|
||||||
const row = event.target?.closest?.(".preview-row");
|
const useId = mark?.getAttribute("data-assign-drop") || "";
|
||||||
const useId = row?.getAttribute("data-binding") || carried.useBindingId || "";
|
const section = event.target?.closest?.("[data-section]");
|
||||||
|
const assign = useId && useId !== carried.bindingId && useId !== carried.hostBindingId && !carried.sourceNode?.contains(mark);
|
||||||
carryRef.current = null;
|
carryRef.current = null;
|
||||||
setIndicator(null);
|
setIndicator(null);
|
||||||
setCarrying(null);
|
setCarrying(null);
|
||||||
document.body.classList.remove("is-carrying");
|
document.body.classList.remove("is-carrying");
|
||||||
if (release && (carried.source === "attachment" || carried.source === "evidence")) releaseRef.current?.(carried);
|
if (assign) placeUseRef.current?.(useId, carried);
|
||||||
else if (useId && useId !== carried.bindingId && useId !== carried.hostBindingId) placeUseRef.current?.(useId, carried);
|
else if ((carried.source === "attachment" || carried.source === "evidence") && (section || event.target?.closest?.("[data-release-drop]"))) {
|
||||||
|
releaseRef.current?.({
|
||||||
|
...carried,
|
||||||
|
place: Boolean(section),
|
||||||
|
chapterId: section && section.getAttribute("data-section") !== "loose" ? section.getAttribute("data-section") : "",
|
||||||
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const drag = dragRef.current;
|
const drag = dragRef.current;
|
||||||
@@ -1575,38 +1591,57 @@ export function ContentBoard({
|
|||||||
}
|
}
|
||||||
function hitAt(x, y) {
|
function hitAt(x, y) {
|
||||||
const nodes = document.elementsFromPoint(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) {
|
for (const node of nodes) {
|
||||||
if (carried.sourceNode?.contains(node)) continue;
|
if (carried.sourceNode?.contains(node)) continue;
|
||||||
const row = node.closest?.(".preview-row");
|
const mark = node.closest?.("[data-assign-drop]");
|
||||||
if (!row || carried.sourceNode?.contains(row)) continue;
|
if (!mark || carried.sourceNode?.contains(mark)) continue;
|
||||||
const useId = row.getAttribute("data-binding") || "";
|
const useId = mark.getAttribute("data-assign-drop") || "";
|
||||||
if (!useId || useId === carried.bindingId || useId === carried.hostBindingId) continue;
|
if (!useId || useId === carried.bindingId || useId === carried.hostBindingId) continue;
|
||||||
return { useId };
|
return { useId };
|
||||||
}
|
}
|
||||||
|
if (carried.source !== "attachment" && carried.source !== "evidence") return {};
|
||||||
|
if (nodes.some((node) => node.closest?.("[data-release-drop]"))) return { release: true, place: false, chapterId: "" };
|
||||||
|
for (const node of nodes) {
|
||||||
|
if (carried.sourceNode?.contains(node)) continue;
|
||||||
|
const section = node.closest?.("[data-section]");
|
||||||
|
if (!section || !rootRef.current?.contains(section)) continue;
|
||||||
|
const id = section.getAttribute("data-section") || "";
|
||||||
|
return {
|
||||||
|
release: true,
|
||||||
|
place: true,
|
||||||
|
chapterId: id === "loose" ? "" : id,
|
||||||
|
title: id === "loose" ? "" : (section.getAttribute("data-chapter-title") || ""),
|
||||||
|
};
|
||||||
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
function remember(x, y, sticky) {
|
function remember(x, y, sticky) {
|
||||||
const found = hitAt(x, y);
|
const found = hitAt(x, y);
|
||||||
if (found.release) {
|
|
||||||
carried.useBindingId = "";
|
|
||||||
carried.release = true;
|
|
||||||
setIndicator({ kind: "release" });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (found.useId) {
|
if (found.useId) {
|
||||||
carried.useBindingId = found.useId;
|
carried.useBindingId = found.useId;
|
||||||
carried.release = false;
|
carried.release = false;
|
||||||
|
carried.place = false;
|
||||||
|
carried.chapterId = "";
|
||||||
setIndicator({ kind: "use", bindingId: found.useId });
|
setIndicator({ kind: "use", bindingId: found.useId });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sticky && carried.useBindingId) {
|
if (found.release) {
|
||||||
|
carried.useBindingId = "";
|
||||||
|
carried.release = true;
|
||||||
|
carried.place = Boolean(found.place);
|
||||||
|
carried.chapterId = found.chapterId || "";
|
||||||
|
setIndicator({ kind: "release", place: carried.place, chapterId: carried.chapterId, title: found.title || "" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sticky && carried.useBindingId && !(x || y)) {
|
||||||
carried.release = false;
|
carried.release = false;
|
||||||
setIndicator({ kind: "use", bindingId: carried.useBindingId });
|
setIndicator({ kind: "use", bindingId: carried.useBindingId });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
carried.useBindingId = "";
|
carried.useBindingId = "";
|
||||||
carried.release = false;
|
carried.release = false;
|
||||||
|
carried.place = false;
|
||||||
|
carried.chapterId = "";
|
||||||
setIndicator(null);
|
setIndicator(null);
|
||||||
}
|
}
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
@@ -1667,7 +1702,9 @@ export function ContentBoard({
|
|||||||
placeUseRef.current?.(useId, carried);
|
placeUseRef.current?.(useId, carried);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (release && (carried.source === "attachment" || carried.source === "evidence")) releaseRef.current?.(carried);
|
if (release && (carried.source === "attachment" || carried.source === "evidence")) {
|
||||||
|
releaseRef.current?.({ ...carried, place: carried.place, chapterId: carried.chapterId });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
carried.cancel = () => {
|
carried.cancel = () => {
|
||||||
if (carried.settled) return;
|
if (carried.settled) return;
|
||||||
@@ -1721,6 +1758,12 @@ export function ContentBoard({
|
|||||||
if (item?.correspondence?.fold) {
|
if (item?.correspondence?.fold) {
|
||||||
await restoreFold(item.id, item.element.version, scope);
|
await restoreFold(item.id, item.element.version, scope);
|
||||||
}
|
}
|
||||||
|
if (payload.place && item && (item.chapter_id || "") !== (payload.chapterId || "")) {
|
||||||
|
await api(`/api/v1/bindings/${item.id}/chapter`, {
|
||||||
|
method: "PATCH",
|
||||||
|
body: { expected_version: record.version, chapter_id: payload.chapterId || null, ...orderContext },
|
||||||
|
});
|
||||||
|
}
|
||||||
onChange();
|
onChange();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err.message);
|
setError(err.message);
|
||||||
@@ -1881,11 +1924,11 @@ export function ContentBoard({
|
|||||||
<div className={carrying ? "contents is-carrying" : "contents"} ref={rootRef}>
|
<div className={carrying ? "contents is-carrying" : "contents"} ref={rootRef}>
|
||||||
{carrying ? (
|
{carrying ? (
|
||||||
carrying.source === "attachment" || carrying.source === "evidence" ? (
|
carrying.source === "attachment" || carrying.source === "evidence" ? (
|
||||||
<div className={indicator?.kind === "release" ? "release-lane is-hot" : "release-lane"} data-release-drop="1">
|
<div className={indicator?.kind === "release" && !indicator.place ? "release-lane is-hot" : "release-lane"} data-release-drop="1">
|
||||||
In den Vorgang legen
|
{indicator?.kind === "release" && indicator.place && indicator.title ? `In ${indicator.title} legen` : "In den Vorgang legen"}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="release-lane">Auf ein Schriftstück loslassen</div>
|
<div className="release-lane">Auf das Dokument-Symbol loslassen</div>
|
||||||
)
|
)
|
||||||
) : null}
|
) : null}
|
||||||
<div className="content-toolbar">
|
<div className="content-toolbar">
|
||||||
@@ -2049,6 +2092,7 @@ export function ContentBoard({
|
|||||||
if (section.title) classes.push("content-section--group");
|
if (section.title) classes.push("content-section--group");
|
||||||
if (draggingId === section.id) classes.push("is-dragging");
|
if (draggingId === section.id) classes.push("is-dragging");
|
||||||
if (!expanded) classes.push("is-collapsed");
|
if (!expanded) classes.push("is-collapsed");
|
||||||
|
if (indicator?.kind === "release" && indicator.place && (indicator.chapterId || "loose") === section.id) classes.push("is-release-target");
|
||||||
const sameParent = (indicator?.parentId || "") === (section.parentId || "");
|
const sameParent = (indicator?.parentId || "") === (section.parentId || "");
|
||||||
const insertBefore = indicator?.kind === "chapter" && sameParent && fromIndex > indicator.index && siblingIndex === indicator.index;
|
const insertBefore = indicator?.kind === "chapter" && sameParent && fromIndex > indicator.index && siblingIndex === indicator.index;
|
||||||
const insertAfter = indicator?.kind === "chapter" && sameParent && fromIndex >= 0 && fromIndex < indicator.index && siblingIndex === indicator.index;
|
const insertAfter = indicator?.kind === "chapter" && sameParent && fromIndex >= 0 && fromIndex < indicator.index && siblingIndex === indicator.index;
|
||||||
@@ -2059,6 +2103,7 @@ export function ContentBoard({
|
|||||||
className={classes.join(" ")}
|
className={classes.join(" ")}
|
||||||
data-section={section.id}
|
data-section={section.id}
|
||||||
data-chapter={section.id === "loose" ? undefined : section.id}
|
data-chapter={section.id === "loose" ? undefined : section.id}
|
||||||
|
data-chapter-title={section.title || ""}
|
||||||
data-chapter-parent={section.parentId || ""}
|
data-chapter-parent={section.parentId || ""}
|
||||||
>
|
>
|
||||||
{insertBefore ? <div className="insert-line" aria-hidden="true" /> : null}
|
{insertBefore ? <div className="insert-line" aria-hidden="true" /> : null}
|
||||||
@@ -2146,7 +2191,7 @@ export function ContentBoard({
|
|||||||
const rowClass = [
|
const rowClass = [
|
||||||
"preview-row",
|
"preview-row",
|
||||||
draggingId === binding.id ? "is-dragging" : "",
|
draggingId === binding.id ? "is-dragging" : "",
|
||||||
indicator?.kind === "use" && indicator.bindingId === binding.id ? "is-use-target" : "",
|
carrying && (binding.id === carrying.bindingId || binding.id === carrying.hostBindingId) ? "is-carry-source" : "",
|
||||||
selectedId === binding.id ? "is-selected" : "",
|
selectedId === binding.id ? "is-selected" : "",
|
||||||
picking && picked.has(binding.id) ? "is-picked" : "",
|
picking && picked.has(binding.id) ? "is-picked" : "",
|
||||||
picking ? "preview-row--picking" : "",
|
picking ? "preview-row--picking" : "",
|
||||||
@@ -2224,7 +2269,8 @@ export function ContentBoard({
|
|||||||
<EntryMark
|
<EntryMark
|
||||||
element={element}
|
element={element}
|
||||||
context={context}
|
context={context}
|
||||||
assignable={false}
|
dropId={canEdit && (!carrying || (binding.id !== carrying.bindingId && binding.id !== carrying.hostBindingId)) ? binding.id : ""}
|
||||||
|
hot={indicator?.kind === "use" && indicator.bindingId === binding.id}
|
||||||
/>
|
/>
|
||||||
<UnitDetail
|
<UnitDetail
|
||||||
binding={binding}
|
binding={binding}
|
||||||
|
|||||||
@@ -1364,6 +1364,24 @@ button.unit-switch[aria-expanded="true"] { color: var(--brand); }
|
|||||||
-webkit-user-drag: none;
|
-webkit-user-drag: none;
|
||||||
}
|
}
|
||||||
body.is-carrying, body.is-carrying * { user-select: none !important; cursor: grabbing; }
|
body.is-carrying, body.is-carrying * { user-select: none !important; cursor: grabbing; }
|
||||||
|
body.is-carrying .entry-mark[data-assign-drop] {
|
||||||
|
box-shadow: inset 0 0 0 2px var(--accent);
|
||||||
|
background: var(--accent-light);
|
||||||
|
cursor: copy;
|
||||||
|
}
|
||||||
|
body.is-carrying .entry-mark[data-assign-drop]::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
inset: -8px;
|
||||||
|
}
|
||||||
|
.entry-mark.is-assign-hot {
|
||||||
|
box-shadow: inset 0 0 0 3px var(--accent);
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.content-section.is-release-target {
|
||||||
|
background: var(--accent-light);
|
||||||
|
box-shadow: inset 0 0 0 2px var(--accent);
|
||||||
|
}
|
||||||
.release-lane {
|
.release-lane {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
Reference in new issue
Block a user