refactor(web): extract allocation drag action plans
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user