1
0

Make sure attachements are only added once to the list after uploading

+ Make sure the attachment list shows up every time after adding an attachment
This commit is contained in:
kolaente
2021-01-18 21:58:34 +01:00
parent a0664ecb29
commit 0b23e91f8d
4 changed files with 19 additions and 33 deletions

View File

@ -8,13 +8,20 @@ export default {
const attachmentService = new AttachmentService()
this.createAttachment(attachmentService, files, onSuccess)
},
createAttachment(attachmentService, files, onSuccess = () => {}) {
const attachmentModel = new AttachmentModel({taskId: this.taskId})
attachmentService.create(attachmentModel, files)
.then(r => {
if (r.success !== null) {
r.success.forEach(a => {
this.$store.commit('attachments/removeById', a.id)
this.$store.commit('attachments/add', a)
this.$store.dispatch('tasks/addTaskAttachment', {taskId: this.taskId, attachment: a})
this.$store.dispatch('tasks/addTaskAttachment', {
taskId: this.taskId,
attachment: a,
})
onSuccess(`${window.API_URL}/tasks/${this.taskId}/attachments/${a.id}`)
})
}