Fix initial dates on task edit sidebar

This commit is contained in:
kolaente 2020-02-09 17:33:04 +01:00
parent 301c23fa9a
commit 6258c59c18
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -199,6 +199,7 @@
watch: { watch: {
task() { task() {
this.taskEditTask = this.task this.taskEditTask = this.task
this.initTaskFields()
} }
}, },
created() { created() {
@ -206,13 +207,20 @@
this.taskService = new TaskService() this.taskService = new TaskService()
this.newTask = new TaskModel() this.newTask = new TaskModel()
this.taskEditTask = this.task this.taskEditTask = this.task
this.initTaskFields()
}, },
methods: { methods: {
initTaskFields() {
this.taskEditTask.dueDate = +new Date(this.task.dueDate) === 0 ? null : this.task.dueDate
this.taskEditTask.startDate = +new Date(this.task.startDate) === 0 ? null : this.task.startDate
this.taskEditTask.endDate = +new Date(this.task.endDate) === 0 ? null : this.task.endDate
},
editTaskSubmit() { editTaskSubmit() {
this.taskService.update(this.taskEditTask) this.taskService.update(this.taskEditTask)
.then(r => { .then(r => {
this.$set(this, 'taskEditTask', r) this.$set(this, 'taskEditTask', r)
this.success({message: 'The task was successfully updated.'}, this) this.success({message: 'The task was successfully updated.'}, this)
this.initTaskFields()
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e, this)