| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <div class="magic-items"> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-22 14:23:59 +02:00
										 |  |  |     <div class="d-flex flex-wrap align-center"> | 
					
						
							|  |  |  |       <Breadcrumb class="mr-auto mb-4" /> | 
					
						
							|  |  |  |       <div class="d-flex flex-wrap align-center"> | 
					
						
							|  |  |  |         <v-btn color="primary" class="mr-4 mb-4" depressed link to="/creation-d-objet-magique/"><v-icon left>mdi-plus</v-icon> Créer un objet magique</v-btn> | 
					
						
							|  |  |  |         <v-btn color="primary" class="mb-4" depressed link to="/mes-objets-magiques/">Mes objets magiques</v-btn> | 
					
						
							|  |  |  |       </div> | 
					
						
							| 
									
										
										
										
											2020-04-22 11:17:05 +02:00
										 |  |  |     </div> | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <h1>Liste des objets magiques</h1> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <v-data-table | 
					
						
							|  |  |  |       class="data-table" | 
					
						
							|  |  |  |       :headers="headers" | 
					
						
							|  |  |  |       :items="magicitems" | 
					
						
							|  |  |  |       item-key="key" | 
					
						
							|  |  |  |       :sort-by.sync="sortBy" | 
					
						
							|  |  |  |       :sort-desc.sync="sortDesc" | 
					
						
							| 
									
										
										
										
											2020-04-16 16:08:44 +02:00
										 |  |  |       must-sort | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |       :search="search" | 
					
						
							| 
									
										
										
										
											2020-04-26 10:27:02 +02:00
										 |  |  |       :items-per-page.sync="itemsPerPage" | 
					
						
							|  |  |  |       :page.sync="page" | 
					
						
							|  |  |  |       @page-count="pageCount = $event" | 
					
						
							|  |  |  |       hide-default-footer | 
					
						
							| 
									
										
										
										
											2020-05-06 17:34:35 +02:00
										 |  |  |       show-expand | 
					
						
							|  |  |  |       @click:row="onClickRow" | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |     > | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-06 17:34:35 +02:00
										 |  |  |       <template v-slot:expanded-item="{ headers, item }"> | 
					
						
							|  |  |  |         <td :colspan="headers.length" class="pa-4"> | 
					
						
							|  |  |  |           <MagicItem :magicItem="item" /> | 
					
						
							|  |  |  |         </td> | 
					
						
							|  |  |  |       </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-22 11:17:05 +02:00
										 |  |  |       <template v-slot:item.isInTreasureChest="{ item }"> | 
					
						
							|  |  |  |         <v-simple-checkbox off-icon="mdi-bookmark-outline" on-icon="mdi-bookmark" @input="toggleItemInTreasureChest(item)" :value="isItemInTreasureChest(item)"></v-simple-checkbox> | 
					
						
							|  |  |  |       </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |       <template v-slot:item.title="{ item }"> | 
					
						
							|  |  |  |         <router-link :to="{ path: item.path }" class="subtitle-2">{{ item.title }}</router-link> | 
					
						
							|  |  |  |       </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       <template v-slot:item.frontmatter.attunement="{ item }"> | 
					
						
							|  |  |  |         <span v-if="item.frontmatter.attunement">{{ item.frontmatter.attunement }}</span> | 
					
						
							|  |  |  |       </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     </v-data-table> | 
					
						
							| 
									
										
										
										
											2020-04-26 10:27:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-26 10:46:45 +02:00
										 |  |  |     <v-row class="align-center mb-12 pb-6"> | 
					
						
							| 
									
										
										
										
											2020-04-26 10:27:02 +02:00
										 |  |  |       <v-col :cols="12" md="3"> | 
					
						
							|  |  |  |         <v-select v-model="itemsPerPage" :items="itemsPerPageChoices" label="Lignes par page" @change="selectItemPerPage"></v-select> | 
					
						
							|  |  |  |       </v-col> | 
					
						
							|  |  |  |       <v-col :cols="12" md="9"> | 
					
						
							|  |  |  |         <v-pagination v-model="page" :length="pageCount" :total-visible="7" @input="changePage"></v-pagination> | 
					
						
							|  |  |  |       </v-col> | 
					
						
							|  |  |  |     </v-row> | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | import { mapState } from 'vuex' | 
					
						
							|  |  |  | import Breadcrumb from '@theme/components/Breadcrumb' | 
					
						
							| 
									
										
										
										
											2020-04-26 10:27:02 +02:00
										 |  |  | import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers' | 
					
						
							| 
									
										
										
										
											2020-05-06 17:34:35 +02:00
										 |  |  | import MagicItem from '@theme/components/MagicItem' | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default { | 
					
						
							| 
									
										
										
										
											2020-05-06 17:34:35 +02:00
										 |  |  |   components: { Breadcrumb, MagicItem }, | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   data () { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       sortBy: 'title', | 
					
						
							|  |  |  |       sortDesc: false, | 
					
						
							| 
									
										
										
										
											2020-04-26 10:27:02 +02:00
										 |  |  |       itemsPerPage: 10, | 
					
						
							|  |  |  |       itemsPerPageChoices: [ | 
					
						
							|  |  |  |         {text: '5', value: 5}, | 
					
						
							|  |  |  |         {text: '10', value: 10}, | 
					
						
							|  |  |  |         {text: '15', value: 15}, | 
					
						
							|  |  |  |         {text: 'Tous', value: -1}, | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       page: 1, | 
					
						
							|  |  |  |       pageCount: 0, | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |       headers: [ | 
					
						
							| 
									
										
										
										
											2020-04-22 11:17:05 +02:00
										 |  |  |         { text: "", align: 'center', sortable: false, value: 'isInTreasureChest' }, | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |         { 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' }, | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   computed: { | 
					
						
							|  |  |  |     ...mapState({ | 
					
						
							|  |  |  |       search: state => state.magicItemFilters.search, | 
					
						
							|  |  |  |       types: state => state.magicItemFilters.types, | 
					
						
							|  |  |  |       rarities: state => state.magicItemFilters.rarities, | 
					
						
							|  |  |  |       hasAttunement: state => state.magicItemFilters.hasAttunement, | 
					
						
							|  |  |  |     }), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     magicitems() { | 
					
						
							|  |  |  |       let results = this.$pagination.pages | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Filter attunement
 | 
					
						
							|  |  |  |       if (this.hasAttunement !== undefined) { | 
					
						
							|  |  |  |         if (this.hasAttunement === true) { | 
					
						
							|  |  |  |           results = results.filter(item => { | 
					
						
							|  |  |  |             return item.frontmatter.attunement | 
					
						
							|  |  |  |           }) | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           results = results.filter(item => { | 
					
						
							|  |  |  |             return item.frontmatter.attunement === false | 
					
						
							|  |  |  |           }) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Filter types
 | 
					
						
							|  |  |  |       let selectedTypes = [] | 
					
						
							|  |  |  |       for (var i = 0; i < this.types.length; i++) { | 
					
						
							|  |  |  |         if (this.types[i].value) { | 
					
						
							|  |  |  |           selectedTypes.push(this.types[i].label) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (selectedTypes.length) { | 
					
						
							|  |  |  |         results = results.filter(item => { | 
					
						
							|  |  |  |           return selectedTypes.indexOf(item.frontmatter.type) > -1 | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Filter rarities
 | 
					
						
							|  |  |  |       let selectedRarities = [] | 
					
						
							|  |  |  |       for (var i = 0; i < this.rarities.length; i++) { | 
					
						
							|  |  |  |         if (this.rarities[i].value) { | 
					
						
							|  |  |  |           selectedRarities.push(this.rarities[i].label) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (selectedRarities.length) { | 
					
						
							|  |  |  |         results = results.filter(item => { | 
					
						
							|  |  |  |           return selectedRarities.indexOf(item.frontmatter.rarity) > -1 | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return results | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-22 11:17:05 +02:00
										 |  |  |   methods: { | 
					
						
							|  |  |  |     isItemInTreasureChest (magicItem) { | 
					
						
							|  |  |  |       let isInTreasureChest = false | 
					
						
							|  |  |  |       for (let mi of this.$store.state.myMagicItems.magicItems) { | 
					
						
							|  |  |  |         if (mi.key == magicItem.key) { | 
					
						
							|  |  |  |           isInTreasureChest = true | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return isInTreasureChest | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     toggleItemInTreasureChest (magicItem) { | 
					
						
							|  |  |  |       if (this.isItemInTreasureChest(magicItem)) { | 
					
						
							|  |  |  |         this.$store.commit('myMagicItems/removeMagicItem', magicItem) | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         this.$store.commit('myMagicItems/addMagicItem', magicItem) | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-04-26 10:27:02 +02:00
										 |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     selectItemPerPage (value) { | 
					
						
							|  |  |  |       setUrlParams("lignes", [value]) | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     changePage (page) { | 
					
						
							|  |  |  |       console.log(page) | 
					
						
							|  |  |  |       setUrlParams("page", [page]) | 
					
						
							| 
									
										
										
										
											2020-05-06 17:34:35 +02:00
										 |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     onClickRow (row, item) { | 
					
						
							|  |  |  |       item.expand(!item.isExpanded) | 
					
						
							| 
									
										
										
										
											2020-04-22 11:17:05 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |   mounted () { | 
					
						
							|  |  |  |     this.$store.commit('setHasRightDrawer', true) | 
					
						
							| 
									
										
										
										
											2020-04-11 18:01:59 +02:00
										 |  |  |     this.$store.commit('setRightDrawer', this.$vuetify.breakpoint.lgAndUp) | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |     this.$store.commit('setInRightDrawer', 'magicItemFilters') | 
					
						
							| 
									
										
										
										
											2020-04-26 10:27:02 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     let itemsPerPage = parseInt(getUrlParameter(window.location.href, "lignes")) | 
					
						
							|  |  |  |     if (itemsPerPage) { | 
					
						
							|  |  |  |       this.itemsPerPage = itemsPerPage | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     let page = parseInt(getUrlParameter(window.location.href, "page")) | 
					
						
							|  |  |  |     if (page) { | 
					
						
							|  |  |  |       this.page = page | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-04-09 15:27:03 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style lang="scss"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </style> |