forked from vikunja/frontend
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>
This commit is contained in:
parent
7ab308b846
commit
0376ef53e3
3
src/helpers/find.ts
Normal file
3
src/helpers/find.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function findIndexById(array : [], id : string | number) {
|
||||
return array.findIndex(({id: currentId}) => currentId === id)
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
import {findIndexById} from '@/helpers/find'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: () => ({
|
||||
@ -15,13 +17,9 @@ export default {
|
||||
state.attachments.push(attachment)
|
||||
},
|
||||
removeById(state, id) {
|
||||
for (const a in state.attachments) {
|
||||
if (state.attachments[a].id === id) {
|
||||
state.attachments.splice(a, 1)
|
||||
console.debug('Remove attachement', id)
|
||||
break
|
||||
}
|
||||
}
|
||||
const attachmentIndex = findIndexById(state.attachments, id)
|
||||
state.attachments.splice(attachmentIndex, 1)
|
||||
console.debug('Remove attachement', id)
|
||||
},
|
||||
},
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user