feat: hide completed tasks from previous days
Added 'updateTaskDisplay' method to hide tasks marked as done if their due date is before the current day. This helps declutter the task view by filtering out outdated completed tasks. The 'updateTaskDisplay' method is invoked during initialization and when tasks are loaded.
This commit is contained in:
parent
4586632c46
commit
2ad254e241
1 changed files with 27 additions and 4 deletions
|
@ -60,6 +60,7 @@ class Kanblendar {
|
|||
this.initDragAndDrop(); // Initialize drag and drop functionality
|
||||
this.requestNotificationPermission(); // Request permission for notifications
|
||||
this.highlightCurrentTimeSlot(); // Highlight the current time slot
|
||||
this.updateTaskDisplay(); // Hide tasks completed before today
|
||||
setInterval(() => this.highlightCurrentTimeSlot(), 60000); // Update highlight every minute
|
||||
}
|
||||
|
||||
|
@ -527,6 +528,7 @@ class Kanblendar {
|
|||
this.moveTaskToNonTimedSection(taskElement, column);
|
||||
}
|
||||
});
|
||||
this.updateTaskDisplay();
|
||||
this.adjustTimeSlotHeights();
|
||||
}
|
||||
|
||||
|
@ -539,4 +541,25 @@ class Kanblendar {
|
|||
});
|
||||
document.dispatchEvent(event);
|
||||
}
|
||||
|
||||
updateTaskDisplay() {
|
||||
const now = new Date();
|
||||
now.setHours(0, 0, 0, 0);
|
||||
|
||||
// Iterate over each task and check its column and due date
|
||||
this.tasks.forEach((task, taskId) => {
|
||||
const taskElement = document.getElementById(taskId);
|
||||
|
||||
// Parse the task's due time
|
||||
const taskDueDate = task.dueTime ? new Date(task.dueTime) : null;
|
||||
|
||||
if (task.column === 'done' && taskDueDate && taskDueDate < now) {
|
||||
// Hide tasks that are done and before today's date
|
||||
taskElement.style.display = 'none';
|
||||
} else {
|
||||
// Show all other tasks
|
||||
taskElement.style.display = 'block';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue