fix(gantt): only persist dates that actually exist on partial-date tasks

Previously drag/resize always set both startDate and endDate, which
would persist the synthetic 7-day span and convert an open-ended task
into a fully-dated one. Now only the date fields that originally exist
on the task are updated.
This commit is contained in:
kolaente
2026-02-18 22:39:37 +01:00
parent ceb62c63d3
commit 362962e81e

View File

@@ -260,13 +260,33 @@ function updateGanttTask(id: string, newStart: Date, newEnd: Date) {
id: Number(id),
}
// Always set the dates that were dragged/resized
update.startDate = roundToNaturalDayBoundary(newStart, true)
update.endDate = roundToNaturalDayBoundary(newEnd)
const hasStartDate = Boolean(task.startDate)
const hasEndDate = Boolean(task.endDate)
const hasDueDate = Boolean(task.dueDate)
// If the task originally only had dueDate (no endDate), also update dueDate
if (!task.endDate && task.dueDate) {
if (hasStartDate && hasEndDate) {
// Both dates exist — update both
update.startDate = roundToNaturalDayBoundary(newStart, true)
update.endDate = roundToNaturalDayBoundary(newEnd)
} else if (hasStartDate && !hasEndDate && hasDueDate) {
// startDate + dueDate (no endDate) — treat as fully dated
update.startDate = roundToNaturalDayBoundary(newStart, true)
update.dueDate = roundToNaturalDayBoundary(newEnd)
} else if (hasStartDate && !hasEndDate) {
// startOnly — only update startDate, don't persist the synthetic end
update.startDate = roundToNaturalDayBoundary(newStart, true)
} else if (!hasStartDate && (hasEndDate || hasDueDate)) {
// endOnly / dueOnly — only update the end side
if (hasEndDate) {
update.endDate = roundToNaturalDayBoundary(newEnd)
}
if (hasDueDate) {
update.dueDate = roundToNaturalDayBoundary(newEnd)
}
} else {
// No dates at all — update both (existing behavior for dateless tasks)
update.startDate = roundToNaturalDayBoundary(newStart, true)
update.endDate = roundToNaturalDayBoundary(newEnd)
}
emit('update:task', update)