mirror of
https://github.com/em-squared/5e-drs.git
synced 2025-10-29 20:54:19 +00:00
ajout de l'option imprimable sur chaque sort dans le grimoire personnel. see #18
This commit is contained in:
parent
9dae3aec37
commit
e6c38d156a
2 changed files with 40 additions and 6 deletions
|
|
@ -5,7 +5,8 @@ export default {
|
|||
|
||||
state: {
|
||||
spells: [],
|
||||
spellSlots: []
|
||||
spellSlots: [],
|
||||
notPrintedSpells: []
|
||||
},
|
||||
|
||||
getters: {
|
||||
|
|
@ -34,6 +35,7 @@ export default {
|
|||
let localStorageData = JSON.parse(localStorage.getItem('mySpells'))
|
||||
state.spells = localStorageData.spells
|
||||
state.spellSlots = localStorageData.spellSlots
|
||||
state.notPrintedSpells = localStorageData.notPrintedSpells
|
||||
}
|
||||
},
|
||||
setSpells: (state, payload) => {
|
||||
|
|
@ -63,6 +65,18 @@ export default {
|
|||
setSpellSlots: (state, 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,9 +80,15 @@
|
|||
</template>
|
||||
|
||||
<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>
|
||||
<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 class="text-no-wrap">
|
||||
<v-btn class="d-print-none mr-2" small depressed icon @click.stop="toggleHidePrint(item)">
|
||||
<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>
|
||||
|
||||
</v-data-table>
|
||||
|
|
@ -93,7 +99,7 @@
|
|||
<h2 v-else>Sorts de niveau {{ level }}</h2>
|
||||
<div class="column-count-2">
|
||||
<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">
|
||||
<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>
|
||||
|
|
@ -177,11 +183,25 @@ export default {
|
|||
},
|
||||
hasSpellOfLevel (level) {
|
||||
for (let spell of this.spells) {
|
||||
if (spell.frontmatter.level == level) {
|
||||
if (spell.frontmatter.level == level && !this.isHiddenPrint(spell)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue