refactor(web): extract project drag helpers
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
startAllocationMultiDrag,
|
||||
updateAllocationMultiDrag,
|
||||
} from "./timelineAllocationMultiDrag.js";
|
||||
import { buildProjectShiftMutationInput, createProjectDragState } from "./timelineProjectDrag.js";
|
||||
import {
|
||||
createMultiSelectState,
|
||||
finalizeMultiSelectDraft,
|
||||
@@ -448,17 +449,7 @@ export function useTimelineDrag({
|
||||
const finalDrag = dragStateRef.current;
|
||||
if (!finalDrag.isDragging) return null;
|
||||
|
||||
const mutationInput =
|
||||
finalDrag.daysDelta !== 0 &&
|
||||
finalDrag.projectId &&
|
||||
finalDrag.currentStartDate &&
|
||||
finalDrag.currentEndDate
|
||||
? {
|
||||
projectId: finalDrag.projectId,
|
||||
newStartDate: finalDrag.currentStartDate,
|
||||
newEndDate: finalDrag.currentEndDate,
|
||||
}
|
||||
: null;
|
||||
const mutationInput = buildProjectShiftMutationInput(finalDrag);
|
||||
|
||||
if (finalDrag.daysDelta !== 0) {
|
||||
preserveLivePreview(projectPreviewRef.current);
|
||||
@@ -543,21 +534,13 @@ export function useTimelineDrag({
|
||||
if (e.button !== 0) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const state: DragState = {
|
||||
isDragging: true,
|
||||
const state = createProjectDragState<DragState>({
|
||||
projectId: opts.projectId,
|
||||
projectName: opts.projectName,
|
||||
allocationId: null,
|
||||
originalStartDate: opts.startDate,
|
||||
originalEndDate: opts.endDate,
|
||||
currentStartDate: opts.startDate,
|
||||
currentEndDate: opts.endDate,
|
||||
startDate: opts.startDate,
|
||||
endDate: opts.endDate,
|
||||
startMouseX: e.clientX,
|
||||
pointerDeltaX: 0,
|
||||
originalLeft: 0,
|
||||
blockWidth: 0,
|
||||
daysDelta: 0,
|
||||
};
|
||||
});
|
||||
dragStateRef.current = state;
|
||||
setDragState(state);
|
||||
|
||||
@@ -602,21 +585,16 @@ export function useTimelineDrag({
|
||||
if (e.button !== 0) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const state: DragState = {
|
||||
isDragging: true,
|
||||
const state = createProjectDragState<DragState>({
|
||||
projectId: opts.projectId,
|
||||
projectName: opts.projectName,
|
||||
allocationId: opts.allocationId ?? null,
|
||||
originalStartDate: opts.startDate,
|
||||
originalEndDate: opts.endDate,
|
||||
currentStartDate: opts.startDate,
|
||||
currentEndDate: opts.endDate,
|
||||
startDate: opts.startDate,
|
||||
endDate: opts.endDate,
|
||||
startMouseX: e.clientX,
|
||||
pointerDeltaX: 0,
|
||||
originalLeft: opts.blockLeft,
|
||||
blockWidth: opts.blockWidth,
|
||||
daysDelta: 0,
|
||||
};
|
||||
});
|
||||
dragStateRef.current = state;
|
||||
setDragState(state);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user