frontend/src/store/modules/attachments.js
dpschen faa2daa876 feat: remove lodash dependency (#743)
Co-authored-by: Dominik Pschenitschni <mail@celement.de>
Reviewed-on: vikunja/frontend#743
Reviewed-by: konrad <k@knt.li>
Co-authored-by: dpschen <dpschen@noreply.kolaente.de>
Co-committed-by: dpschen <dpschen@noreply.kolaente.de>
2021-10-06 20:25:06 +00:00

25 lines
598 B
JavaScript

import Vue from 'vue'
import {findIndexById} from '@/helpers/utils'
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)
},
},
}