Fix date handling on task detail page

This commit is contained in:
kolaente 2020-02-08 18:37:23 +01:00
parent 04d7d48b68
commit 37d6ceb963
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -347,6 +347,17 @@
this.$set(this, 'task', r) this.$set(this, 'task', r)
this.setListAndNamespaceTitleFromParent() this.setListAndNamespaceTitleFromParent()
this.taskTitle = this.task.text this.taskTitle = this.task.text
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 // Set all active fields based on values in the model
this.activeFields.assignees = this.task.assignees.length > 0 this.activeFields.assignees = this.task.assignees.length > 0
@ -355,15 +366,11 @@
this.activeFields.percentDone = this.task.percentDone > 0 this.activeFields.percentDone = this.task.percentDone > 0
this.activeFields.startDate = this.task.startDate !== null this.activeFields.startDate = this.task.startDate !== null
this.activeFields.endDate = this.task.endDate !== null this.activeFields.endDate = this.task.endDate !== null
this.activeFields.reminders = this.task.reminderDates.length > 1 this.activeFields.reminders = this.task.reminderDates.length > 0
this.activeFields.repeatAfter = this.task.repeatAfter.amount > 0 this.activeFields.repeatAfter = this.task.repeatAfter.amount > 0
this.activeFields.labels = this.task.labels.length > 0 this.activeFields.labels = this.task.labels.length > 0
this.activeFields.attachments = this.task.attachments.length > 0 this.activeFields.attachments = this.task.attachments.length > 0
this.activeFields.relatedTasks = Object.keys(this.task.related_tasks).length > 0 this.activeFields.relatedTasks = Object.keys(this.task.related_tasks).length > 0
})
.catch(e => {
this.error(e, this)
})
}, },
saveTaskOnChange() { saveTaskOnChange() {
this.$refs.taskTitle.spellcheck = false this.$refs.taskTitle.spellcheck = false
@ -386,6 +393,7 @@
.then(r => { .then(r => {
this.$set(this, 'task', r) this.$set(this, 'task', r)
this.success({message: 'The task was saved successfully.'}, this) this.success({message: 'The task was saved successfully.'}, this)
this.setActiveFields()
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e, this)