mirror of
https://github.com/em-squared/5e-drs.git
synced 2025-12-17 07:30:47 +00:00
modification de l'identification des resources plus robuste
This commit is contained in:
parent
0494298159
commit
96d028dfa6
14 changed files with 130 additions and 94 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import {sortByString} from '@theme/util/filterHelpers'
|
||||
import { getResourceIndexInLibrary } from '@theme/util'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
|
@ -51,30 +52,28 @@ export default {
|
|||
state.magicItems.sort((a, b) => { return sortByString(a.title, b.title) })
|
||||
},
|
||||
updateMagicItem: (state, payload) => {
|
||||
state.magicItems.forEach((magicItem, idx) => {
|
||||
if (magicItem.key == payload.key) {
|
||||
state.magicItems[idx] = payload
|
||||
}
|
||||
})
|
||||
let magicItemIndex = getResourceIndexInLibrary(payload, state.magicItems)
|
||||
if (magicItemIndex >= 0) {
|
||||
state.magicItems[magicItemIndex] = payload
|
||||
}
|
||||
},
|
||||
removeMagicItem: (state, payload) => {
|
||||
state.magicItems.forEach((magicItem, idx) => {
|
||||
if (magicItem.key == payload.key) {
|
||||
state.magicItems.splice(idx, 1)
|
||||
}
|
||||
})
|
||||
let magicItemIndex = getResourceIndexInLibrary(payload, state.magicItems)
|
||||
if (magicItemIndex >= 0) {
|
||||
state.magicItems.splice(magicItemIndex, 1)
|
||||
}
|
||||
},
|
||||
setNotPrintedMagicItems: (state, payload) => {
|
||||
state.notPrintedMagicItems = payload
|
||||
},
|
||||
addNotPrintedMagicItem: (state, payload) => {
|
||||
let magicItemIndex = state.notPrintedMagicItems.findIndex(magicItem => magicItem.key == payload.key)
|
||||
let magicItemIndex = getResourceIndexInLibrary(payload, state.notPrintedMagicItems)
|
||||
if (!magicItemIndex >= 0) {
|
||||
state.notPrintedMagicItems.push(payload)
|
||||
}
|
||||
},
|
||||
removeNotPrintedMagicItem: (state, payload) => {
|
||||
let magicItemIndex = state.notPrintedMagicItems.findIndex(magicItem => magicItem.key == payload.key)
|
||||
let magicItemIndex = getResourceIndexInLibrary(payload, state.notPrintedMagicItems)
|
||||
if (magicItemIndex >= 0) {
|
||||
state.notPrintedMagicItems.splice(magicItemIndex, 1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue