frontend/src/store/modules/attachments.js
dpschen 0376ef53e3 fix: remove attachment by id (#725)
Co-authored-by: Dominik Pschenitschni <mail@celement.de>
Reviewed-on: vikunja/frontend#725
Co-authored-by: dpschen <dpschen@noreply.kolaente.de>
Co-committed-by: dpschen <dpschen@noreply.kolaente.de>
2021-09-10 12:50:41 +00:00

25 lines
597 B
JavaScript

import Vue from 'vue'
import {findIndexById} from '@/helpers/find'
export default {
namespaced: true,
state: () => ({
attachments: [],
}),
mutations: {
set(state, attachments) {
console.debug('Set attachments', attachments)
Vue.set(state, 'attachments', attachments)
},
add(state, attachment) {
console.debug('Add attachement', attachment)
state.attachments.push(attachment)
},
removeById(state, id) {
const attachmentIndex = findIndexById(state.attachments, id)
state.attachments.splice(attachmentIndex, 1)
console.debug('Remove attachement', id)
},
},
}