fix: handle tasks without due times appropriately
Ensures tasks without due times are moved to a non-timed section rather than attempting to update their location based on an undefined value. This change prevents errors related to missing due time values and improves overall task management experience.
This commit is contained in:
parent
83471f8820
commit
cc4989cac4
1 changed files with 19 additions and 4 deletions
|
@ -295,7 +295,7 @@ class Kanblendar {
|
|||
event.preventDefault();
|
||||
const title = document.getElementById('kanblendar-taskTitle').value;
|
||||
const description = document.getElementById('kanblendar-taskDescription').value;
|
||||
const dueTime = document.getElementById('kanblendar-taskDueTime').value;
|
||||
const dueTime = document.getElementById('kanblendar-taskDueTime').value || null;
|
||||
const column = document.getElementById('kanblendar-taskColumn').value;
|
||||
const notifyBefore = parseInt(document.getElementById('kanblendar-taskNotify').value, 10);
|
||||
|
||||
|
@ -308,12 +308,20 @@ class Kanblendar {
|
|||
this.currentTask.dataset.column = column;
|
||||
this.currentTask.dataset.notifyBefore = notifyBefore;
|
||||
this.moveTaskToColumn(this.currentTask, column);
|
||||
this.updateTaskLocation(this.currentTask, dueTime);
|
||||
if (dueTime) {
|
||||
this.updateTaskLocation(this.currentTask, dueTime);
|
||||
} else {
|
||||
this.moveTaskToNonTimedSection(this.currentTask, column);
|
||||
}
|
||||
this.cancelNotification(this.currentTask.id);
|
||||
} else {
|
||||
newTask = this.createTaskElement(title, description, dueTime, column, notifyBefore);
|
||||
this.moveTaskToColumn(newTask, column); // Correctly move to the selected column
|
||||
this.updateTaskLocation(newTask, dueTime);
|
||||
this.moveTaskToColumn(newTask, column);
|
||||
if (dueTime) {
|
||||
this.updateTaskLocation(newTask, dueTime);
|
||||
} else {
|
||||
this.moveTaskToNonTimedSection(newTask, column);
|
||||
}
|
||||
}
|
||||
|
||||
if (dueTime && notifyBefore >= 0) {
|
||||
|
@ -324,6 +332,13 @@ class Kanblendar {
|
|||
this.closeModalFunc();
|
||||
}
|
||||
|
||||
moveTaskToNonTimedSection(task, column) {
|
||||
const columnTasks = document.getElementById(`${column}-tasks`);
|
||||
if (columnTasks) {
|
||||
columnTasks.appendChild(task);
|
||||
}
|
||||
}
|
||||
|
||||
createTaskElement(title, description, dueTime, column, notifyBefore) {
|
||||
const id = `task-${Date.now()}`;
|
||||
const newTask = document.createElement('div');
|
||||
|
|
Loading…
Reference in a new issue