feat: use async / await where it makes sense
This commit is contained in:
parent
a776e1d2f3
commit
bb94c1ba3a
74 changed files with 1458 additions and 1662 deletions
|
|
@ -561,23 +561,22 @@ export default {
|
|||
return uploadFile(this.taskId, ...args)
|
||||
},
|
||||
|
||||
loadTask(taskId) {
|
||||
async loadTask(taskId) {
|
||||
if (taskId === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
this.taskService.get({id: taskId})
|
||||
.then(r => {
|
||||
this.task = r
|
||||
this.$store.commit('attachments/set', r.attachments)
|
||||
this.taskColor = this.task.hexColor
|
||||
this.setActiveFields()
|
||||
this.setTitle(this.task.title)
|
||||
})
|
||||
.finally(() => {
|
||||
this.$nextTick(() => this.visible = true)
|
||||
this.scrollToHeading()
|
||||
})
|
||||
try {
|
||||
this.task = await this.taskService.get({id: taskId})
|
||||
this.$store.commit('attachments/set', this.task.attachments)
|
||||
this.taskColor = this.task.hexColor
|
||||
this.setActiveFields()
|
||||
this.setTitle(this.task.title)
|
||||
} finally {
|
||||
this.scrollToHeading()
|
||||
await this.$nextTick()
|
||||
this.visible = true
|
||||
}
|
||||
},
|
||||
scrollToHeading() {
|
||||
this.$refs.heading.$el.scrollIntoView({block: 'center'})
|
||||
|
|
@ -633,6 +632,7 @@ export default {
|
|||
}
|
||||
this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions)
|
||||
},
|
||||
|
||||
setFieldActive(fieldName) {
|
||||
this.activeFields[fieldName] = true
|
||||
this.$nextTick(() => {
|
||||
|
|
@ -651,13 +651,13 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
deleteTask() {
|
||||
this.$store.dispatch('tasks/delete', this.task)
|
||||
.then(() => {
|
||||
this.$message.success({message: this.$t('task.detail.deleteSuccess')})
|
||||
this.$router.push({name: 'list.index', params: {listId: this.task.listId}})
|
||||
})
|
||||
|
||||
async deleteTask() {
|
||||
await this.$store.dispatch('tasks/delete', this.task)
|
||||
this.$message.success({message: this.$t('task.detail.deleteSuccess')})
|
||||
this.$router.push({name: 'list.index', params: {listId: this.task.listId}})
|
||||
},
|
||||
|
||||
toggleTaskDone() {
|
||||
this.task.done = !this.task.done
|
||||
|
||||
|
|
@ -665,36 +665,26 @@ export default {
|
|||
playPop()
|
||||
}
|
||||
|
||||
this.saveTask(true, () => this.toggleTaskDone())
|
||||
this.saveTask(true, this.toggleTaskDone)
|
||||
},
|
||||
|
||||
setDescriptionChanged(e) {
|
||||
if (e.key === 'Enter' || e.key === 'Control') {
|
||||
return
|
||||
}
|
||||
this.descriptionChanged = true
|
||||
},
|
||||
saveTaskIfDescriptionChanged() {
|
||||
// We want to only save the description if it was changed.
|
||||
// Since we can either trigger this with ctrl+enter or @change, it would be possible to save a task first
|
||||
// with ctrl+enter and then with @change although nothing changed since the last save when @change gets fired.
|
||||
// To only save one time we added this method.
|
||||
if (this.descriptionChanged) {
|
||||
this.descriptionChanged = false
|
||||
this.saveTask()
|
||||
}
|
||||
},
|
||||
|
||||
async changeList(list) {
|
||||
this.$store.commit('kanban/removeTaskInBucket', this.task)
|
||||
this.task.listId = list.id
|
||||
await this.saveTask()
|
||||
},
|
||||
toggleFavorite() {
|
||||
|
||||
async toggleFavorite() {
|
||||
this.task.isFavorite = !this.task.isFavorite
|
||||
this.taskService.update(this.task)
|
||||
.then(t => {
|
||||
this.task = t
|
||||
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
|
||||
})
|
||||
this.task = await this.taskService.update(this.task)
|
||||
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue