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

ajout de l'option du choix d'impression pour toutes les bibliothèques + refonte des bibliothèques. fix #18

This commit is contained in:
Maxime Moraine 2020-05-04 16:52:03 +02:00
parent 44b8729230
commit 65fa675c6f
11 changed files with 254 additions and 67 deletions

View file

@ -5,6 +5,7 @@ export default {
state: {
monsters: [],
notPrintedMonsters: []
},
getters: {
@ -31,7 +32,12 @@ export default {
// Récupération des données utilisateurs depuis le navigateur
if(localStorage.getItem('myMonsters') && localStorage.getItem('myMonsters') !== undefined) {
let localStorageData = JSON.parse(localStorage.getItem('myMonsters'))
state.monsters = localStorageData.monsters
if (localStorageData.monsters) {
state.monsters = localStorageData.monsters
}
if (localStorageData.notPrintedMonsters) {
state.notPrintedMonsters = localStorageData.notPrintedMonsters
}
}
},
setMonsters: (state, payload) => {
@ -58,6 +64,21 @@ export default {
}
})
},
setNotPrintedMonsters: (state, payload) => {
state.notPrintedMonsters = payload
},
addNotPrintedMonster: (state, payload) => {
let monsterIndex = state.notPrintedMonsters.findIndex(monster => monster.key == payload.key)
if (!monsterIndex >= 0) {
state.notPrintedMonsters.push(payload)
}
},
removeNotPrintedMonster: (state, payload) => {
let monsterIndex = state.notPrintedMonsters.findIndex(monster => monster.key == payload.key)
if (monsterIndex >= 0) {
state.notPrintedMonsters.splice(monsterIndex, 1)
}
}
}
}