Fix attachments being added mutliple times
This commit is contained in:
parent
c5da0fcba4
commit
23552b2b1b
2 changed files with 4 additions and 1 deletions
|
@ -14,10 +14,10 @@ export default {
|
||||||
const attachmentModel = new AttachmentModel({taskId: this.taskId})
|
const attachmentModel = new AttachmentModel({taskId: this.taskId})
|
||||||
attachmentService.create(attachmentModel, files)
|
attachmentService.create(attachmentModel, files)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
|
console.debug(`Uploaded attachments for task ${this.taskId}, response was`, r)
|
||||||
if (r.success !== null) {
|
if (r.success !== null) {
|
||||||
r.success.forEach(a => {
|
r.success.forEach(a => {
|
||||||
this.$store.commit('attachments/removeById', a.id)
|
this.$store.commit('attachments/removeById', a.id)
|
||||||
this.$store.commit('attachments/add', a)
|
|
||||||
this.$store.dispatch('tasks/addTaskAttachment', {
|
this.$store.dispatch('tasks/addTaskAttachment', {
|
||||||
taskId: this.taskId,
|
taskId: this.taskId,
|
||||||
attachment: a,
|
attachment: a,
|
||||||
|
|
|
@ -7,15 +7,18 @@ export default {
|
||||||
}),
|
}),
|
||||||
mutations: {
|
mutations: {
|
||||||
set(state, attachments) {
|
set(state, attachments) {
|
||||||
|
console.debug('Set attachments', attachments)
|
||||||
Vue.set(state, 'attachments', attachments)
|
Vue.set(state, 'attachments', attachments)
|
||||||
},
|
},
|
||||||
add(state, attachment) {
|
add(state, attachment) {
|
||||||
|
console.debug('Add attachement', attachment)
|
||||||
state.attachments.push(attachment)
|
state.attachments.push(attachment)
|
||||||
},
|
},
|
||||||
removeById(state, id) {
|
removeById(state, id) {
|
||||||
for (const a in state.attachments) {
|
for (const a in state.attachments) {
|
||||||
if (state.attachments[a].id === id) {
|
if (state.attachments[a].id === id) {
|
||||||
state.attachments.splice(a, 1)
|
state.attachments.splice(a, 1)
|
||||||
|
console.debug('Remove attachement', id)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue