Starte Zuordnen am Griff statt am Titel und erlaube dort auch Sortieren in eigener Reihenfolge.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a5350bc76e
commit
5b23e4aab0
1 file changed
+39
-47
@@ -958,7 +958,6 @@ export function ContentBoard({
|
|||||||
const [pickTarget, setPickTarget] = useState("");
|
const [pickTarget, setPickTarget] = useState("");
|
||||||
const dragRef = useRef(null);
|
const dragRef = useRef(null);
|
||||||
const carryRef = useRef(null);
|
const carryRef = useRef(null);
|
||||||
const armListCarryRef = useRef(null);
|
|
||||||
const releaseRef = useRef(null);
|
const releaseRef = useRef(null);
|
||||||
const placeUseRef = useRef(null);
|
const placeUseRef = useRef(null);
|
||||||
const rootRef = useRef(null);
|
const rootRef = useRef(null);
|
||||||
@@ -1201,21 +1200,14 @@ export function ContentBoard({
|
|||||||
if (target.closest("button, input, textarea, select, label, .direction-column, .preview-row__actions, .handle, .row-menu")) return null;
|
if (target.closest("button, input, textarea, select, label, .direction-column, .preview-row__actions, .handle, .row-menu")) return null;
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
function onPointerDownCapture(event) {
|
|
||||||
if (!rowTarget(event)) return;
|
|
||||||
armListCarryRef.current?.(event);
|
|
||||||
}
|
|
||||||
function blockRowMouseDown(event) {
|
function blockRowMouseDown(event) {
|
||||||
if (event.button !== 0 || !rowTarget(event)) return;
|
if (event.button !== 0 || !rowTarget(event)) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!carryRef.current) armListCarryRef.current?.(event);
|
|
||||||
}
|
}
|
||||||
node.addEventListener("pointerdown", onPointerDownCapture, true);
|
|
||||||
node.addEventListener("mousedown", blockRowMouseDown, true);
|
node.addEventListener("mousedown", blockRowMouseDown, true);
|
||||||
node.addEventListener("dragover", place);
|
node.addEventListener("dragover", place);
|
||||||
node.addEventListener("drop", drop);
|
node.addEventListener("drop", drop);
|
||||||
return () => {
|
return () => {
|
||||||
node.removeEventListener("pointerdown", onPointerDownCapture, true);
|
|
||||||
node.removeEventListener("mousedown", blockRowMouseDown, true);
|
node.removeEventListener("mousedown", blockRowMouseDown, true);
|
||||||
node.removeEventListener("dragover", place);
|
node.removeEventListener("dragover", place);
|
||||||
node.removeEventListener("drop", drop);
|
node.removeEventListener("drop", drop);
|
||||||
@@ -1601,7 +1593,7 @@ export function ContentBoard({
|
|||||||
function beginCarryPointer(event, payload) {
|
function beginCarryPointer(event, payload) {
|
||||||
if (carryRef.current || pending || (event.button != null && event.button !== 0)) return;
|
if (carryRef.current || pending || (event.button != null && event.button !== 0)) return;
|
||||||
const target = event.target?.nodeType === 1 ? event.target : event.target?.parentElement;
|
const target = event.target?.nodeType === 1 ? event.target : event.target?.parentElement;
|
||||||
if (!target?.closest || target.closest("button, input, textarea, select, label")) return;
|
if (!target?.closest || target.closest("button:not(.handle), input, textarea, select, label")) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const opener = target.closest("a.preview-row__title, a.preview-row__text, .use-chip__title");
|
const opener = target.closest("a.preview-row__title, a.preview-row__text, .use-chip__title");
|
||||||
@@ -1712,6 +1704,7 @@ export function ContentBoard({
|
|||||||
carried.release = false;
|
carried.release = false;
|
||||||
carried.place = false;
|
carried.place = false;
|
||||||
carried.chapterId = "";
|
carried.chapterId = "";
|
||||||
|
carried.reorderTarget = null;
|
||||||
paintAssignTarget(found.useId);
|
paintAssignTarget(found.useId);
|
||||||
setIndicator({ kind: "use", bindingId: found.useId });
|
setIndicator({ kind: "use", bindingId: found.useId });
|
||||||
return;
|
return;
|
||||||
@@ -1736,6 +1729,14 @@ export function ContentBoard({
|
|||||||
carried.place = false;
|
carried.place = false;
|
||||||
carried.chapterId = "";
|
carried.chapterId = "";
|
||||||
paintAssignTarget("");
|
paintAssignTarget("");
|
||||||
|
if (carried.reorder) {
|
||||||
|
const sectionId = sectionUnder(y) || carried.reorder.sectionId;
|
||||||
|
const index = indexAt(sectionId, y);
|
||||||
|
carried.reorderTarget = { sectionId, index };
|
||||||
|
setIndicator({ sectionId, index, kind: "order" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
carried.reorderTarget = null;
|
||||||
setIndicator(null);
|
setIndicator(null);
|
||||||
}
|
}
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
@@ -1813,6 +1814,16 @@ export function ContentBoard({
|
|||||||
placeUseRef.current?.(useId, carried);
|
placeUseRef.current?.(useId, carried);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (carried.reorder && carried.reorderTarget?.index != null) {
|
||||||
|
finishDrag({
|
||||||
|
bindingId: carried.reorder.bindingId,
|
||||||
|
sectionId: carried.reorder.sectionId,
|
||||||
|
targetSectionId: carried.reorderTarget.sectionId,
|
||||||
|
index: carried.reorderTarget.index,
|
||||||
|
moved: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (release && (carried.source === "attachment" || carried.source === "evidence")) {
|
if (release && (carried.source === "attachment" || carried.source === "evidence")) {
|
||||||
releaseRef.current?.({ ...carried, place: carried.place, chapterId: carried.chapterId });
|
releaseRef.current?.({ ...carried, place: carried.place, chapterId: carried.chapterId });
|
||||||
}
|
}
|
||||||
@@ -1844,22 +1855,6 @@ export function ContentBoard({
|
|||||||
window.addEventListener("mouseup", onMouseUp, true);
|
window.addEventListener("mouseup", onMouseUp, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
armListCarryRef.current = (event) => {
|
|
||||||
if (carryRef.current || !canEdit || pending || picking) return;
|
|
||||||
const target = event.target?.nodeType === 1 ? event.target : event.target?.parentElement;
|
|
||||||
const row = target?.closest?.("li.preview-row");
|
|
||||||
if (!row) return;
|
|
||||||
if (target.closest(".use-chip, .unit-detail")) return;
|
|
||||||
const binding = source.find((item) => item.id === row.getAttribute("data-binding"));
|
|
||||||
if (!binding?.element) return;
|
|
||||||
beginCarryPointer(event, {
|
|
||||||
source: "list",
|
|
||||||
elementId: binding.element.id,
|
|
||||||
bindingId: binding.id,
|
|
||||||
title: binding.element.title,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function bindingByElement(elementId) {
|
function bindingByElement(elementId) {
|
||||||
return source.find((item) => item.element?.id === elementId) || null;
|
return source.find((item) => item.element?.id === elementId) || null;
|
||||||
}
|
}
|
||||||
@@ -2332,7 +2327,7 @@ export function ContentBoard({
|
|||||||
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" : "",
|
||||||
canSort && custom ? "preview-row--ordered" : "",
|
(canEdit || (canSort && custom)) ? "preview-row--ordered" : "",
|
||||||
].filter(Boolean).join(" ");
|
].filter(Boolean).join(" ");
|
||||||
function openFromList(event) {
|
function openFromList(event) {
|
||||||
const row = event.currentTarget.closest(".preview-row");
|
const row = event.currentTarget.closest(".preview-row");
|
||||||
@@ -2350,16 +2345,6 @@ export function ContentBoard({
|
|||||||
key={binding.id}
|
key={binding.id}
|
||||||
data-binding={binding.id}
|
data-binding={binding.id}
|
||||||
className={rowClass}
|
className={rowClass}
|
||||||
onPointerDown={(event) => {
|
|
||||||
if (!canEdit || pending || picking || event.button !== 0) return;
|
|
||||||
if (event.target.closest("button, input, textarea, select, label, .use-chip, .unit-detail, .entry-mark")) return;
|
|
||||||
beginCarryPointer(event, {
|
|
||||||
source: "list",
|
|
||||||
elementId: element.id,
|
|
||||||
bindingId: binding.id,
|
|
||||||
title: element.title,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{indicator?.kind === "order" && indicator?.sectionId === section.id && 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 ? (
|
||||||
@@ -2387,16 +2372,30 @@ export function ContentBoard({
|
|||||||
) : (
|
) : (
|
||||||
<DirectionColumn direction={binding.communication?.direction} />
|
<DirectionColumn direction={binding.communication?.direction} />
|
||||||
)}
|
)}
|
||||||
{canSort && custom ? (
|
{canEdit || (canSort && custom) ? (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="handle"
|
className="handle"
|
||||||
aria-label={`${element.title} ziehen`}
|
aria-label={canEdit && canSort && custom
|
||||||
|
? `${element.title} ziehen, zuordnen oder sortieren`
|
||||||
|
: canEdit
|
||||||
|
? `${element.title} zuordnen`
|
||||||
|
: `${element.title} ziehen`}
|
||||||
draggable={false}
|
draggable={false}
|
||||||
disabled={pending}
|
disabled={pending || picking}
|
||||||
onPointerDown={(event) => {
|
onPointerDown={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
beginDrag(event, { bindingId: binding.id, sectionId: section.id });
|
if (!canEdit || picking) {
|
||||||
|
if (canSort && custom) beginDrag(event, { bindingId: binding.id, sectionId: section.id });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
beginCarryPointer(event, {
|
||||||
|
source: "list",
|
||||||
|
elementId: element.id,
|
||||||
|
bindingId: binding.id,
|
||||||
|
title: element.title,
|
||||||
|
reorder: canSort && custom ? { bindingId: binding.id, sectionId: section.id } : null,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className="handle__grip" aria-hidden="true" />
|
<span className="handle__grip" aria-hidden="true" />
|
||||||
@@ -2405,15 +2404,8 @@ export function ContentBoard({
|
|||||||
<EntryMark
|
<EntryMark
|
||||||
element={element}
|
element={element}
|
||||||
context={context}
|
context={context}
|
||||||
assignable={canEdit && !pending && !picking}
|
|
||||||
dropId={assignDropId}
|
dropId={assignDropId}
|
||||||
hot={indicator?.kind === "use" && indicator.bindingId === binding.id}
|
hot={indicator?.kind === "use" && indicator.bindingId === binding.id}
|
||||||
onAssignStart={(event) => beginCarryPointer(event, {
|
|
||||||
source: "list",
|
|
||||||
elementId: element.id,
|
|
||||||
bindingId: binding.id,
|
|
||||||
title: element.title,
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
<UnitDetail
|
<UnitDetail
|
||||||
binding={binding}
|
binding={binding}
|
||||||
|
|||||||
Reference in new issue
Block a user