1
0
Fork 0
mirror of https://github.com/em-squared/5e-drs.git synced 2025-10-31 05:24:20 +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: {
magicItems: [],
notPrintedMagicItems: []
},
getters: {
@ -31,7 +32,12 @@ export default {
// Récupération des données utilisateurs depuis le navigateur
if(localStorage.getItem('myMagicItems') && localStorage.getItem('myMagicItems') !== undefined) {
let localStorageData = JSON.parse(localStorage.getItem('myMagicItems'))
state.magicItems = localStorageData.magicItems
if (localStorageData.magicItems) {
state.magicItems = localStorageData.magicItems
}
if (localStorageData.notPrintedMagicItems) {
state.notPrintedMagicItems = localStorageData.notPrintedMagicItems
}
}
},
setMagicItems: (state, payload) => {
@ -58,6 +64,21 @@ export default {
}
})
},
setNotPrintedMagicItems: (state, payload) => {
state.notPrintedMagicItems = payload
},
addNotPrintedMagicItem: (state, payload) => {
let magicItemIndex = state.notPrintedMagicItems.findIndex(magicItem => magicItem.key == payload.key)
if (!magicItemIndex >= 0) {
state.notPrintedMagicItems.push(payload)
}
},
removeNotPrintedMagicItem: (state, payload) => {
let magicItemIndex = state.notPrintedMagicItems.findIndex(magicItem => magicItem.key == payload.key)
if (magicItemIndex >= 0) {
state.notPrintedMagicItems.splice(magicItemIndex, 1)
}
}
}
}

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)
}
}
}
}