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

@ -9,7 +9,7 @@ export const MONSTERTYPES = [
"Fées", "Fées",
"Fiélon", "Fiélon",
"Géant", "Géant",
"Humanoide", "Humanoïde",
"Mort-vivant", "Mort-vivant",
"Plante", "Plante",
"Vase", "Vase",

View file

@ -5,6 +5,7 @@ export default {
state: { state: {
magicItems: [], magicItems: [],
notPrintedMagicItems: []
}, },
getters: { getters: {
@ -31,8 +32,13 @@ export default {
// Récupération des données utilisateurs depuis le navigateur // Récupération des données utilisateurs depuis le navigateur
if(localStorage.getItem('myMagicItems') && localStorage.getItem('myMagicItems') !== undefined) { if(localStorage.getItem('myMagicItems') && localStorage.getItem('myMagicItems') !== undefined) {
let localStorageData = JSON.parse(localStorage.getItem('myMagicItems')) let localStorageData = JSON.parse(localStorage.getItem('myMagicItems'))
if (localStorageData.magicItems) {
state.magicItems = localStorageData.magicItems state.magicItems = localStorageData.magicItems
} }
if (localStorageData.notPrintedMagicItems) {
state.notPrintedMagicItems = localStorageData.notPrintedMagicItems
}
}
}, },
setMagicItems: (state, payload) => { setMagicItems: (state, payload) => {
state.magicItems = payload state.magicItems = 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: { state: {
monsters: [], monsters: [],
notPrintedMonsters: []
}, },
getters: { getters: {
@ -31,8 +32,13 @@ export default {
// Récupération des données utilisateurs depuis le navigateur // Récupération des données utilisateurs depuis le navigateur
if(localStorage.getItem('myMonsters') && localStorage.getItem('myMonsters') !== undefined) { if(localStorage.getItem('myMonsters') && localStorage.getItem('myMonsters') !== undefined) {
let localStorageData = JSON.parse(localStorage.getItem('myMonsters')) let localStorageData = JSON.parse(localStorage.getItem('myMonsters'))
if (localStorageData.monsters) {
state.monsters = localStorageData.monsters state.monsters = localStorageData.monsters
} }
if (localStorageData.notPrintedMonsters) {
state.notPrintedMonsters = localStorageData.notPrintedMonsters
}
}
}, },
setMonsters: (state, payload) => { setMonsters: (state, payload) => {
state.monsters = payload state.monsters = 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)
}
}
} }
} }

View file

@ -2,21 +2,63 @@
<main class="page content"> <main class="page content">
<div class="theme-default-content"> <div class="theme-default-content">
<div v-if="magicItems.length > 0"> <div v-if="magicItems.length > 0">
<masonry class="d-print-none" :cols="{'default': 2, 960: 1}" :gutter="24">
<MagicItemCard v-for="(magicItem, idx) in magicItems" :magicItem="magicItem" :showActions="true" :key="idx"> <div class="d-print-none mb-12">
</MagicItemCard>
</masonry> <v-data-table
<div class="d-none d-print-block" v-for="magicItem in magicItems"> class="data-table"
<div> :headers="headers"
:items="magicItems"
item-key="key"
:sort-by="sortBy"
:sort-desc="sortDesc"
must-sort
:items-per-page="-1"
hide-default-footer
show-expand
>
<template v-slot:expanded-item="{ headers, item }">
<td :colspan="headers.length" class="pa-4">
<MagicItem :magicItem="item" />
</td>
</template>
<template v-slot:item.title="{ item }">
<span class="subtitle-2">{{ item.title }}</span>
</template>
<template v-slot:item.frontmatter.attunement="{ item }">
<span v-if="item.frontmatter.attunement">{{ item.frontmatter.attunement }}</span>
</template>
<template v-slot:item.actions="{ item }">
<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 link icon :to="{ path: '/creation-d-objet-magique/', 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('myMagicItems/removeMagicItem', item)"><v-icon>mdi-delete</v-icon></v-btn>
</div>
</template>
</v-data-table>
</div>
<div class="d-none d-print-block column-count-2">
<div v-for="magicItem in magicItems">
<div v-if="!isHiddenPrint(magicItem)">
<h2 class="d-flex align-center"> <h2 class="d-flex align-center">
<div class="mr-4">{{ magicItem.title }}</div> <div class="mr-4">{{ magicItem.title }}</div>
<v-btn class="d-print-none mr-2" small depressed link :to="{ path: '/creation-de-sort/', query: { key: magicItem.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: magicItem.key } }"><v-icon left>mdi-pencil</v-icon> Modifier</v-btn>
<v-btn color="error" class="d-print-none" small depressed @click="$store.commit('myMagicItems/removeMagicItem', magicItem)"><v-icon left>mdi-delete</v-icon> Supprimer</v-btn> <v-btn color="error" class="d-print-none" small depressed @click="$store.commit('myMagicItems/removeMagicItem', magicItem)"><v-icon left>mdi-delete</v-icon> Supprimer</v-btn>
</h2> </h2>
</div>
<MagicItem :magicItem="magicItem" :isList="true" :hideTitle="true" /> <MagicItem :magicItem="magicItem" :isList="true" :hideTitle="true" />
</div> </div>
</div> </div>
</div>
</div>
<template v-else> <template v-else>
Vous n'avez aucun objet magique. Vous n'avez aucun objet magique.
</template> </template>
@ -27,19 +69,25 @@
<script> <script>
import MagicItem from '@theme/components/MagicItem' import MagicItem from '@theme/components/MagicItem'
import MagicItemCard from '@theme/components/MagicItemCard'
export default { export default {
name: 'MyMagicItems', name: 'MyMagicItems',
components: { components: {
MagicItem, MagicItem
MagicItemCard
}, },
data () { data () {
return { return {
sortBy: 'title',
sortDesc: false,
headers: [
{ text: "Nom", align: 'start', sortable: true, value: 'title' },
{ text: "Type", align: 'start', sortable: false, value: 'frontmatter.type' },
{ text: "Rareté", align: 'start', sortable: false, value: 'frontmatter.rarity' },
{ text: "Harmonisation", align: 'start', sortable: false, value: 'frontmatter.attunement' },
{ text: "", align: 'center', sortable: false, value: 'actions' },
],
} }
}, },
@ -50,6 +98,22 @@ export default {
}, },
methods: { methods: {
toggleHidePrint (magicItem) {
if (this.isHiddenPrint(magicItem)) {
this.$store.commit('myMagicItems/removeNotPrintedMagicItem', magicItem)
} else {
this.$store.commit('myMagicItems/addNotPrintedMagicItem', magicItem)
}
},
isHiddenPrint (magicItem) {
if (this.$store.state.myMagicItems.notPrintedMagicItems) {
let idx = this.$store.state.myMagicItems.notPrintedMagicItems.findIndex(item => item.key == magicItem.key)
if (idx >= 0) {
return true
}
}
return false
}
} }
} }
</script> </script>

