From 2e66e83c9c4b00b407230adcb1365a4414229047 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 30 Jan 2022 12:01:37 +0100 Subject: [PATCH] fix: sort tasks correctly by due date --- src/views/tasks/ShowTasks.vue | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/views/tasks/ShowTasks.vue b/src/views/tasks/ShowTasks.vue index 9b6638af9..095a5755a 100644 --- a/src/views/tasks/ShowTasks.vue +++ b/src/views/tasks/ShowTasks.vue @@ -119,12 +119,22 @@ export default { // soonest before the later ones. // We can't use the api sorting here because that sorts tasks with a due date after // ones without a due date. - return [...this.tasks].sort((a, b) => { - const sortByDueDate = b.dueDate - a.dueDate - return sortByDueDate === 0 - ? b.id - a.id - : sortByDueDate - }) + + const tasksWithDueDate = [...this.tasks] + .filter(t => t.dueDate !== null) + .sort((a, b) => { + const sortByDueDate = a.dueDate - b.dueDate + return sortByDueDate === 0 + ? b.id - a.id + : sortByDueDate + }) + const tasksWithoutDueDate = [...this.tasks] + .filter(t => t.dueDate === null) + + return [ + ...tasksWithDueDate, + ...tasksWithoutDueDate, + ] }, hasTasks() { return this.tasks && this.tasks.length > 0