2021-04-28 23:39:14 +00:00
|
|
|
<template lang="html">
|
|
|
|
<div class="global-search">
|
2021-05-10 22:41:16 +00:00
|
|
|
<b-button v-b-toggle.global-search>
|
|
|
|
<i class="fas fa-search fa-fw" aria-hidden />
|
|
|
|
</b-button>
|
2021-04-28 23:39:14 +00:00
|
|
|
|
2021-05-10 22:41:16 +00:00
|
|
|
<b-sidebar
|
|
|
|
id="global-search"
|
|
|
|
title="Sidebar"
|
|
|
|
shadow
|
|
|
|
backdrop
|
|
|
|
bg-variant="dark"
|
|
|
|
text-variant="white"
|
|
|
|
right
|
|
|
|
header-class="px-2 pt-2 d-flex align-items-center justify-content-between"
|
|
|
|
>
|
|
|
|
<template #header="{ hide }">
|
|
|
|
<h5 class="mb-0 ml-2">
|
|
|
|
Game search
|
|
|
|
</h5>
|
|
|
|
|
|
|
|
<b-button
|
|
|
|
class="align-self-baseline"
|
|
|
|
@click="hide"
|
|
|
|
>
|
|
|
|
<i class="fas fa-times fa-fw" aria-hidden />
|
|
|
|
</b-button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<div class="px-3 py-2">
|
|
|
|
<b-form-input
|
|
|
|
v-model="searchText"
|
|
|
|
type="search"
|
|
|
|
autofocus
|
|
|
|
debounce="500"
|
|
|
|
class="mb-4"
|
|
|
|
:placeholder="$t('board.addGame.inputPlaceholder')"
|
|
|
|
@update="search"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<b-list-group
|
|
|
|
v-for="{ id } in searchResults"
|
|
|
|
:key="id"
|
|
|
|
@click="openGame(id)"
|
|
|
|
>
|
|
|
|
<game-card-search
|
|
|
|
:game-id="id"
|
|
|
|
class="mb-2"
|
|
|
|
/>
|
|
|
|
</b-list-group>
|
|
|
|
</div>
|
|
|
|
</b-sidebar>
|
2021-04-28 23:39:14 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-05-10 22:41:16 +00:00
|
|
|
import GameCardSearch from '@/components/GameCards/GameCardSearch';
|
|
|
|
|
2021-04-28 23:39:14 +00:00
|
|
|
export default {
|
2021-05-10 22:41:16 +00:00
|
|
|
components: {
|
|
|
|
GameCardSearch,
|
|
|
|
},
|
|
|
|
|
2021-04-28 23:39:14 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
searchText: '',
|
2021-05-10 22:41:16 +00:00
|
|
|
searchResults: [],
|
2021-04-28 23:39:14 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2021-05-10 22:41:16 +00:00
|
|
|
openGame(gameId) {
|
|
|
|
this.$store.commit('SET_GAME_MODAL_DATA', { gameId });
|
|
|
|
this.$bvModal.show('game-modal');
|
|
|
|
},
|
|
|
|
|
|
|
|
async search(searchText) {
|
|
|
|
if (!searchText) {
|
|
|
|
this.searchResults = [];
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.searchResults = await this.$store.dispatch('CUSTOM_SEARCH', { searchText });
|
2021-04-28 23:39:14 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
|
|
|
</style>
|