View file

@ -2,18 +2,70 @@
<main class="page content"> <main class="page content">
<div class="theme-default-content"> <div class="theme-default-content">
<template v-if="monsters.length > 0"> <template v-if="monsters.length > 0">
<MonsterCard class="d-print-none" v-for="(monster, idx) in monsters" :monster="monster" :showActions="true" :key="idx">
</MonsterCard> <div class="d-print-none mb-12">
<div class="d-none d-print-block" v-for="monster in monsters">
<div> <v-data-table
class="data-table"
:headers="headers"
:items="monsters"
item-key="key"
:sort-by="sortBy"
:sort-desc="sortDesc"
must-sort
:items-per-page="-1"
hide-default-footer
show-expand
>
<template v-slot:expanded-item="{ headers, item }">
<td :colspan="headers.length" class="pa-4">
<Monster class="column-count-2" :monster="item" />
</td>
</template>
<template v-slot:item.title="{ item }">
<span class="subtitle-2">{{ item.title }}</span>
</template>
<template v-slot:item.frontmatter.challenge="{ item }">
<span>{{ displayChallenge(item.frontmatter.challenge) }}</span>
</template>
<template v-slot:item.frontmatter.environments="{ item }">
<span v-if="item.frontmatter.environments">{{ displayList(item.frontmatter.environments) }}</span>
</template>
<template v-slot:item.frontmatter.dungeonTypes="{ item }">
<span v-if="item.frontmatter.dungeonTypes">{{ displayList(item.frontmatter.dungeonTypes) }}</span>
</template>
<template v-slot:item.actions="{ item }">
<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 link icon :to="{ path: '/creation-de-monstre-pnj/', 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('myMonsters/removeMonster', item)"><v-icon>mdi-delete</v-icon></v-btn>
</div>
</template>
</v-data-table>
</div>
<div class="d-none d-print-block column-count-2">
<div v-for="monster in monsters">
<div v-if="!isHiddenPrint(monster)">
<h1 class="d-flex align-center"> <h1 class="d-flex align-center">
<div class="mr-4">{{ monster.title }}</div> <div class="mr-4">{{ monster.title }}</div>
<v-btn class="d-print-none mr-2" small depressed link :to="{ path: '/creation-de-monstre-pnj/', query: { key: monster.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-monstre-pnj/', query: { key: monster.key } }"><v-icon left>mdi-pencil</v-icon> Modifier</v-btn>
<v-btn color="error" class="d-print-none" small depressed @click="$store.commit('myMonsters/removeMonster', monster)"><v-icon left>mdi-delete</v-icon> Supprimer</v-btn> <v-btn color="error" class="d-print-none" small depressed @click="$store.commit('myMonsters/removeMonster', monster)"><v-icon left>mdi-delete</v-icon> Supprimer</v-btn>
</h1> </h1>
</div>
<Monster :monster="monster" :isList="true" :hideTitle="true" /> <Monster :monster="monster" :isList="true" :hideTitle="true" />
</div> </div>
</div>
</div>
</template> </template>
<template v-else> <template v-else>
Vous n'avez recensé aucun monstre dans votre bestiaire. Vous n'avez recensé aucun monstre dans votre bestiaire.
@ -25,19 +77,29 @@
<script> <script>
import Monster from '@theme/components/Monster' import Monster from '@theme/components/Monster'
import MonsterCard from '@theme/components/MonsterCard' import { displayChallenge } from '@theme/util/monsterHelpers'
export default { export default {
name: 'MyMonsters', name: 'MyMonsters',
components: { components: {
Monster, Monster
MonsterCard
}, },
data () { data () {
return { return {
sortBy: 'title',
sortDesc: false,
headers: [
{ text: "Nom", align: 'start', sortable: true, value: 'title' },
{ text: "ID", align: 'center', sortable: true, value: 'frontmatter.challenge' },
{ text: "Type", align: 'start', sortable: false, value: 'frontmatter.type' },
{ text: "Taille", align: 'center', sortable: false, value: 'frontmatter.size' },
{ text: "Sous-type", align: 'start', sortable: false, value: 'frontmatter.subtype' },
{ text: "Environnements", align: 'start', sortable: false, value: 'frontmatter.environments' },
{ text: "Type de donjons", align: 'start', sortable: false, value: 'frontmatter.dungeonTypes' },
{ text: "", align: 'center', sortable: false, value: 'actions' },
]
} }
}, },
@ -48,6 +110,24 @@ export default {
}, },
methods: { methods: {
displayList (list) { return list.join(', ') },
displayChallenge (challenge) { return displayChallenge(challenge) },
toggleHidePrint (monster) {
if (this.isHiddenPrint(monster)) {
this.$store.commit('myMonsters/removeNotPrintedMonster', monster)
} else {
this.$store.commit('myMonsters/addNotPrintedMonster', monster)
}
},
isHiddenPrint (monster) {
if (this.$store.state.myMonsters.notPrintedMonsters) {
let idx = this.$store.state.myMonsters.notPrintedMonsters.findIndex(item => item.key == monster.key)
if (idx >= 0) {
return true
}
}
return false
}
} }
} }
</script> </script>

