update attachment

Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2020-02-21 12:08:24 +01:00
committed by Julius Härtl
parent 1e3ff41cb2
commit 725f99d8b8
6 changed files with 95 additions and 10 deletions

View File

@@ -47,6 +47,10 @@ export default {
}
},
updateAttachment(state, { cardId, attachment }) {
Vue.set(state.attachments, cardId, attachment)
},
deleteAttachment(state, deletedAttachment) {
const existingIndex = state.attachments[deletedAttachment.cardId].findIndex(a => a.id === deletedAttachment.id)
if (existingIndex !== -1) {
@@ -67,6 +71,11 @@ export default {
commit('cardIncreaseAttachmentCount', cardId)
},
async updateAttachment({ commit }, { cardId, attachmentId, formData }) {
const attachment = await apiClient.updateAttachment({ cardId, attachmentId, formData })
commit('updateAttachment', { cardId, attachment })
},
async deleteAttachment({ commit }, attachment) {
await apiClient.deleteAttachment(attachment)
commit('deleteAttachment', attachment)