2019-12-03 20:57:52 +00:00
|
|
|
<template>
|
2019-12-30 21:51:19 +00:00
|
|
|
<div key="champions" class="mt-3">
|
2020-08-27 19:35:39 +00:00
|
|
|
<div class="flex items-center space-x-4">
|
2019-12-27 21:09:24 +00:00
|
|
|
<ChampionsSearch @search-champions="updateSearch" />
|
2020-08-27 19:35:39 +00:00
|
|
|
<FilterQueue @filter-queue="filterByQueue" :choices="queues" />
|
|
|
|
|
<OnlyMostPlayed v-model="onlyMostPlayed" />
|
2019-12-03 20:57:52 +00:00
|
|
|
</div>
|
2020-08-27 19:35:39 +00:00
|
|
|
<ChampionsTable
|
|
|
|
|
:champions="champions"
|
|
|
|
|
:search="searchChampions"
|
|
|
|
|
:only-most-played="onlyMostPlayed"
|
|
|
|
|
class="mt-6"
|
|
|
|
|
/>
|
2019-12-03 20:57:52 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
2019-12-21 16:56:31 +00:00
|
|
|
|
|
|
|
|
<script>
|
2019-12-27 21:09:24 +00:00
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex'
|
2019-12-23 21:13:42 +00:00
|
|
|
import { gameModes } from '@/data/data.js'
|
2019-12-22 23:23:05 +00:00
|
|
|
import ChampionsSearch from '@/components/Summoner/Champions/ChampionsSearch.vue'
|
2019-12-21 16:56:31 +00:00
|
|
|
import ChampionsTable from '@/components/Summoner/Champions/ChampionsTable.vue'
|
2019-12-23 21:13:42 +00:00
|
|
|
import FilterQueue from '@/components/Summoner/Champions/FilterQueue.vue'
|
2020-08-27 19:35:39 +00:00
|
|
|
import OnlyMostPlayed from '@/components/Summoner/Champions/OnlyMostPlayed.vue'
|
2019-12-21 16:56:31 +00:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
2019-12-22 23:23:05 +00:00
|
|
|
ChampionsSearch,
|
2019-12-21 16:56:31 +00:00
|
|
|
ChampionsTable,
|
2019-12-23 21:13:42 +00:00
|
|
|
FilterQueue,
|
2020-08-27 19:35:39 +00:00
|
|
|
OnlyMostPlayed,
|
2019-12-21 16:56:31 +00:00
|
|
|
},
|
|
|
|
|
|
2019-12-22 23:23:05 +00:00
|
|
|
data() {
|
|
|
|
|
return {
|
2020-08-27 19:35:39 +00:00
|
|
|
onlyMostPlayed: false,
|
2020-02-01 19:17:14 +00:00
|
|
|
queue: null,
|
2023-09-20 20:01:43 +00:00
|
|
|
searchChampions: '',
|
2019-12-22 23:23:05 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-12-21 16:56:31 +00:00
|
|
|
computed: {
|
2019-12-23 21:13:42 +00:00
|
|
|
queues() {
|
|
|
|
|
// Only keep the gameModes the summoner has played
|
|
|
|
|
const queues = Object.keys(gameModes)
|
2023-09-20 20:01:43 +00:00
|
|
|
.filter(
|
|
|
|
|
(gameMode) =>
|
|
|
|
|
gameModes[gameMode].type !== 'Bot' && this.gamemodes.includes(Number(gameMode))
|
2019-12-23 21:13:42 +00:00
|
|
|
)
|
|
|
|
|
.reduce((obj, key) => {
|
|
|
|
|
return {
|
|
|
|
|
...obj,
|
2023-09-20 20:01:43 +00:00
|
|
|
[key]: gameModes[key],
|
2019-12-23 21:13:42 +00:00
|
|
|
}
|
|
|
|
|
}, {})
|
2023-09-20 20:01:43 +00:00
|
|
|
return { 0: { type: 'Normal', name: 'All queues' }, ...queues }
|
2019-12-23 21:13:42 +00:00
|
|
|
},
|
2019-12-27 21:09:24 +00:00
|
|
|
...mapGetters('summoner', ['summonerFound']),
|
2019-12-21 16:56:31 +00:00
|
|
|
...mapState({
|
2023-09-20 20:01:43 +00:00
|
|
|
champions: (state) => state.summoner.champions.list,
|
|
|
|
|
championsLoaded: (state) => state.summoner.champions.championsLoaded,
|
|
|
|
|
gamemodes: (state) => state.summoner.basic.gamemodes,
|
|
|
|
|
}),
|
2019-12-21 16:56:31 +00:00
|
|
|
},
|
|
|
|
|
|
2019-12-28 19:35:05 +00:00
|
|
|
watch: {
|
2020-02-01 19:17:14 +00:00
|
|
|
championsLoaded() {
|
|
|
|
|
this.fetchData()
|
|
|
|
|
},
|
2019-12-28 19:35:05 +00:00
|
|
|
summonerFound() {
|
|
|
|
|
this.fetchData()
|
2023-09-20 20:01:43 +00:00
|
|
|
},
|
2019-12-21 16:56:31 +00:00
|
|
|
},
|
|
|
|
|
|
2019-12-28 19:35:05 +00:00
|
|
|
created() {
|
|
|
|
|
this.fetchData()
|
|
|
|
|
},
|
|
|
|
|
|
2019-12-21 16:56:31 +00:00
|
|
|
methods: {
|
2019-12-28 19:35:05 +00:00
|
|
|
fetchData() {
|
|
|
|
|
if (!this.championsLoaded && this.summonerFound) {
|
2020-02-01 19:17:14 +00:00
|
|
|
this.championsRequest(this.queue)
|
2019-12-28 19:35:05 +00:00
|
|
|
}
|
|
|
|
|
},
|
2019-12-23 21:13:42 +00:00
|
|
|
filterByQueue(queue) {
|
2019-12-27 17:38:43 +00:00
|
|
|
queue = Number(queue)
|
2022-01-07 23:55:50 +00:00
|
|
|
this.queue = queue === 0 ? null : queue
|
2020-02-01 19:17:14 +00:00
|
|
|
this.championsRequest(this.queue)
|
2019-12-23 21:13:42 +00:00
|
|
|
},
|
2019-12-22 23:23:05 +00:00
|
|
|
updateSearch(search) {
|
|
|
|
|
this.searchChampions = search
|
|
|
|
|
},
|
2020-01-01 15:39:54 +00:00
|
|
|
...mapActions('summoner', ['championsRequest']),
|
2020-06-26 15:27:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
metaInfo() {
|
|
|
|
|
return {
|
|
|
|
|
title: 'Summoner Champions',
|
|
|
|
|
}
|
2023-09-20 20:01:43 +00:00
|
|
|
},
|
2019-12-21 16:56:31 +00:00
|
|
|
}
|
|
|
|
|
</script>
|