diff --git a/frontend/src/pages/content.jsx b/frontend/src/pages/content.jsx index 54740b8..b221009 100644 --- a/frontend/src/pages/content.jsx +++ b/frontend/src/pages/content.jsx @@ -18,14 +18,13 @@ import { siblingChapterIds, } from "./chapters.js"; import { - AttachDialog, Chronology, DispatchDialog, EvidenceDialog, hostMark, restoreFold, scopeBody, - unitMarks, + StructureAssignDialog, UnitDetail, writeAssign, } 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 [open, setOpen] = useState(false); const known = directionWord(direction); @@ -467,11 +466,12 @@ export function DirectionControl({ direction = "", title, disabled = false, onCh anchorRef.current?.focus(); } return ( - + : null} {canSort && custom ? : null} - {canEdit && onAttach ? : null} + {canEdit && onAttach ? : null} {canEdit && onDispatch ? : null} - {canEdit && onEvidence ? : null} {canEdit ? : null} {canEdit && canDestroy ? : null} @@ -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 photo = symbol === "image" && Boolean(element.preview?.available); const [url, setUrl] = useState(""); @@ -887,6 +889,7 @@ function EntryMark({ element, context, assignable = false, onAssignStart, onAssi return ( new Set()); const [picking, setPicking] = useState(false); @@ -959,6 +961,7 @@ export function ContentBoard({ const dragRef = useRef(null); const carryRef = useRef(null); const releaseRef = useRef(null); + const placeUseRef = useRef(null); const rootRef = useRef(null); const savingDirection = useRef(false); const custom = record?.content_order === "position"; @@ -1093,34 +1096,46 @@ export function ContentBoard({ const node = rootRef.current; if (!node) return undefined; function place(event) { - if (carryRef.current) { + const carried = carryRef.current; + if (carried) { event.preventDefault(); + const useId = useDropId(event.target); + if (useId && useId !== carried.bindingId) setIndicator({ kind: "use", bindingId: useId }); + else setIndicator(null); return; } const drag = dragRef.current; if (!drag?.html5) return; event.preventDefault(); if (drag.kind === "chapter") { + drag.useBindingId = null; drag.index = chapterUnder(event.clientY, drag.parentId); setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter", parentId: drag.parentId || "" }); 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"); if (!sectionId) return; drag.targetSectionId = sectionId; drag.index = indexAt(sectionId, event.clientY); - setIndicator({ sectionId, index: drag.index }); + setIndicator({ sectionId, index: drag.index, kind: "order" }); } function drop(event) { const carried = carryRef.current; if (carried) { - if (event.target?.closest?.(".drop-well")) return; - if (carried.source === "attachment" || carried.source === "evidence") { - event.preventDefault(); - releaseRef.current?.(carried); - } + const useId = useDropId(event.target); + event.preventDefault(); 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; } if (!dragRef.current?.html5) return; @@ -1384,6 +1399,24 @@ export function ContentBoard({ dragRef.current = null; setDraggingId(""); 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.kind === "chapter") { const ids = siblingChapterIds(chapters, drag.chapterId); @@ -1434,13 +1467,23 @@ export function ContentBoard({ if (event.clientY < 72) window.scrollBy(0, -16); if (event.clientY > window.innerHeight - 72) window.scrollBy(0, 16); if (drag.kind === "chapter") { + drag.useBindingId = null; drag.index = chapterUnder(event.clientY, drag.parentId); setIndicator({ sectionId: drag.chapterId, index: drag.index, kind: "chapter", parentId: drag.parentId || "" }); 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.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) { @@ -1485,12 +1528,11 @@ export function ContentBoard({ function beginCarry(payload) { carryRef.current = payload; - setCarry(payload); } function endCarry() { carryRef.current = null; - setCarry(null); + setIndicator(null); } function bindingByElement(elementId) { @@ -1586,22 +1628,25 @@ export function ContentBoard({ } } - function dropReceipt(hostBinding, payload, dispatch) { - if (!payload || payload.elementId === hostBinding.element.id) return; - if (payload.source === "evidence" && dispatch && payload.dispatchId === dispatch.id) return; + function openPlace(hostBindingId, payload) { + const host = source.find((item) => item.id === hostBindingId); + 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 found = payload.source === "evidence" ? dispatchOf(payload.dispatchId) : null; setDialog({ - type: "evidence", + type: "place-use", + host, binding: item || { element: { id: payload.elementId, title: payload.title || "Unterlage", version: 1 } }, - hosts: [hostBinding], - dispatchId: dispatch ? dispatch.id : "", - replace: found && (!dispatch || found.dispatch.id !== dispatch.id) - ? { dispatchId: found.dispatch.id, version: found.dispatch.version } - : null, + payload, }); } + placeUseRef.current = openPlace; + function beginDrag(event, drag) { if (pending || (event.button != null && event.button !== 0)) return; event.preventDefault(); @@ -1666,7 +1711,7 @@ export function ContentBoard({ ) : (

Noch keine Unterlage und keine Notiz.

)} - setDialog(null)}> + setDialog(null)}> {dialog?.type === "bulk" && !dialog.host ? (
{ event.preventDefault(); @@ -1707,9 +1752,10 @@ export function ContentBoard({
) : null} {dialog?.type === "attach" && dialog.host ? ( - 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)} pending={pending} onClose={() => setDialog(null)} @@ -1728,24 +1774,44 @@ export function ContentBoard({ /> ) : null}
- setDialog(null)}> - {dialog?.type === "receipt-source" ? ( + setDialog(null)}> + {dialog?.type === "place-use" ? (
-

Unterlage aus diesem Vorgang als Beleg von {dialog.host.element.title}.

-
    - {source.filter((item) => item.element.id !== dialog.host.element.id).map((item) => ( -
  • - {item.element.title} - -
  • - ))} -
- {!source.filter((item) => item.element.id !== dialog.host.element.id).length ?

Keine weitere Unterlage.

: null} +

{dialog.payload.title || dialog.binding.element.title} an {dialog.host.element.title}

+ + +
) : null}
@@ -1871,7 +1937,7 @@ export function ContentBoard({ const sourceSymbol = contentSourceSymbol(element); const way = directionWord(binding.communication?.direction) || "Keine Angabe"; 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 originText = binding.origin && section.title && !binding.origin.includes(section.title) ? `${binding.origin}${binding.shared ? " · weitere Einbindung" : ""}` @@ -1881,6 +1947,7 @@ export function ContentBoard({ const rowClass = [ "preview-row", draggingId === binding.id ? "is-dragging" : "", + indicator?.kind === "use" && indicator.bindingId === binding.id ? "is-use-target" : "", selectedId === binding.id ? "is-selected" : "", picking && picked.has(binding.id) ? "is-picked" : "", picking ? "preview-row--picking" : "", @@ -1893,7 +1960,7 @@ export function ContentBoard({ } return (
  • - {indicator?.sectionId === section.id && indicator?.kind !== "chapter" && indicator.index === index ?
    : null} + {indicator?.kind === "order" && indicator?.sectionId === section.id && indicator.index === index ?
    : null} {picking ? (
  • ); })} - {indicator?.sectionId === section.id && indicator?.kind !== "chapter" && indicator.index === section.items.length ?
  • + +
  • + ); + } + + 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 ( +
  • +
    + + +
    + {expanded ? ( +
      + {(section.items || []).filter((item) => titleMatches(item, needle)).map((item) => renderRow(item, depth + 1))} + {(section.children || []).map((child) => renderSection(child, depth + 1))} +
    + ) : null} +
  • + ); + } + + const loose = tree.loose.filter((item) => titleMatches(item, needle)); + const roots = tree.roots.map((section) => renderSection(section, 0)).filter(Boolean); + return ( -
    -

    Anlagen von {host.element.title}. Bereits zugeordnete Anlagen stehen oben. Eine weitere Unterlage aus diesem Vorgang wird daraus genommen und nur noch hier gezeigt.

    -
    -

    Zugeordnet

    - {current.length ? ( -
      - {current.map((item, index) => ( -
    1. - {index + 1}. {item.title} - {formatDate(item.document_on)} - -
    2. - ))} -
    - ) :

    Noch keine Anlage an diesem Schriftstück.

    } -
    +
    +

    Zuordnen an {host.element.title}. Kapitel bleiben geschlossen, bis sie geöffnet werden.

    - {available.length ? ( -
      - {available.map((item) => ( -
    • - {item.element.title} - {formatDate(item.element.dates?.document_on)} - -
    • - ))} -
    - ) :

    Keine weitere passende Unterlage in diesem Vorgang.

    } + {step === "pick" ? ( + <> +
      + {roots} + {loose.length ? ( +
    • +
      + + +
      + {needle || opened.has("loose") ? ( +
        + {loose.map((item) => renderRow(item, 1))} +
      + ) : null} +
    • + ) : null} + {!roots.length && !loose.length ?
    • Nichts mit diesem Titel.
    • : null} +
    +
    + {selected.size} ausgewählt + {needle ? : null} + + + +
    + + ) : ( +
    +

    {selected.size} Belege. Dieselbe Rolle gilt für die Auswahl.

    + + {!dispatchId ? ( + <> + + + + + ) : null} + +
    + Darstellung in der Liste + + +
    + + +
    + )} {error ?

    {error}

    : null} -
    ); } @@ -425,42 +643,6 @@ export function ComparisonList({ comparisons = [], state, reason }) { ); } -function DropWell({ label, hint, armed, onDrop, onPick }) { - const [over, setOver] = useState(false); - return ( -
    { - 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); - }} - > - {over ? hint : label} - {onPick ? : null} -
    - ); -} - function chipDrag(enabled, payload, onCarryStart, onCarryEnd) { return { role: "button", @@ -482,153 +664,118 @@ export function UnitDetail({ canEdit, pending, scope, - carry, onOpen, onDetach, onDetachEvidence, onUnfold, onCarryStart, onCarryEnd, - onDropAttachment, - onDropReceipt, - onPickAttachments, - onPickReceipt, }) { const pack = binding.correspondence || {}; const attachments = pack.attachments || []; const dispatches = pack.dispatches || []; - const show = canEdit || attachments.length || dispatches.length || (pack.hosts || []).length; - if (!show) return null; - const armed = Boolean(carry && carry.elementId !== binding.element.id); - if (!attachments.length && !dispatches.length) { - if (!canEdit) return null; - return ( -
    - - onDropReceipt(payload, null)} onPick={() => onPickReceipt(null)} /> -
    - ); - } + const [open, setOpen] = useState(false); + if (!attachments.length && !dispatches.length) return null; + const summary = unitMarks(binding) || "Anlagen und Belege"; return ( -
    -
    -

    Anlagen

    - {canEdit ? ( - - ) : null} - {attachments.length ? ( -
      - {attachments.map((item, index) => ( -
    1. - - {index + 1}. {item.title} - {formatDate(item.document_on)} - {item.binding_id ? ( - - ) : null} - {canEdit ? ( - - ) : null} -
    2. - ))} -
    - ) : null} -
    - {dispatches.map((item) => ( -
    -

    - Versand {item.undated ? "undatiert" : formatDate(item.sent_on)} · {item.channel_label} - {item.counterpart ? ` · ${item.counterpart}` : " · Gegenüber unbekannt"} -

    -

    - {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} -

    - {canEdit ? ( - onDropReceipt(payload, item)} - onPick={() => onPickReceipt(item)} - /> +
    + + {open ? ( +
    + {attachments.length ? ( +
    +

    Anlagen

    +
      + {attachments.map((item, index) => ( +
    1. + {canEdit ? ( + + ) : null} + {index + 1}. {item.title} + {formatDate(item.document_on)} + {item.binding_id ? ( + + ) : null} + {canEdit ? ( + + ) : null} +
    2. + ))} +
    +
    ) : null} - {item.evidence?.length ? ( -
      - {item.evidence.map((proof) => ( -
    • - - - {formatDate(proof.document_on)} - {proof.source_state === "gap" ? Lücke: {proof.gap_reason} : null} - - {canEdit ? ( - - ) : null} - {canEdit && proof.listed_fold === "evidence" ? ( - - ) : null} -
    • - ))} -
    - ) : null} -
    - Gesicherte Fassung -
      - {item.items.map((part) => ( -
    1. - {part.role === "host" ? "Schreiben" : "Anlage"}: {part.title} - Dokumentdatum {formatDate(part.document_on)} - {part.source_state === "gap" ? Lücke: {part.gap_reason} : scope ? ( - Öffnen - ) : Gesichert} -
    2. - ))} -
    -
    -
    - ))} - {canEdit ? ( - onDropReceipt(payload, null)} - onPick={() => onPickReceipt(null)} - /> + {dispatches.map((item) => ( +
    +

    + Versand {item.undated ? "undatiert" : formatDate(item.sent_on)} · {item.channel_label} + {item.counterpart ? ` · ${item.counterpart}` : ""} +

    + {item.evidence?.length ? ( +
      + {item.evidence.map((proof) => ( +
    • + {canEdit ? ( + + ) : null} + + {formatDate(proof.document_on)} + {proof.source_state === "gap" ? Lücke: {proof.gap_reason} : null} + {canEdit ? ( + + ) : null} + {canEdit && proof.listed_fold === "evidence" ? ( + + ) : null} +
    • + ))} +
    + ) :

    Ohne Beleg

    } +
    + Gesicherte Fassung +
      + {item.items.map((part) => ( +
    1. + {part.role === "host" ? "Schreiben" : "Anlage"}: {part.title} + {formatDate(part.document_on)} + {part.source_state === "gap" ? Lücke: {part.gap_reason} : scope ? ( + Öffnen + ) : Gesichert} +
    2. + ))} +
    +
    +
    + ))} +
    ) : null}
    ); diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 744b9c5..115adec 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -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--scroll { max-height: 240px; overflow: 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--slim { gap: 4px; margin-top: 2px; } .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--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--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 .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__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; } .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; } .chapter-children { display: grid; gap: 8px; margin-top: 8px; } .pick-bar {