mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-03-11 17:48:44 -05:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user