From 37d6ceb9634faa2c1116df22987d242ec3f5efa1 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 8 Feb 2020 18:37:23 +0100 Subject: [PATCH] Fix date handling on task detail page --- src/components/tasks/TaskDetailView.vue | 34 +++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/components/tasks/TaskDetailView.vue b/src/components/tasks/TaskDetailView.vue index 11b3b283..6bd01a3f 100644 --- a/src/components/tasks/TaskDetailView.vue +++ b/src/components/tasks/TaskDetailView.vue @@ -347,24 +347,31 @@ this.$set(this, 'task', r) this.setListAndNamespaceTitleFromParent() this.taskTitle = this.task.text - - // Set all active fields based on values in the model - this.activeFields.assignees = this.task.assignees.length > 0 - this.activeFields.priority = this.task.priority !== priorites.UNSET - this.activeFields.dueDate = this.task.dueDate !== null - this.activeFields.percentDone = this.task.percentDone > 0 - this.activeFields.startDate = this.task.startDate !== null - this.activeFields.endDate = this.task.endDate !== null - this.activeFields.reminders = this.task.reminderDates.length > 1 - this.activeFields.repeatAfter = this.task.repeatAfter.amount > 0 - this.activeFields.labels = this.task.labels.length > 0 - this.activeFields.attachments = this.task.attachments.length > 0 - this.activeFields.relatedTasks = Object.keys(this.task.related_tasks).length > 0 + this.setActiveFields() }) .catch(e => { this.error(e, this) }) }, + setActiveFields() { + + this.task.dueDate = +new Date(this.task.dueDate) === 0 ? null : this.task.dueDate + this.task.startDate = +new Date(this.task.startDate) === 0 ? null : this.task.startDate + this.task.endDate = +new Date(this.task.endDate) === 0 ? null : this.task.endDate + + // Set all active fields based on values in the model + this.activeFields.assignees = this.task.assignees.length > 0 + this.activeFields.priority = this.task.priority !== priorites.UNSET + this.activeFields.dueDate = this.task.dueDate !== null + this.activeFields.percentDone = this.task.percentDone > 0 + this.activeFields.startDate = this.task.startDate !== null + this.activeFields.endDate = this.task.endDate !== null + this.activeFields.reminders = this.task.reminderDates.length > 0 + this.activeFields.repeatAfter = this.task.repeatAfter.amount > 0 + this.activeFields.labels = this.task.labels.length > 0 + this.activeFields.attachments = this.task.attachments.length > 0 + this.activeFields.relatedTasks = Object.keys(this.task.related_tasks).length > 0 + }, saveTaskOnChange() { this.$refs.taskTitle.spellcheck = false @@ -386,6 +393,7 @@ .then(r => { this.$set(this, 'task', r) this.success({message: 'The task was saved successfully.'}, this) + this.setActiveFields() }) .catch(e => { this.error(e, this)