View file

@ -4,20 +4,6 @@
<div v-if="spells.length > 0"> <div v-if="spells.length > 0">
<div class="d-print-none mb-12"> <div class="d-print-none mb-12">
<v-dialog v-model="spellCard" max-width="660">
<v-card v-if="selectedSpell">
<v-card-title class="headline">
{{selectedSpell.title}}
<v-spacer></v-spacer>
<v-btn icon @click="spellCard = false"><v-icon>mdi-close</v-icon></v-btn>
</v-card-title>
<v-card-text>
<Spell :spell="selectedSpell" :isList="true" :hideTitle="true" />
</v-card-text>
</v-card>
</v-dialog>
<v-data-table <v-data-table
class="data-table" class="data-table"
:headers="headers" :headers="headers"
@ -29,8 +15,15 @@
must-sort must-sort
:items-per-page="-1" :items-per-page="-1"
hide-default-footer hide-default-footer
show-expand
> >
<template v-slot:expanded-item="{ headers, item }">
<td :colspan="headers.length" class="pa-4">
<Spell :spell="item" />
</td>
</template>
<template v-slot:group.header="{ group, headers, isOpen, toggle }"> <template v-slot:group.header="{ group, headers, isOpen, toggle }">
<td class="group-header" :colspan="headers.length"> <td class="group-header" :colspan="headers.length">
<div class="d-block d-md-flex align-center"> <div class="d-block d-md-flex align-center">
@ -55,7 +48,7 @@
</template> </template>
<template v-slot:item.title="{ item }"> <template v-slot:item.title="{ item }">
<span class="cursor-pointer subtitle-2" @click.stop="openSpellDetails(item)">{{ item.title }}</span> <span class="subtitle-2">{{ item.title }}</span>
</template> </template>
<template v-slot:item.frontmatter.level="{ item }"> <template v-slot:item.frontmatter.level="{ item }">
@ -85,7 +78,6 @@
<v-icon v-if="isHiddenPrint(item)">mdi-printer-off</v-icon> <v-icon v-if="isHiddenPrint(item)">mdi-printer-off</v-icon>
<v-icon v-else>mdi-printer</v-icon> <v-icon v-else>mdi-printer</v-icon>
</v-btn> </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 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> <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> </div>
@ -122,14 +114,12 @@
<script> <script>
import Spell from '@theme/components/Spell' import Spell from '@theme/components/Spell'
import SpellCard from '@theme/components/SpellCard'
export default { export default {
name: 'MySpells', name: 'MySpells',
components: { components: {
Spell, Spell
SpellCard
}, },
data () { data () {
@ -146,9 +136,7 @@ export default {
{ text: "Rituel", align: 'center', sortable: false, value: 'frontmatter.ritual' }, { text: "Rituel", align: 'center', sortable: false, value: 'frontmatter.ritual' },
{ text: "Composantes", align: 'center', sortable: false, value: 'frontmatter.components' }, { text: "Composantes", align: 'center', sortable: false, value: 'frontmatter.components' },
{ text: "", align: 'center', sortable: false, value: 'actions' }, { text: "", align: 'center', sortable: false, value: 'actions' },
], ]
spellCard: false,
selectedSpell: null
} }
}, },
@ -177,10 +165,6 @@ export default {
onInputSpellSlots () { onInputSpellSlots () {
this.$store.commit('mySpells/setSpellSlots', this.spellSlots) this.$store.commit('mySpells/setSpellSlots', this.spellSlots)
}, },
openSpellDetails (spell) {
this.selectedSpell = spell
this.spellCard = true
},
hasSpellOfLevel (level) { hasSpellOfLevel (level) {
for (let spell of this.spells) { for (let spell of this.spells) {
if (spell.frontmatter.level == level && !this.isHiddenPrint(spell)) { if (spell.frontmatter.level == level && !this.isHiddenPrint(spell)) {
@ -211,13 +195,6 @@ export default {
<style lang="scss"> <style lang="scss">
@import "../styles/colors"; @import "../styles/colors";
.group-header {
background-color: $color-dragon;
color: #fff;
}
.cursor-pointer {
cursor: pointer;
}
.spell-slot { .spell-slot {
margin: 0; margin: 0;
} }

View file

@ -65,6 +65,9 @@ export default {
} }
if (isValid) { if (isValid) {
self.$store.commit('myMagicItems/setMagicItems', result.magicItems) self.$store.commit('myMagicItems/setMagicItems', result.magicItems)
if (result.notPrintedMagicItems) {
self.$store.commit('myMagicItems/setNotPrintedMagicItems', result.notPrintedMagicItems)
}
} }
} }

View file

@ -65,6 +65,9 @@ export default {
} }
if (isValid) { if (isValid) {
self.$store.commit('myMonsters/setMonsters', result.monsters) self.$store.commit('myMonsters/setMonsters', result.monsters)
if (result.notPrintedMonsters) {
self.$store.commit('myMonsters/setNotPrintedMonsters', result.notPrintedMonsters)
}
} }
} }

View file

@ -1,3 +1,7 @@
.cursor-pointer {
cursor: pointer;
}
a.header-anchor { a.header-anchor {
text-decoration: none; text-decoration: none;
} }

View file

@ -8,6 +8,15 @@
height: auto !important; height: auto !important;
} }
.break-inside-avoid {
break-inside: avoid;
}
a {
text-decoration: none;
color: rgba(0,0,0,.87) !important;
}
.d-flex { .d-flex {
display: block !important; display: block !important;
} }

View file

@ -93,3 +93,8 @@ table {
} }
} }
} }
.group-header {
background-color: $color-dragon;
color: #fff;
}