2020-08-22 18:59:58 +00:00
|
|
|
<template lang="html">
|
|
|
|
<div class="platform-picker">
|
2020-10-14 23:57:10 +00:00
|
|
|
<b-dropdown
|
2020-10-21 16:25:11 +00:00
|
|
|
:text="dropdownLabel"
|
2020-10-15 21:27:53 +00:00
|
|
|
boundary="viewport"
|
2020-10-14 23:57:10 +00:00
|
|
|
>
|
2020-10-14 23:20:25 +00:00
|
|
|
<b-dropdown-item
|
2020-08-26 17:34:59 +00:00
|
|
|
v-for="platform in filteredPlatforms"
|
2020-10-21 16:25:11 +00:00
|
|
|
:key="platform.id"
|
2020-10-14 23:20:25 +00:00
|
|
|
:active="value.includes(platform.id)"
|
|
|
|
@click="handleClick(platform.id)"
|
2020-08-26 17:34:59 +00:00
|
|
|
>
|
2020-10-14 23:20:25 +00:00
|
|
|
<b-img
|
|
|
|
:src="`/static/platform-logos/${platform.slug}.${platform.logoFormat}`"
|
|
|
|
:alt="platform.name"
|
|
|
|
width="40"
|
|
|
|
class="pr-2"
|
|
|
|
/>
|
|
|
|
|
|
|
|
{{ platform.name }}
|
|
|
|
</b-dropdown-item>
|
|
|
|
</b-dropdown>
|
|
|
|
|
|
|
|
<b-alert :show="value.length > 1" class="mt-3 mb-0">
|
|
|
|
Game search will be limited to the platforms selected.
|
|
|
|
</b-alert>
|
2020-08-22 18:59:58 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-08-25 04:21:24 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2020-08-22 18:59:58 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: Array,
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-08-25 04:21:24 +00:00
|
|
|
...mapGetters(['filteredPlatforms']),
|
2020-10-14 23:20:25 +00:00
|
|
|
|
|
|
|
dropdownLabel() {
|
|
|
|
return this.value.length
|
|
|
|
? this.$t('board.settings.platformLabel', { platformCount: this.value.length })
|
|
|
|
: this.$t('board.settings.platformPlaceholder');
|
|
|
|
},
|
2020-08-22 18:59:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
handleClick(platformId) {
|
|
|
|
if (this.value.includes(platformId)) {
|
|
|
|
this.removePlatform(platformId);
|
|
|
|
} else {
|
|
|
|
this.selectPlatform(platformId);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
selectPlatform(platformId) {
|
|
|
|
this.value.push(platformId);
|
|
|
|
},
|
|
|
|
|
|
|
|
removePlatform(platformId) {
|
|
|
|
const index = this.value.indexOf(platformId);
|
|
|
|
|
|
|
|
this.value.splice(index, 1);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-10-14 23:57:10 +00:00
|
|
|
|
2020-10-21 19:02:32 +00:00
|
|
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
|
|
|
.dropdown {
|
|
|
|
max-height: 50vh;
|
2020-10-14 23:57:10 +00:00
|
|
|
}
|
|
|
|
</style>
|