1
0
Fork 0
mirror of https://github.com/em-squared/5e-drs.git synced 2025-10-31 05:24:20 +00:00

modification de l'identification des resources plus robuste

This commit is contained in:
Maxime Moraine 2020-05-24 13:32:31 +02:00
parent 0494298159
commit 96d028dfa6
14 changed files with 130 additions and 94 deletions

View file

@ -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.monsters.sort((a, b) => { return sortByString(a.title, b.title) })
},
updateMonster: (state, payload) => {
state.monsters.forEach((monster, idx) => {
if (monster.key == payload.key) {
state.monsters[idx] = payload
}
})
let monsterIndex = getResourceIndexInLibrary(payload, state.monsters)
if (monsterIndex >= 0) {
state.monsters[monsterIndex] = payload
}
},
removeMonster: (state, payload) => {
state.monsters.forEach((monster, idx) => {
if (monster.key == payload.key) {
state.monsters.splice(idx, 1)
}
})
let monsterIndex = getResourceIndexInLibrary(payload, state.monsters)
if (monsterIndex >= 0) {
state.monsters.splice(monsterIndex, 1)
}
},
setNotPrintedMonsters: (state, payload) => {
state.notPrintedMonsters = payload
},
addNotPrintedMonster: (state, payload) => {
let monsterIndex = state.notPrintedMonsters.findIndex(monster => monster.key == payload.key)
let monsterIndex = getResourceIndexInLibrary(payload, state.notPrintedMonsters)
if (!monsterIndex >= 0) {
state.notPrintedMonsters.push(payload)
}
},
removeNotPrintedMonster: (state, payload) => {
let monsterIndex = state.notPrintedMonsters.findIndex(monster => monster.key == payload.key)
let monsterIndex = getResourceIndexInLibrary(payload, state.notPrintedMonsters)
if (monsterIndex >= 0) {
state.notPrintedMonsters.splice(monsterIndex, 1)
}