refactor(web): extract allocation drag action plans

This commit is contained in:
2026-04-01 10:15:54 +02:00
parent 203bb8751d
commit c941b1e5cf
7 changed files with 246 additions and 40 deletions
+21 -14
View File
@@ -14,9 +14,9 @@ import {
import {
buildAllocationMovedSnapshot,
hasAllocationDateChange,
requiresAllocationFragmentExtraction,
shouldTreatAllocationDragAsClick,
} from "./timelineAllocationFinalize.js";
import { buildAllocationBlockClickInfo, buildAllocationMutationPlan } from "./timelineAllocationActions.js";
import {
finalizeAllocationMultiDrag,
isAllocationMultiSelected,
@@ -729,22 +729,29 @@ export function useTimelineDrag({
onShiftClickAllocRef.current?.(alloc.allocationId);
} else {
// Normal click → open alloc popover
onBlockClickRef.current?.({
allocationId: alloc.allocationId,
projectId: alloc.projectId ?? "",
projectName: alloc.projectName ?? "",
startDate: alloc.originalStartDate!,
endDate: alloc.originalEndDate!,
});
const clickInfo = buildAllocationBlockClickInfo(alloc);
if (clickInfo) {
onBlockClickRef.current?.(clickInfo);
}
}
} else if (hasDateChange && alloc.allocationId && alloc.currentStartDate && alloc.currentEndDate) {
const activeAllocationId = alloc.allocationId;
const currentStartDate = alloc.currentStartDate;
const currentEndDate = alloc.currentEndDate;
const baseMutationAllocationId = alloc.mutationAllocationId ?? activeAllocationId;
const requiresExtraction = requiresAllocationFragmentExtraction(alloc);
const mutationPlan = buildAllocationMutationPlan(alloc);
if (!mutationPlan) {
allocDragRef.current = INITIAL_ALLOC_DRAG;
setAllocDragState(INITIAL_ALLOC_DRAG);
return;
}
pendingSnapshotRef.current = buildAllocationMovedSnapshot(alloc);
const {
activeAllocationId,
currentStartDate,
currentEndDate,
baseMutationAllocationId,
requiresExtraction,
pendingSnapshot,
} = mutationPlan;
pendingSnapshotRef.current = pendingSnapshot;
pendingOptimisticAllocationIdRef.current = activeAllocationId;
setOptimisticAllocations((prev) => {
const next = new Map(prev);