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 imprimable sur chaque sort dans le grimoire personnel. see #18

This commit is contained in:
Maxime Moraine 2020-05-04 11:25:26 +02:00
parent 9dae3aec37
commit e6c38d156a
2 changed files with 40 additions and 6 deletions

View file

@ -5,7 +5,8 @@ export default {
state: { state: {
spells: [], spells: [],
spellSlots: [] spellSlots: [],
notPrintedSpells: []
}, },
getters: { getters: {
@ -34,6 +35,7 @@ export default {
let localStorageData = JSON.parse(localStorage.getItem('mySpells')) let localStorageData = JSON.parse(localStorage.getItem('mySpells'))
state.spells = localStorageData.spells state.spells = localStorageData.spells
state.spellSlots = localStorageData.spellSlots state.spellSlots = localStorageData.spellSlots
state.notPrintedSpells = localStorageData.notPrintedSpells
} }
}, },
setSpells: (state, payload) => { setSpells: (state, payload) => {
@ -63,6 +65,18 @@ export default {
setSpellSlots: (state, payload) => { setSpellSlots: (state, payload) => {
state.spellSlots = payload state.spellSlots = payload
}, },
addNotPrintedSpell: (state, payload) => {
let spellIndex = state.notPrintedSpells.findIndex(spell => spell.key == payload.key)
if (!spellIndex >= 0) {
state.notPrintedSpells.push(payload)
}
},
removeNotPrintedSpell: (state, payload) => {
let spellIndex = state.notPrintedSpells.findIndex(spell => spell.key == payload.key)
if (spellIndex >= 0) {
state.notPrintedSpells.splice(spellIndex, 1)
}
}
} }
} }

View file

@ -80,9 +80,15 @@
</template> </template>
<template v-slot:item.actions="{ item }"> <template v-slot:item.actions="{ item }">
<v-btn class="d-print-none mr-2" small depressed icon @click.stop="openSpellDetails(item)"><v-icon>mdi-eye</v-icon></v-btn> <div class="text-no-wrap">
<v-btn class="d-print-none mr-2" small depressed link icon :to="{ path: '/creation-de-sort/', query: { key: item.key } }"><v-icon>mdi-pencil</v-icon></v-btn> <v-btn class="d-print-none mr-2" small depressed icon @click.stop="toggleHidePrint(item)">
<v-btn color="error" class="d-print-none" small depressed icon @click="$store.commit('mySpells/removeSpell', item)"><v-icon>mdi-delete</v-icon></v-btn> <v-icon v-if="isHiddenPrint(item)">mdi-printer-off</v-icon>
<v-icon v-else>mdi-printer</v-icon>
</v-btn>
<v-btn class="d-print-none mr-2" small depressed icon @click.stop="openSpellDetails(item)"><v-icon>mdi-eye</v-icon></v-btn>
<v-btn class="d-print-none mr-2" small depressed link icon :to="{ path: '/creation-de-sort/', query: { key: item.key } }"><v-icon>mdi-pencil</v-icon></v-btn>
<v-btn color="error" class="d-print-none" small depressed icon @click="$store.commit('mySpells/removeSpell', item)"><v-icon>mdi-delete</v-icon></v-btn>
</div>
</template> </template>
</v-data-table> </v-data-table>
@ -93,7 +99,7 @@
<h2 v-else>Sorts de niveau {{ level }}</h2> <h2 v-else>Sorts de niveau {{ level }}</h2>
<div class="column-count-2"> <div class="column-count-2">
<div v-for="spell in spells"> <div v-for="spell in spells">
<template v-if="spell.frontmatter.level == level"> <template v-if="spell.frontmatter.level == level && !isHiddenPrint(spell)">
<h3 class="d-flex align-center title"> <h3 class="d-flex align-center title">
<div class="mr-4">{{ spell.title }}</div> <div class="mr-4">{{ spell.title }}</div>
<v-btn class="d-print-none mr-2" small depressed link :to="{ path: '/creation-de-sort/', query: { key: spell.key } }"><v-icon left>mdi-pencil</v-icon> Modifier</v-btn> <v-btn class="d-print-none mr-2" small depressed link :to="{ path: '/creation-de-sort/', query: { key: spell.key } }"><v-icon left>mdi-pencil</v-icon> Modifier</v-btn>
@ -177,11 +183,25 @@ export default {
}, },
hasSpellOfLevel (level) { hasSpellOfLevel (level) {
for (let spell of this.spells) { for (let spell of this.spells) {
if (spell.frontmatter.level == level) { if (spell.frontmatter.level == level && !this.isHiddenPrint(spell)) {
return true return true
} }
} }
return false return false
},
toggleHidePrint (spell) {
if (this.isHiddenPrint(spell)) {
this.$store.commit('mySpells/removeNotPrintedSpell', spell)
} else {
this.$store.commit('mySpells/addNotPrintedSpell', spell)
}
},
isHiddenPrint (spell) {
let idx = this.$store.state.mySpells.notPrintedSpells.findIndex(item => item.key == spell.key)
if (idx >= 0) {
return true
}
return false
} }
}, },
} }