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:
@ -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}`)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user