feat: improve store and model typing
This commit is contained in:
parent
c9e85cb52b
commit
3766b5e51b
98 changed files with 1050 additions and 507 deletions
|
|
@ -1,21 +1,24 @@
|
|||
import {findIndexById} from '@/helpers/utils'
|
||||
|
||||
import type { AttachmentState } from '@/store/types'
|
||||
import type { IAttachment } from '@/models/attachment'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: () => ({
|
||||
state: (): AttachmentState => ({
|
||||
attachments: [],
|
||||
}),
|
||||
mutations: {
|
||||
set(state, attachments) {
|
||||
set(state: AttachmentState, attachments: IAttachment[]) {
|
||||
console.debug('Set attachments', attachments)
|
||||
state.attachments = attachments
|
||||
},
|
||||
add(state, attachment) {
|
||||
add(state: AttachmentState, attachment: IAttachment) {
|
||||
console.debug('Add attachement', attachment)
|
||||
state.attachments.push(attachment)
|
||||
},
|
||||
removeById(state, id) {
|
||||
const attachmentIndex = findIndexById(state.attachments, id)
|
||||
removeById(state: AttachmentState, id: IAttachment['id']) {
|
||||
const attachmentIndex = findIndexById<IAttachment>(state.attachments, id)
|
||||
state.attachments.splice(attachmentIndex, 1)
|
||||
console.debug('Remove attachement', id)
|
||||
},
|
||||
|
|
|
|||
Reference in a new issue