Lege Anlagen und Belege an der Markierung ab, damit die Zeile schlank bleibt und das Verschieben seine eigene Linie behaelt.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c774fb7206
commit
be027a1025
3 files changed
+512
-307
No files matched your search
+122
-64
@@ -18,14 +18,13 @@ import {
|
|||||||
siblingChapterIds,
|
siblingChapterIds,
|
||||||
} from "./chapters.js";
|
} from "./chapters.js";
|
||||||
import {
|
import {
|
||||||
AttachDialog,
|
|
||||||
Chronology,
|
Chronology,
|
||||||
DispatchDialog,
|
DispatchDialog,
|
||||||
EvidenceDialog,
|
EvidenceDialog,
|
||||||
hostMark,
|
hostMark,
|
||||||
restoreFold,
|
restoreFold,
|
||||||
scopeBody,
|
scopeBody,
|
||||||
unitMarks,
|
StructureAssignDialog,
|
||||||
UnitDetail,
|
UnitDetail,
|
||||||
writeAssign,
|
writeAssign,
|
||||||
} from "./correspondence.jsx";
|
} from "./correspondence.jsx";
|
||||||
@@ -455,7 +454,7 @@ function MenuPopover({ open, anchorRef, onClose, label, children, sheet = false
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DirectionControl({ direction = "", title, disabled = false, onChange }) {
|
export function DirectionControl({ direction = "", title, disabled = false, onChange, dropId = "" }) {
|
||||||
const anchorRef = useRef(null);
|
const anchorRef = useRef(null);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const known = directionWord(direction);
|
const known = directionWord(direction);
|
||||||
@@ -467,11 +466,12 @@ export function DirectionControl({ direction = "", title, disabled = false, onCh
|
|||||||
anchorRef.current?.focus();
|
anchorRef.current?.focus();
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<span className={`direction-column${direction === "local" ? " direction-column--local" : ""}`}>
|
<span className={`direction-column${direction === "local" ? " direction-column--local" : ""}`} data-use-drop={dropId || undefined}>
|
||||||
<button
|
<button
|
||||||
ref={anchorRef}
|
ref={anchorRef}
|
||||||
type="button"
|
type="button"
|
||||||
className="direction-trigger"
|
className="direction-trigger"
|
||||||
|
data-use-drop={dropId || undefined}
|
||||||
aria-label={name}
|
aria-label={name}
|
||||||
aria-haspopup="dialog"
|
aria-haspopup="dialog"
|
||||||
aria-expanded={open}
|
aria-expanded={open}
|
||||||
@@ -772,7 +772,6 @@ function EntryActions({
|
|||||||
onPlaceChapter,
|
onPlaceChapter,
|
||||||
onAttach,
|
onAttach,
|
||||||
onDispatch,
|
onDispatch,
|
||||||
onEvidence,
|
|
||||||
}) {
|
}) {
|
||||||
const anchorRef = useRef(null);
|
const anchorRef = useRef(null);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -840,9 +839,8 @@ function EntryActions({
|
|||||||
) : null}
|
) : 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 === 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}
|
{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); }}>Anlage aus der Liste wählen</button> : null}
|
{canEdit && onAttach ? <button type="button" onClick={() => { close(); onAttach(binding); }}>Anlagen und Belege zuordnen</button> : null}
|
||||||
{canEdit && onDispatch ? <button type="button" onClick={() => { close(); onDispatch(binding); }}>Versand dokumentieren</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 Beleg zuordnen …</button> : null}
|
|
||||||
{canEdit ? <button type="button" onClick={() => { close(); onRemove(binding, false); }}>Aus diesem Zusammenhang entfernen</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}
|
{canEdit && canDestroy ? <button type="button" className="danger" onClick={() => { close(); onRemove(binding, true); }}>Überall löschen</button> : null}
|
||||||
</MenuPopover>
|
</MenuPopover>
|
||||||
@@ -863,7 +861,11 @@ function TypeGlyph({ name, tone, size = 28 }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function EntryMark({ element, context, assignable = false, onAssignStart, onAssignEnd }) {
|
function useDropId(node) {
|
||||||
|
return node?.closest?.("[data-use-drop]")?.getAttribute("data-use-drop") || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function EntryMark({ element, context, assignable = false, dropId = "", 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,6 +889,7 @@ function EntryMark({ element, context, assignable = false, onAssignStart, onAssi
|
|||||||
return (
|
return (
|
||||||
<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}
|
||||||
draggable={assignable}
|
draggable={assignable}
|
||||||
role={assignable ? "button" : undefined}
|
role={assignable ? "button" : undefined}
|
||||||
tabIndex={assignable ? 0 : undefined}
|
tabIndex={assignable ? 0 : undefined}
|
||||||
@@ -950,7 +953,6 @@ export function ContentBoard({
|
|||||||
const [pending, setPending] = useState(false);
|
const [pending, setPending] = useState(false);
|
||||||
const [dialog, setDialog] = useState(null);
|
const [dialog, setDialog] = useState(null);
|
||||||
const [draggingId, setDraggingId] = useState("");
|
const [draggingId, setDraggingId] = useState("");
|
||||||
const [carry, setCarry] = useState(null);
|
|
||||||
const [indicator, setIndicator] = useState(null);
|
const [indicator, setIndicator] = useState(null);
|
||||||
const [folded, setFolded] = useState(() => new Set());
|
const [folded, setFolded] = useState(() => new Set());
|
||||||
const [picking, setPicking] = useState(false);
|
const [picking, setPicking] = useState(false);
|
||||||
@@ -959,6 +961,7 @@ export function ContentBoard({
|
|||||||
const dragRef = useRef(null);
|
const dragRef = useRef(null);
|
||||||
const carryRef = useRef(null);
|
const carryRef = useRef(null);
|
||||||
const releaseRef = useRef(null);
|
const releaseRef = useRef(null);
|
||||||
|
const placeUseRef = useRef(null);
|
||||||
const rootRef = useRef(null);
|
const rootRef = useRef(null);
|
||||||
const savingDirection = useRef(false);
|
const savingDirection = useRef(false);
|
||||||
const custom = record?.content_order === "position";
|
const custom = record?.content_order === "position";
|
||||||
@@ -1093,34 +1096,46 @@ export function ContentBoard({
|
|||||||
const node = rootRef.current;
|
const node = rootRef.current;
|
||||||
if (!node) return undefined;
|
if (!node) return undefined;
|
||||||
function place(event) {
|
function place(event) {
|
||||||
if (carryRef.current) {
|
const carried = carryRef.current;
|
||||||
|
if (carried) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
const useId = useDropId(event.target);
|
||||||
|
if (useId && useId !== carried.bindingId) setIndicator({ kind: "use", bindingId: useId });
|
||||||
|
else setIndicator(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const drag = dragRef.current;
|
const drag = dragRef.current;
|
||||||
if (!drag?.html5) return;
|
if (!drag?.html5) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (drag.kind === "chapter") {
|
if (drag.kind === "chapter") {
|
||||||
|
drag.useBindingId = null;
|
||||||
drag.index = chapterUnder(event.clientY, drag.parentId);
|
drag.index = chapterUnder(event.clientY, drag.parentId);
|
||||||
setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter", parentId: drag.parentId || "" });
|
setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter", parentId: drag.parentId || "" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const useId = useDropId(event.target);
|
||||||
|
if (useId && useId !== drag.bindingId) {
|
||||||
|
drag.useBindingId = useId;
|
||||||
|
drag.index = null;
|
||||||
|
setIndicator({ kind: "use", bindingId: useId });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
drag.useBindingId = null;
|
||||||
const sectionId = event.target?.closest?.("[data-section]")?.getAttribute("data-section");
|
const sectionId = event.target?.closest?.("[data-section]")?.getAttribute("data-section");
|
||||||
if (!sectionId) return;
|
if (!sectionId) return;
|
||||||
drag.targetSectionId = sectionId;
|
drag.targetSectionId = sectionId;
|
||||||
drag.index = indexAt(sectionId, event.clientY);
|
drag.index = indexAt(sectionId, event.clientY);
|
||||||
setIndicator({ sectionId, index: drag.index });
|
setIndicator({ sectionId, index: drag.index, kind: "order" });
|
||||||
}
|
}
|
||||||
function drop(event) {
|
function drop(event) {
|
||||||
const carried = carryRef.current;
|
const carried = carryRef.current;
|
||||||
if (carried) {
|
if (carried) {
|
||||||
if (event.target?.closest?.(".drop-well")) return;
|
const useId = useDropId(event.target);
|
||||||
if (carried.source === "attachment" || carried.source === "evidence") {
|
event.preventDefault();
|
||||||
event.preventDefault();
|
|
||||||
releaseRef.current?.(carried);
|
|
||||||
}
|
|
||||||
carryRef.current = null;
|
carryRef.current = null;
|
||||||
setCarry(null);
|
setIndicator(null);
|
||||||
|
if (useId) placeUseRef.current?.(useId, carried);
|
||||||
|
else if (carried.source === "attachment" || carried.source === "evidence") releaseRef.current?.(carried);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!dragRef.current?.html5) return;
|
if (!dragRef.current?.html5) return;
|
||||||
@@ -1384,6 +1399,24 @@ export function ContentBoard({
|
|||||||
dragRef.current = null;
|
dragRef.current = null;
|
||||||
setDraggingId("");
|
setDraggingId("");
|
||||||
setIndicator(null);
|
setIndicator(null);
|
||||||
|
if (drag?.useBindingId && drag.bindingId && drag.useBindingId !== drag.bindingId) {
|
||||||
|
const host = source.find((item) => item.id === drag.useBindingId);
|
||||||
|
const item = source.find((item) => item.id === drag.bindingId);
|
||||||
|
if (host && item && host.element.id !== item.element.id) {
|
||||||
|
setDialog({
|
||||||
|
type: "place-use",
|
||||||
|
host,
|
||||||
|
binding: item,
|
||||||
|
payload: {
|
||||||
|
source: "list",
|
||||||
|
elementId: item.element.id,
|
||||||
|
bindingId: item.id,
|
||||||
|
title: item.element.title,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!drag || !drag.moved || drag.index == null) return;
|
if (!drag || !drag.moved || drag.index == null) return;
|
||||||
if (drag.kind === "chapter") {
|
if (drag.kind === "chapter") {
|
||||||
const ids = siblingChapterIds(chapters, drag.chapterId);
|
const ids = siblingChapterIds(chapters, drag.chapterId);
|
||||||
@@ -1434,13 +1467,23 @@ export function ContentBoard({
|
|||||||
if (event.clientY < 72) window.scrollBy(0, -16);
|
if (event.clientY < 72) window.scrollBy(0, -16);
|
||||||
if (event.clientY > window.innerHeight - 72) window.scrollBy(0, 16);
|
if (event.clientY > window.innerHeight - 72) window.scrollBy(0, 16);
|
||||||
if (drag.kind === "chapter") {
|
if (drag.kind === "chapter") {
|
||||||
|
drag.useBindingId = null;
|
||||||
drag.index = chapterUnder(event.clientY, drag.parentId);
|
drag.index = chapterUnder(event.clientY, drag.parentId);
|
||||||
setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter", parentId: drag.parentId || "" });
|
setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter", parentId: drag.parentId || "" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const useId = useDropId(document.elementFromPoint(event.clientX, event.clientY));
|
||||||
|
if (useId && useId !== drag.bindingId) {
|
||||||
|
drag.useBindingId = useId;
|
||||||
|
drag.index = null;
|
||||||
|
drag.moved = true;
|
||||||
|
setIndicator({ kind: "use", bindingId: useId });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
drag.useBindingId = null;
|
||||||
drag.targetSectionId = sectionUnder(event.clientY) || drag.sectionId;
|
drag.targetSectionId = sectionUnder(event.clientY) || drag.sectionId;
|
||||||
drag.index = indexAt(drag.targetSectionId, event.clientY);
|
drag.index = indexAt(drag.targetSectionId, event.clientY);
|
||||||
setIndicator({ sectionId: drag.targetSectionId, index: drag.index });
|
setIndicator({ sectionId: drag.targetSectionId, index: drag.index, kind: "order" });
|
||||||
}
|
}
|
||||||
|
|
||||||
function release(event) {
|
function release(event) {
|
||||||
@@ -1485,12 +1528,11 @@ export function ContentBoard({
|
|||||||
|
|
||||||
function beginCarry(payload) {
|
function beginCarry(payload) {
|
||||||
carryRef.current = payload;
|
carryRef.current = payload;
|
||||||
setCarry(payload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function endCarry() {
|
function endCarry() {
|
||||||
carryRef.current = null;
|
carryRef.current = null;
|
||||||
setCarry(null);
|
setIndicator(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindingByElement(elementId) {
|
function bindingByElement(elementId) {
|
||||||
@@ -1586,22 +1628,25 @@ export function ContentBoard({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dropReceipt(hostBinding, payload, dispatch) {
|
function openPlace(hostBindingId, payload) {
|
||||||
if (!payload || payload.elementId === hostBinding.element.id) return;
|
const host = source.find((item) => item.id === hostBindingId);
|
||||||
if (payload.source === "evidence" && dispatch && payload.dispatchId === dispatch.id) return;
|
if (!host || !payload || host.element.id === payload.elementId) return;
|
||||||
|
if (payload.source === "attachment" && payload.hostElementId === host.element.id) return;
|
||||||
|
if (payload.source === "evidence") {
|
||||||
|
const found = dispatchOf(payload.dispatchId);
|
||||||
|
if (found?.host?.element.id === host.element.id) return;
|
||||||
|
}
|
||||||
const item = bindingByElement(payload.elementId);
|
const item = bindingByElement(payload.elementId);
|
||||||
const found = payload.source === "evidence" ? dispatchOf(payload.dispatchId) : null;
|
|
||||||
setDialog({
|
setDialog({
|
||||||
type: "evidence",
|
type: "place-use",
|
||||||
|
host,
|
||||||
binding: item || { element: { id: payload.elementId, title: payload.title || "Unterlage", version: 1 } },
|
binding: item || { element: { id: payload.elementId, title: payload.title || "Unterlage", version: 1 } },
|
||||||
hosts: [hostBinding],
|
payload,
|
||||||
dispatchId: dispatch ? dispatch.id : "",
|
|
||||||
replace: found && (!dispatch || found.dispatch.id !== dispatch.id)
|
|
||||||
? { dispatchId: found.dispatch.id, version: found.dispatch.version }
|
|
||||||
: null,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
placeUseRef.current = openPlace;
|
||||||
|
|
||||||
function beginDrag(event, drag) {
|
function beginDrag(event, drag) {
|
||||||
if (pending || (event.button != null && event.button !== 0)) return;
|
if (pending || (event.button != null && event.button !== 0)) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -1666,7 +1711,7 @@ export function ContentBoard({
|
|||||||
) : (
|
) : (
|
||||||
<p className="muted">Noch keine Unterlage und keine Notiz.</p>
|
<p className="muted">Noch keine Unterlage und keine Notiz.</p>
|
||||||
)}
|
)}
|
||||||
<Modal open={dialog?.type === "attach" || dialog?.type === "bulk"} title="Anlagen" onClose={() => setDialog(null)}>
|
<Modal wide open={dialog?.type === "attach" || dialog?.type === "bulk"} title={dialog?.type === "attach" ? "Anlagen und Belege" : "Anlagen"} onClose={() => setDialog(null)}>
|
||||||
{dialog?.type === "bulk" && !dialog.host ? (
|
{dialog?.type === "bulk" && !dialog.host ? (
|
||||||
<form className="stack" onSubmit={async (event) => {
|
<form className="stack" onSubmit={async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -1707,9 +1752,10 @@ export function ContentBoard({
|
|||||||
</form>
|
</form>
|
||||||
) : null}
|
) : null}
|
||||||
{dialog?.type === "attach" && dialog.host ? (
|
{dialog?.type === "attach" && dialog.host ? (
|
||||||
<AttachDialog
|
<StructureAssignDialog
|
||||||
host={source.find((item) => item.id === dialog.host.id) || dialog.host}
|
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)}
|
bindings={source}
|
||||||
|
chapters={chapters}
|
||||||
scope={scopeBody(actionContext(), containerKind, containerId)}
|
scope={scopeBody(actionContext(), containerKind, containerId)}
|
||||||
pending={pending}
|
pending={pending}
|
||||||
onClose={() => setDialog(null)}
|
onClose={() => setDialog(null)}
|
||||||
@@ -1728,24 +1774,44 @@ export function ContentBoard({
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal open={dialog?.type === "receipt-source"} title="Beleg wählen" onClose={() => setDialog(null)}>
|
<Modal open={dialog?.type === "place-use"} title="Ablegen" onClose={() => setDialog(null)}>
|
||||||
{dialog?.type === "receipt-source" ? (
|
{dialog?.type === "place-use" ? (
|
||||||
<div className="stack">
|
<div className="stack">
|
||||||
<p>Unterlage aus diesem Vorgang als Beleg von <strong>{dialog.host.element.title}</strong>.</p>
|
<p><strong>{dialog.payload.title || dialog.binding.element.title}</strong> an <strong>{dialog.host.element.title}</strong></p>
|
||||||
<ul className="choice-list choice-list--scroll">
|
<button type="button" disabled={pending} onClick={async () => {
|
||||||
{source.filter((item) => item.element.id !== dialog.host.element.id).map((item) => (
|
await dropAttachment(dialog.host, dialog.payload);
|
||||||
<li key={item.id}>
|
setDialog(null);
|
||||||
<span>{item.element.title}</span>
|
}}>Als Anlage</button>
|
||||||
<button type="button" onClick={() => setDialog({
|
<button type="button" disabled={pending} onClick={async () => {
|
||||||
type: "evidence",
|
const payload = dialog.payload;
|
||||||
binding: item,
|
if (payload.source === "attachment") {
|
||||||
hosts: [dialog.host],
|
const from = bindingByElement(payload.hostElementId);
|
||||||
dispatchId: dialog.dispatchId,
|
if (from) {
|
||||||
})}>Als Beleg</button>
|
setPending(true);
|
||||||
</li>
|
setError("");
|
||||||
))}
|
try {
|
||||||
</ul>
|
await api(`/api/v1/elements/${from.element.id}/attachments/${payload.elementId}/detach`, {
|
||||||
{!source.filter((item) => item.element.id !== dialog.host.element.id).length ? <p className="muted">Keine weitere Unterlage.</p> : null}
|
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>
|
||||||
|
<button type="button" className="quiet" onClick={() => setDialog(null)}>Abbrechen</button>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -1871,7 +1937,7 @@ export function ContentBoard({
|
|||||||
const sourceSymbol = contentSourceSymbol(element);
|
const sourceSymbol = contentSourceSymbol(element);
|
||||||
const way = directionWord(binding.communication?.direction) || "Keine Angabe";
|
const way = directionWord(binding.communication?.direction) || "Keine Angabe";
|
||||||
const party = counterpartLabel(element, binding.communication?.direction);
|
const party = counterpartLabel(element, binding.communication?.direction);
|
||||||
const facts = [party, formatDate(fachDate(element)), sourceLabel(element), way, unitMarks(binding)].filter(Boolean).join(" · ");
|
const facts = [party, formatDate(fachDate(element)), sourceLabel(element), way].filter(Boolean).join(" · ");
|
||||||
const samePiece = hostMark(binding);
|
const samePiece = hostMark(binding);
|
||||||
const originText = binding.origin && section.title && !binding.origin.includes(section.title)
|
const originText = binding.origin && section.title && !binding.origin.includes(section.title)
|
||||||
? `${binding.origin}${binding.shared ? " · weitere Einbindung" : ""}`
|
? `${binding.origin}${binding.shared ? " · weitere Einbindung" : ""}`
|
||||||
@@ -1881,6 +1947,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" : "",
|
||||||
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" : "",
|
||||||
@@ -1893,7 +1960,7 @@ export function ContentBoard({
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<li key={binding.id} data-binding={binding.id} className={rowClass}>
|
<li key={binding.id} data-binding={binding.id} className={rowClass}>
|
||||||
{indicator?.sectionId === section.id && indicator?.kind !== "chapter" && indicator.index === index ? <div className="insert-line" /> : null}
|
{indicator?.kind === "order" && indicator?.sectionId === section.id && indicator.index === index ? <div className="insert-line" /> : null}
|
||||||
{picking ? (
|
{picking ? (
|
||||||
<label className="pick-box">
|
<label className="pick-box">
|
||||||
<input
|
<input
|
||||||
@@ -1914,6 +1981,7 @@ export function ContentBoard({
|
|||||||
direction={directionValue(binding.communication)}
|
direction={directionValue(binding.communication)}
|
||||||
title={element.title}
|
title={element.title}
|
||||||
disabled={pending}
|
disabled={pending}
|
||||||
|
dropId={binding.id}
|
||||||
onChange={(value) => saveRowDirection(binding, value)}
|
onChange={(value) => saveRowDirection(binding, value)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -1941,6 +2009,7 @@ export function ContentBoard({
|
|||||||
<EntryMark
|
<EntryMark
|
||||||
element={element}
|
element={element}
|
||||||
context={context}
|
context={context}
|
||||||
|
dropId={canEdit ? binding.id : ""}
|
||||||
assignable={canEdit && !pending && !picking}
|
assignable={canEdit && !pending && !picking}
|
||||||
onAssignStart={(event) => {
|
onAssignStart={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -1988,7 +2057,6 @@ export function ContentBoard({
|
|||||||
binding={binding}
|
binding={binding}
|
||||||
canEdit={canEdit}
|
canEdit={canEdit}
|
||||||
pending={pending}
|
pending={pending}
|
||||||
carry={carry}
|
|
||||||
scope={scopeBody(actionContext(), containerKind, containerId)}
|
scope={scopeBody(actionContext(), containerKind, containerId)}
|
||||||
onCarryStart={beginCarry}
|
onCarryStart={beginCarry}
|
||||||
onCarryEnd={endCarry}
|
onCarryEnd={endCarry}
|
||||||
@@ -1996,15 +2064,6 @@ export function ContentBoard({
|
|||||||
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);
|
||||||
}}
|
}}
|
||||||
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({
|
onDetach={(elementId) => releaseToList({
|
||||||
source: "attachment",
|
source: "attachment",
|
||||||
elementId,
|
elementId,
|
||||||
@@ -2051,12 +2110,11 @@ export function ContentBoard({
|
|||||||
onPlaceChapter={placeChapter}
|
onPlaceChapter={placeChapter}
|
||||||
onAttach={(row) => setDialog({ type: "attach", host: row })}
|
onAttach={(row) => setDialog({ type: "attach", host: row })}
|
||||||
onDispatch={(row) => setDialog({ type: "dispatch", host: row })}
|
onDispatch={(row) => setDialog({ type: "dispatch", host: row })}
|
||||||
onEvidence={(row) => setDialog({ type: "evidence", binding: row })}
|
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{indicator?.sectionId === section.id && indicator?.kind !== "chapter" && indicator.index === section.items.length ? <li className="insert-line" aria-hidden="true" /> : null}
|
{indicator?.kind === "order" && indicator?.sectionId === section.id && indicator.index === section.items.length ? <li className="insert-line" aria-hidden="true" /> : null}
|
||||||
</ol> : null}
|
</ol> : null}
|
||||||
{expanded && section.children?.length ? (
|
{expanded && section.children?.length ? (
|
||||||
<div className="chapter-children">
|
<div className="chapter-children">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { api } from "../api.js";
|
import { api } from "../api.js";
|
||||||
|
import { buildChapterSections, sectionCounts } from "./chapters.js";
|
||||||
|
|
||||||
function formatDate(value) {
|
function formatDate(value) {
|
||||||
if (!value) return "Ohne Datum";
|
if (!value) return "Ohne Datum";
|
||||||
@@ -81,34 +82,103 @@ export function writeAssign(event, payload) {
|
|||||||
event.dataTransfer.setData("text/plain", payload.title || "");
|
event.dataTransfer.setData("text/plain", payload.title || "");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readAssign(event) {
|
function ancestorIds(chapters, chapterId) {
|
||||||
const raw = event.dataTransfer.getData(ASSIGN_MIME);
|
const byId = new Map((chapters || []).map((chapter) => [chapter.id, chapter]));
|
||||||
if (!raw) return null;
|
const ids = [];
|
||||||
try {
|
const seen = new Set();
|
||||||
return JSON.parse(raw);
|
let current = chapterId ? byId.get(chapterId) : null;
|
||||||
} catch {
|
while (current && !seen.has(current.id)) {
|
||||||
return null;
|
seen.add(current.id);
|
||||||
|
ids.push(current.id);
|
||||||
|
current = current.parent_chapter_id ? byId.get(current.parent_chapter_id) : null;
|
||||||
}
|
}
|
||||||
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
function assignEvent(event) {
|
function branchItems(section) {
|
||||||
return [...(event.dataTransfer?.types || [])].includes(ASSIGN_MIME);
|
return [
|
||||||
|
...(section.items || []),
|
||||||
|
...(section.children || []).flatMap(branchItems),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AttachDialog({ host, candidates, scope, pending, onClose, onDone }) {
|
function titleMatches(binding, needle) {
|
||||||
const current = host.correspondence?.attachments || [];
|
if (!needle) return true;
|
||||||
const taken = new Set(current.map((item) => item.element_id));
|
return (binding.element?.title || "").toLowerCase().includes(needle);
|
||||||
|
}
|
||||||
|
|
||||||
|
function branchVisible(section, needle) {
|
||||||
|
if (!needle) return true;
|
||||||
|
if ((section.items || []).some((item) => titleMatches(item, needle))) return true;
|
||||||
|
return (section.children || []).some((child) => branchVisible(child, needle));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function StructureAssignDialog({ host, bindings, chapters, scope, pending, onClose, onDone }) {
|
||||||
|
const tree = useMemo(() => buildChapterSections(chapters, bindings), [chapters, bindings]);
|
||||||
|
const [opened, setOpened] = useState(() => new Set(host.chapter_id ? ancestorIds(chapters, host.chapter_id) : ["loose"]));
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
|
const [selected, setSelected] = useState(() => new Set());
|
||||||
|
const [step, setStep] = useState("pick");
|
||||||
|
const [role, setRole] = useState("email");
|
||||||
|
const [fold, setFold] = useState("evidence");
|
||||||
|
const [dispatchId, setDispatchId] = useState(host.correspondence?.dispatches?.[0]?.id || "");
|
||||||
|
const [channel, setChannel] = useState("email");
|
||||||
|
const [sentOn, setSentOn] = useState("");
|
||||||
|
const [counterpart, setCounterpart] = useState("");
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const needle = query.trim().toLowerCase();
|
const needle = query.trim().toLowerCase();
|
||||||
const available = candidates.filter((item) => {
|
const taken = new Set((host.correspondence?.attachments || []).map((item) => item.element_id));
|
||||||
if (taken.has(item.element.id) || item.element.id === host.element.id) return false;
|
const dispatches = host.correspondence?.dispatches || [];
|
||||||
if (!needle) return true;
|
|
||||||
return item.element.title.toLowerCase().includes(needle);
|
|
||||||
});
|
|
||||||
|
|
||||||
async function add(elementId) {
|
function toggle(id) {
|
||||||
|
setSelected((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
if (next.has(id)) next.delete(id);
|
||||||
|
else next.add(id);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleIds(ids) {
|
||||||
|
if (!ids.length) return;
|
||||||
|
setSelected((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
const allOn = ids.every((id) => next.has(id));
|
||||||
|
ids.forEach((id) => {
|
||||||
|
if (allOn) next.delete(id);
|
||||||
|
else next.add(id);
|
||||||
|
});
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleChapter(section) {
|
||||||
|
toggleIds(branchItems(section).map((item) => item.element.id).filter((id) => id !== host.element.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
function visibleIds() {
|
||||||
|
const ids = [];
|
||||||
|
function walk(section) {
|
||||||
|
if (!branchVisible(section, needle)) return;
|
||||||
|
for (const item of section.items || []) {
|
||||||
|
if (item.element.id !== host.element.id && titleMatches(item, needle)) ids.push(item.element.id);
|
||||||
|
}
|
||||||
|
for (const child of section.children || []) walk(child);
|
||||||
|
}
|
||||||
|
tree.roots.forEach(walk);
|
||||||
|
for (const item of tree.loose) {
|
||||||
|
if (item.element.id !== host.element.id && titleMatches(item, needle)) ids.push(item.element.id);
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveAttachments() {
|
||||||
|
const ids = [...selected].filter((id) => id !== host.element.id && !taken.has(id));
|
||||||
|
if (!ids.length) {
|
||||||
|
setError("In der Auswahl ist keine neue Anlage.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setError("");
|
setError("");
|
||||||
try {
|
try {
|
||||||
@@ -116,68 +186,216 @@ export function AttachDialog({ host, candidates, scope, pending, onClose, onDone
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
body: fieldBody(scope, {
|
body: fieldBody(scope, {
|
||||||
expected_version: host.element.version,
|
expected_version: host.element.version,
|
||||||
attachment_element_ids: [elementId],
|
attachment_element_ids: ids,
|
||||||
fold: "attachment",
|
fold: "attachment",
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
onDone();
|
onDone();
|
||||||
|
onClose();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err.message);
|
setError(err.message);
|
||||||
|
onDone();
|
||||||
} finally {
|
} finally {
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove(elementId) {
|
async function saveReceipts(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const ids = [...selected].filter((id) => id !== host.element.id);
|
||||||
|
if (!ids.length) return;
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setError("");
|
setError("");
|
||||||
try {
|
try {
|
||||||
await api(`/api/v1/elements/${host.element.id}/attachments/${elementId}/detach`, {
|
if (!dispatchId) {
|
||||||
method: "POST",
|
await api(`/api/v1/elements/${host.element.id}/dispatches`, {
|
||||||
body: fieldBody(scope, { expected_version: host.element.version }),
|
method: "POST",
|
||||||
});
|
body: fieldBody(scope, {
|
||||||
|
expected_version: host.element.version,
|
||||||
|
channel,
|
||||||
|
sent_on: sentOn || null,
|
||||||
|
counterpart: counterpart.trim() || null,
|
||||||
|
attachment_element_ids: (host.correspondence?.attachments || []).map((item) => item.element_id),
|
||||||
|
evidence: ids.map((id) => ({ element_id: id, role, fold })),
|
||||||
|
historical_gap: false,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const dispatch = dispatches.find((item) => item.id === dispatchId);
|
||||||
|
const already = new Set((dispatch?.evidence || []).map((item) => item.element_id));
|
||||||
|
const fresh = ids.filter((id) => !already.has(id));
|
||||||
|
if (!fresh.length) {
|
||||||
|
setError("Diese Belege liegen an dem Versand bereits.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let version = dispatch?.version || 1;
|
||||||
|
for (const id of fresh) {
|
||||||
|
await api(`/api/v1/dispatches/${dispatchId}/evidence`, {
|
||||||
|
method: "POST",
|
||||||
|
body: fieldBody(scope, {
|
||||||
|
expected_version: version,
|
||||||
|
element_id: id,
|
||||||
|
role,
|
||||||
|
fold,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
version += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
onDone();
|
onDone();
|
||||||
|
onClose();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err.message);
|
setError(err.message);
|
||||||
|
onDone();
|
||||||
} finally {
|
} finally {
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderRow(item, depth) {
|
||||||
|
const id = item.element.id;
|
||||||
|
const isHost = id === host.element.id;
|
||||||
|
return (
|
||||||
|
<li key={item.id} className="pick-tree__row" style={{ "--depth": depth }}>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" checked={selected.has(id)} disabled={isHost} onChange={() => toggle(id)} />
|
||||||
|
<span>{item.element.title}</span>
|
||||||
|
<span className="muted">{formatDate(item.element.dates?.document_on)}</span>
|
||||||
|
{isHost ? <span className="muted">dieses Schriftstück</span> : null}
|
||||||
|
{taken.has(id) ? <span className="muted">Anlage</span> : null}
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSection(section, depth) {
|
||||||
|
if (!branchVisible(section, needle)) return null;
|
||||||
|
const expanded = Boolean(needle) || opened.has(section.id);
|
||||||
|
const counts = sectionCounts(section);
|
||||||
|
const total = counts.direct + counts.nested;
|
||||||
|
return (
|
||||||
|
<li key={section.id}>
|
||||||
|
<div className="pick-tree__chapter" style={{ "--depth": depth }}>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="quiet"
|
||||||
|
aria-expanded={expanded}
|
||||||
|
onClick={() => setOpened((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
if (next.has(section.id)) next.delete(section.id);
|
||||||
|
else next.add(section.id);
|
||||||
|
return next;
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{expanded ? "▾" : "▸"} {section.title}
|
||||||
|
<span className="muted">{total}</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="quiet" aria-label={`Alle in ${section.title} auswählen`} onClick={() => toggleChapter(section)}>alle</button>
|
||||||
|
</div>
|
||||||
|
{expanded ? (
|
||||||
|
<ul className="pick-tree__items">
|
||||||
|
{(section.items || []).filter((item) => titleMatches(item, needle)).map((item) => renderRow(item, depth + 1))}
|
||||||
|
{(section.children || []).map((child) => renderSection(child, depth + 1))}
|
||||||
|
</ul>
|
||||||
|
) : null}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const loose = tree.loose.filter((item) => titleMatches(item, needle));
|
||||||
|
const roots = tree.roots.map((section) => renderSection(section, 0)).filter(Boolean);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="stack">
|
<div className="stack pick-tree">
|
||||||
<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>
|
<p>Zuordnen an <strong>{host.element.title}</strong>. Kapitel bleiben geschlossen, bis sie geöffnet werden.</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>
|
<label>
|
||||||
Weitere Unterlage
|
Suchen
|
||||||
<input value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Titel suchen" />
|
<input value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Titel" />
|
||||||
</label>
|
</label>
|
||||||
{available.length ? (
|
{step === "pick" ? (
|
||||||
<ul className="choice-list choice-list--scroll">
|
<>
|
||||||
{available.map((item) => (
|
<ul className="pick-tree__list">
|
||||||
<li key={item.id}>
|
{roots}
|
||||||
<span>{item.element.title}</span>
|
{loose.length ? (
|
||||||
<span className="muted">{formatDate(item.element.dates?.document_on)}</span>
|
<li>
|
||||||
<button type="button" disabled={pending || busy} onClick={() => add(item.element.id)}>Als Anlage</button>
|
<div className="pick-tree__chapter">
|
||||||
</li>
|
<button
|
||||||
))}
|
type="button"
|
||||||
</ul>
|
className="quiet"
|
||||||
) : <p className="muted">Keine weitere passende Unterlage in diesem Vorgang.</p>}
|
aria-expanded={Boolean(needle) || opened.has("loose")}
|
||||||
|
onClick={() => setOpened((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
if (next.has("loose")) next.delete("loose");
|
||||||
|
else next.add("loose");
|
||||||
|
return next;
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{needle || opened.has("loose") ? "▾" : "▸"} Ohne Kapitel
|
||||||
|
<span className="muted">{loose.length}</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="quiet" onClick={() => toggleIds(loose.map((item) => item.element.id).filter((id) => id !== host.element.id))}>alle</button>
|
||||||
|
</div>
|
||||||
|
{needle || opened.has("loose") ? (
|
||||||
|
<ul className="pick-tree__items">
|
||||||
|
{loose.map((item) => renderRow(item, 1))}
|
||||||
|
</ul>
|
||||||
|
) : null}
|
||||||
|
</li>
|
||||||
|
) : null}
|
||||||
|
{!roots.length && !loose.length ? <li className="muted">Nichts mit diesem Titel.</li> : null}
|
||||||
|
</ul>
|
||||||
|
<div className="pick-tree__bar">
|
||||||
|
<span>{selected.size} ausgewählt</span>
|
||||||
|
{needle ? <button type="button" className="quiet" onClick={() => toggleIds(visibleIds())}>Sichtbare</button> : null}
|
||||||
|
<button type="button" disabled={pending || busy || !selected.size} onClick={saveAttachments}>Als Anlagen</button>
|
||||||
|
<button type="button" disabled={pending || busy || !selected.size} onClick={() => { setError(""); setStep("receipt"); }}>Als Belege</button>
|
||||||
|
<button type="button" className="quiet" onClick={onClose}>Schließen</button>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<form className="stack" onSubmit={saveReceipts}>
|
||||||
|
<p>{selected.size} Belege. Dieselbe Rolle gilt für die Auswahl.</p>
|
||||||
|
<label>
|
||||||
|
Versand
|
||||||
|
<select value={dispatchId} onChange={(event) => setDispatchId(event.target.value)}>
|
||||||
|
<option value="">Neuen Versand anlegen</option>
|
||||||
|
{dispatches.map((item) => (
|
||||||
|
<option key={item.id} value={item.id}>
|
||||||
|
{item.sent_on ? formatDate(item.sent_on) : "undatiert"} · {item.channel_label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
{!dispatchId ? (
|
||||||
|
<>
|
||||||
|
<label>
|
||||||
|
Weg
|
||||||
|
<select value={channel} onChange={(event) => setChannel(event.target.value)}>
|
||||||
|
<option value="email">E-Mail</option>
|
||||||
|
<option value="post">Post</option>
|
||||||
|
<option value="other">Sonstiger Weg</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label>Versanddatum<input type="date" value={sentOn} onChange={(event) => setSentOn(event.target.value)} /></label>
|
||||||
|
<label>Gegenüber<input value={counterpart} onChange={(event) => setCounterpart(event.target.value)} maxLength={200} /></label>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
<label>
|
||||||
|
Rolle
|
||||||
|
<select value={role} onChange={(event) => setRole(event.target.value)}>
|
||||||
|
{RECEIPT_ROLES.map(([value, label]) => <option key={value} value={value}>{label}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Darstellung in der Liste</legend>
|
||||||
|
<label><input type="radio" name="assign-fold" checked={fold === "evidence"} onChange={() => setFold("evidence")} /> Nur am Versand zeigen</label>
|
||||||
|
<label><input type="radio" name="assign-fold" checked={fold === "keep"} onChange={() => setFold("keep")} /> Zusätzlich als eigenen Eintrag behalten</label>
|
||||||
|
</fieldset>
|
||||||
|
<button type="submit" disabled={pending || busy}>Belege zuordnen</button>
|
||||||
|
<button type="button" className="quiet" onClick={() => setStep("pick")}>Zurück zur Struktur</button>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
{error ? <p className="error">{error}</p> : null}
|
{error ? <p className="error">{error}</p> : null}
|
||||||
<button type="button" className="quiet" onClick={onClose}>Schließen</button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -425,42 +643,6 @@ export function ComparisonList({ comparisons = [], state, reason }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
function chipDrag(enabled, payload, onCarryStart, onCarryEnd) {
|
||||||
return {
|
return {
|
||||||
role: "button",
|
role: "button",
|
||||||
@@ -482,153 +664,118 @@ export function UnitDetail({
|
|||||||
canEdit,
|
canEdit,
|
||||||
pending,
|
pending,
|
||||||
scope,
|
scope,
|
||||||
carry,
|
|
||||||
onOpen,
|
onOpen,
|
||||||
onDetach,
|
onDetach,
|
||||||
onDetachEvidence,
|
onDetachEvidence,
|
||||||
onUnfold,
|
onUnfold,
|
||||||
onCarryStart,
|
onCarryStart,
|
||||||
onCarryEnd,
|
onCarryEnd,
|
||||||
onDropAttachment,
|
|
||||||
onDropReceipt,
|
|
||||||
onPickAttachments,
|
|
||||||
onPickReceipt,
|
|
||||||
}) {
|
}) {
|
||||||
const pack = binding.correspondence || {};
|
const pack = binding.correspondence || {};
|
||||||
const attachments = pack.attachments || [];
|
const attachments = pack.attachments || [];
|
||||||
const dispatches = pack.dispatches || [];
|
const dispatches = pack.dispatches || [];
|
||||||
const show = canEdit || attachments.length || dispatches.length || (pack.hosts || []).length;
|
const [open, setOpen] = useState(false);
|
||||||
if (!show) return null;
|
if (!attachments.length && !dispatches.length) return null;
|
||||||
const armed = Boolean(carry && carry.elementId !== binding.element.id);
|
const summary = unitMarks(binding) || "Anlagen und Belege";
|
||||||
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 (
|
return (
|
||||||
<div className="unit-detail">
|
<div className="unit-fold">
|
||||||
<section>
|
<button type="button" className="quiet unit-toggle" aria-expanded={open} onClick={() => setOpen((value) => !value)}>
|
||||||
<h4>Anlagen</h4>
|
{open ? "Zuklappen" : summary}
|
||||||
{canEdit ? (
|
</button>
|
||||||
<DropWell
|
{open ? (
|
||||||
label="Anlage hier ablegen"
|
<div className="unit-detail unit-detail--slim">
|
||||||
hint="Als Anlage zuordnen"
|
{attachments.length ? (
|
||||||
armed={armed}
|
<section>
|
||||||
onDrop={onDropAttachment}
|
<h4>Anlagen</h4>
|
||||||
onPick={onPickAttachments}
|
<ol>
|
||||||
/>
|
{attachments.map((item, index) => (
|
||||||
) : null}
|
<li key={item.id} className="use-chip">
|
||||||
{attachments.length ? (
|
{canEdit ? (
|
||||||
<ol>
|
<span
|
||||||
{attachments.map((item, index) => (
|
className="use-chip__grip"
|
||||||
<li key={item.id} className="use-chip">
|
aria-label={`${item.title} aus den Anlagen ziehen`}
|
||||||
<span
|
{...chipDrag(!pending, {
|
||||||
className="use-chip__grip"
|
source: "attachment",
|
||||||
aria-label={`${item.title} aus den Anlagen ziehen`}
|
elementId: item.element_id,
|
||||||
{...chipDrag(canEdit && !pending, {
|
hostElementId: binding.element.id,
|
||||||
source: "attachment",
|
bindingId: item.binding_id || "",
|
||||||
elementId: item.element_id,
|
title: item.title,
|
||||||
hostElementId: binding.element.id,
|
}, onCarryStart, onCarryEnd)}
|
||||||
title: item.title,
|
/>
|
||||||
}, onCarryStart, onCarryEnd)}
|
) : null}
|
||||||
/>
|
<span>{index + 1}. {item.title}</span>
|
||||||
<span>{index + 1}. {item.title}</span>
|
<span className="muted">{formatDate(item.document_on)}</span>
|
||||||
<span className="muted">{formatDate(item.document_on)}</span>
|
{item.binding_id ? (
|
||||||
{item.binding_id ? (
|
<button type="button" className="quiet" onClick={() => onOpen(item.element_id)}>Öffnen</button>
|
||||||
<button type="button" className="quiet" onClick={() => onOpen(item.element_id)}>Öffnen</button>
|
) : null}
|
||||||
) : null}
|
{canEdit ? (
|
||||||
{canEdit ? (
|
<button type="button" className="quiet" disabled={pending} onClick={() => onDetach(item.element_id)}>In die Liste</button>
|
||||||
<button type="button" className="quiet" disabled={pending} onClick={() => onDetach(item.element_id)}>In die Liste</button>
|
) : null}
|
||||||
) : null}
|
</li>
|
||||||
</li>
|
))}
|
||||||
))}
|
</ol>
|
||||||
</ol>
|
</section>
|
||||||
) : null}
|
|
||||||
</section>
|
|
||||||
{dispatches.map((item) => (
|
|
||||||
<section key={item.id}>
|
|
||||||
<h4>
|
|
||||||
Versand {item.undated ? "undatiert" : formatDate(item.sent_on)} · {item.channel_label}
|
|
||||||
{item.counterpart ? ` · ${item.counterpart}` : " · Gegenüber unbekannt"}
|
|
||||||
</h4>
|
|
||||||
<p className="muted">
|
|
||||||
{item.provenance === "reconstructed" ? "Rekonstruierte Dokumentation. " : "Beim Dokumentieren gesichert. "}
|
|
||||||
{item.completeness === "secured" ? "Inhaltsstand gesichert." : null}
|
|
||||||
{item.completeness === "partial" ? "Inhaltsstand nur teilweise gesichert." : null}
|
|
||||||
{item.completeness === "gap" ? "Kein vollständiger gesicherter Inhaltsstand." : null}
|
|
||||||
</p>
|
|
||||||
{canEdit ? (
|
|
||||||
<DropWell
|
|
||||||
label="Beleg hier ablegen"
|
|
||||||
hint="Als Beleg dieses Versands"
|
|
||||||
armed={armed}
|
|
||||||
onDrop={(payload) => onDropReceipt(payload, item)}
|
|
||||||
onPick={() => onPickReceipt(item)}
|
|
||||||
/>
|
|
||||||
) : null}
|
) : null}
|
||||||
{item.evidence?.length ? (
|
{dispatches.map((item) => (
|
||||||
<ul>
|
<section key={item.id}>
|
||||||
{item.evidence.map((proof) => (
|
<h4>
|
||||||
<li key={proof.id} className="use-chip">
|
Versand {item.undated ? "undatiert" : formatDate(item.sent_on)} · {item.channel_label}
|
||||||
<span
|
{item.counterpart ? ` · ${item.counterpart}` : ""}
|
||||||
className="use-chip__grip"
|
</h4>
|
||||||
aria-label={`${proof.title} aus den Belegen ziehen`}
|
{item.evidence?.length ? (
|
||||||
{...chipDrag(canEdit && !pending, {
|
<ul>
|
||||||
source: "evidence",
|
{item.evidence.map((proof) => (
|
||||||
elementId: proof.element_id,
|
<li key={proof.id} className="use-chip">
|
||||||
dispatchId: item.id,
|
{canEdit ? (
|
||||||
version: item.version,
|
<span
|
||||||
title: proof.title,
|
className="use-chip__grip"
|
||||||
}, onCarryStart, onCarryEnd)}
|
aria-label={`${proof.title} aus den Belegen ziehen`}
|
||||||
/>
|
{...chipDrag(!pending, {
|
||||||
<button type="button" className="quiet" onClick={() => onOpen(proof.element_id)}>
|
source: "evidence",
|
||||||
{receiptRoleLabel(proof.role, proof.role_label)}: {proof.title}
|
elementId: proof.element_id,
|
||||||
</button>
|
dispatchId: item.id,
|
||||||
<span className="muted">{formatDate(proof.document_on)}</span>
|
hostElementId: binding.element.id,
|
||||||
{proof.source_state === "gap" ? <span>Lücke: {proof.gap_reason}</span> : null}
|
version: item.version,
|
||||||
<ComparisonList comparisons={proof.comparisons} state={proof.source_state} reason={proof.gap_reason} />
|
title: proof.title,
|
||||||
{canEdit ? (
|
}, onCarryStart, onCarryEnd)}
|
||||||
<button type="button" className="quiet" disabled={pending} onClick={() => onDetachEvidence(proof, item)}>
|
/>
|
||||||
In die Liste
|
) : null}
|
||||||
</button>
|
<button type="button" className="quiet" onClick={() => onOpen(proof.element_id)}>
|
||||||
) : null}
|
{receiptRoleLabel(proof.role, proof.role_label)}: {proof.title}
|
||||||
{canEdit && proof.listed_fold === "evidence" ? (
|
</button>
|
||||||
<button type="button" className="quiet" disabled={pending} onClick={() => onUnfold(proof.element_id)}>
|
<span className="muted">{formatDate(proof.document_on)}</span>
|
||||||
Zusätzlich in der Liste zeigen
|
{proof.source_state === "gap" ? <span>Lücke: {proof.gap_reason}</span> : null}
|
||||||
</button>
|
{canEdit ? (
|
||||||
) : null}
|
<button type="button" className="quiet" disabled={pending} onClick={() => onDetachEvidence(proof, item)}>
|
||||||
</li>
|
In die Liste
|
||||||
))}
|
</button>
|
||||||
</ul>
|
) : null}
|
||||||
) : null}
|
{canEdit && proof.listed_fold === "evidence" ? (
|
||||||
<details className="use-editions">
|
<button type="button" className="quiet" disabled={pending} onClick={() => onUnfold(proof.element_id)}>
|
||||||
<summary>Gesicherte Fassung</summary>
|
Zusätzlich in der Liste zeigen
|
||||||
<ol>
|
</button>
|
||||||
{item.items.map((part) => (
|
) : null}
|
||||||
<li key={part.id}>
|
</li>
|
||||||
<span>{part.role === "host" ? "Schreiben" : "Anlage"}: {part.title}</span>
|
))}
|
||||||
<span className="muted">Dokumentdatum {formatDate(part.document_on)}</span>
|
</ul>
|
||||||
{part.source_state === "gap" ? <span>Lücke: {part.gap_reason}</span> : scope ? (
|
) : <p className="muted">Ohne Beleg</p>}
|
||||||
<a href={snapshotHref(item.id, part.id, scope)}>Öffnen</a>
|
<details className="use-editions">
|
||||||
) : <span>Gesichert</span>}
|
<summary>Gesicherte Fassung</summary>
|
||||||
</li>
|
<ol>
|
||||||
))}
|
{item.items.map((part) => (
|
||||||
</ol>
|
<li key={part.id}>
|
||||||
</details>
|
<span>{part.role === "host" ? "Schreiben" : "Anlage"}: {part.title}</span>
|
||||||
</section>
|
<span className="muted">{formatDate(part.document_on)}</span>
|
||||||
))}
|
{part.source_state === "gap" ? <span>Lücke: {part.gap_reason}</span> : scope ? (
|
||||||
{canEdit ? (
|
<a href={snapshotHref(item.id, part.id, scope)}>Öffnen</a>
|
||||||
<DropWell
|
) : <span>Gesichert</span>}
|
||||||
label="Beleg für einen weiteren Versand"
|
</li>
|
||||||
hint="Neuen Versand mit diesem Beleg anlegen"
|
))}
|
||||||
armed={armed}
|
</ol>
|
||||||
onDrop={(payload) => onDropReceipt(payload, null)}
|
</details>
|
||||||
onPick={() => onPickReceipt(null)}
|
</section>
|
||||||
/>
|
))}
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+17
-17
@@ -1329,33 +1329,33 @@ button.hierarchy__row { width: 100%; min-height: 34px; padding: 6px 8px; border:
|
|||||||
.choice-list li, .choice-list label { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
.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--scroll { max-height: 240px; overflow: auto; }
|
||||||
.choice-list__move { display: inline-flex; gap: 4px; margin-left: auto; }
|
.choice-list__move { display: inline-flex; gap: 4px; margin-left: auto; }
|
||||||
|
.unit-fold { margin-top: 2px; }
|
||||||
.unit-detail, .comparison, .chrono { display: grid; gap: 8px; margin-top: 8px; }
|
.unit-detail, .comparison, .chrono { display: grid; gap: 8px; margin-top: 8px; }
|
||||||
|
.unit-detail--slim { gap: 4px; margin-top: 2px; }
|
||||||
.unit-detail h4, .chrono h3 { margin: 0; font-size: 13px; }
|
.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 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--slim section { padding: 0; border: 0; border-radius: 0; background: transparent; gap: 2px; }
|
||||||
|
.unit-detail--slim button.quiet, .unit-detail--slim summary { min-height: 22px; height: 22px; padding: 0 6px; font-size: 12px; }
|
||||||
.unit-detail ol, .unit-detail ul, .comparison ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
|
.unit-detail ol, .unit-detail ul, .comparison ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
|
||||||
|
.unit-detail--slim ol, .unit-detail--slim ul { gap: 0; }
|
||||||
.unit-detail li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; min-width: 0; max-width: 100%; }
|
.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; }
|
.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 { 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; }
|
.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; }
|
.entry-mark[draggable="true"] { cursor: grab; }
|
||||||
.use-editions summary { cursor: pointer; color: var(--text2); font-size: 13px; }
|
.use-editions summary { cursor: pointer; color: var(--text2); font-size: 13px; }
|
||||||
.unit-toggle { min-height: 32px; }
|
.unit-toggle { min-height: 22px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
|
||||||
|
.preview-row.is-use-target .direction-trigger,
|
||||||
|
.preview-row.is-use-target .entry-mark {
|
||||||
|
box-shadow: inset 0 0 0 2px var(--accent);
|
||||||
|
background: var(--accent-light);
|
||||||
|
}
|
||||||
|
.pick-tree__list { max-height: 60vh; overflow: auto; margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
|
||||||
|
.pick-tree__items { margin: 0; padding: 0; list-style: none; }
|
||||||
|
.pick-tree__chapter, .pick-tree__row { display: flex; gap: 8px; align-items: center; min-height: 28px; padding-left: calc(var(--depth, 0) * 14px); }
|
||||||
|
.pick-tree__chapter > span, .pick-tree__row label { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
|
||||||
|
.pick-tree button.quiet { min-height: 28px; height: 28px; padding: 0 8px; font-size: 13px; }
|
||||||
|
.pick-tree__bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }
|
||||||
.count { white-space: normal; }
|
.count { white-space: normal; }
|
||||||
.chapter-children { display: grid; gap: 8px; margin-top: 8px; }
|
.chapter-children { display: grid; gap: 8px; margin-top: 8px; }
|
||||||
.pick-bar {
|
.pick-bar {
|
||||||
|
|||||||
Reference in new issue
Block a user