fix: ensure task due time updates correctly on drop

Refactored time slot handling to avoid updating task due time when startTime is not valid. This prevents potential misalignment of task due times when tasks are dropped outside of defined slots. Also added missing dueTime update in the tasks map for synchronization. Adjustments ensure more consistent task scheduling and improved user interaction.
This commit is contained in:
Kumi 2024-07-31 10:57:51 +02:00
parent 44885d3801
commit 2b5dbada07
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -255,17 +255,25 @@ class Kanblendar {
// Update the task's due time if dropped in a time slot and the current due time is not valid for that slot // Update the task's due time if dropped in a time slot and the current due time is not valid for that slot
if (dropTarget.classList.contains('kanblendar-time-slot')) { if (dropTarget.classList.contains('kanblendar-time-slot')) {
const startTime = dropTarget.dataset.startTime; const startTime = dropTarget.dataset.startTime;
const dueTime = new Date(task.dataset.dueTime);
const slotStartTime = new Date(`${this.config.currentDate}T${startTime}:00`); const slotStartTime = new Date(`${this.config.currentDate}T${startTime}:00`);
const slotEndTime = this.addMinutes(slotStartTime, this.config.interval); const slotEndTime = this.addMinutes(slotStartTime, this.config.interval);
if (startTime) {
const dueTime = new Date(task.dataset.dueTime);
if (!(dueTime >= slotStartTime && dueTime <= slotEndTime)) { if (!(dueTime >= slotStartTime && dueTime <= slotEndTime)) {
task.dataset.dueTime = slotStartTime.toISOString(); task.dataset.dueTime = slotStartTime.toISOString();
} }
} else {
task.dataset.dueTime = slotStartTime.toISOString();
}
} }
// Update the task's column in the tasks map
// Update the task in the tasks map
this.tasks.get(task.id).column = dropTarget.id.replace('-tasks', ''); this.tasks.get(task.id).column = dropTarget.id.replace('-tasks', '');
this.tasks.get(task.id).dueTime = task.dataset.dueTime;
this.adjustTimeSlotHeights(); // Adjust heights after dropping a task this.adjustTimeSlotHeights(); // Adjust heights after dropping a task
} }