2018-10-19 05:15:28 +00:00
|
|
|
<template lang="html">
|
2020-08-18 18:56:10 +00:00
|
|
|
<div class="board" :class="{ dragging }" >
|
2020-08-15 00:00:55 +00:00
|
|
|
<board-placeholder v-if="loading" />
|
2019-11-21 21:44:51 +00:00
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
<template v-else>
|
|
|
|
<pre>{{ board }}</pre>
|
|
|
|
<list
|
|
|
|
v-for="(list, listIndex) in board.lists"
|
|
|
|
v-if="list && !loading"
|
|
|
|
:name="list.name"
|
|
|
|
:game-list="list.games"
|
|
|
|
:list-index="listIndex"
|
|
|
|
:key="`${list.name}-${listIndex}`"
|
|
|
|
@dragEnd="updateLists"
|
|
|
|
/>
|
|
|
|
</template>
|
2019-11-08 20:34:06 +00:00
|
|
|
|
2020-08-15 06:52:35 +00:00
|
|
|
<add-list />
|
2019-11-21 22:06:14 +00:00
|
|
|
<game-modal />
|
2019-11-08 20:34:06 +00:00
|
|
|
</div>
|
2018-10-19 05:15:28 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-08-15 00:00:55 +00:00
|
|
|
import BoardPlaceholder from '@/components/Board/BoardPlaceholder';
|
|
|
|
import AddList from '@/components/Board/AddList';
|
2020-08-18 18:56:10 +00:00
|
|
|
import GameModal from '@/components/Game/GameModal';
|
2019-05-17 05:37:58 +00:00
|
|
|
import List from '@/components/Lists/List';
|
2020-08-18 18:56:10 +00:00
|
|
|
// import chunk from 'lodash.chunk';
|
2019-10-09 16:30:07 +00:00
|
|
|
import { mapState } from 'vuex';
|
2018-10-19 05:15:28 +00:00
|
|
|
import draggable from 'vuedraggable';
|
2018-10-25 06:33:15 +00:00
|
|
|
|
2018-10-19 05:15:28 +00:00
|
|
|
export default {
|
2019-11-08 19:56:03 +00:00
|
|
|
components: {
|
|
|
|
draggable,
|
|
|
|
List,
|
2020-08-15 00:00:55 +00:00
|
|
|
BoardPlaceholder,
|
2020-08-11 04:16:43 +00:00
|
|
|
AddList,
|
2019-11-21 22:06:14 +00:00
|
|
|
GameModal,
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-08-18 18:56:10 +00:00
|
|
|
loading: true,
|
2019-11-08 19:56:03 +00:00
|
|
|
gameData: null,
|
|
|
|
gameDetailListIndex: null,
|
|
|
|
queryLimit: 500,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-08-18 18:56:10 +00:00
|
|
|
...mapState(['user', 'gameLists', 'platform', 'boards', 'games', 'dragging', 'board']),
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
2018-10-19 05:15:28 +00:00
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
mounted() {
|
2020-08-18 18:56:10 +00:00
|
|
|
this.load();
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-08-18 18:56:10 +00:00
|
|
|
load() {
|
|
|
|
// TODO: handle loading public board
|
|
|
|
if (this.$route.params.id && this.user) {
|
|
|
|
this.loadBoard(this.$route.params.id);
|
|
|
|
} else {
|
|
|
|
this.$router.push({ name: 'dashboard' });
|
|
|
|
}
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
2020-08-11 04:16:43 +00:00
|
|
|
async updateLists() {
|
2020-08-18 21:35:32 +00:00
|
|
|
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
2019-11-08 19:56:03 +00:00
|
|
|
.catch(() => {
|
2020-08-13 06:55:56 +00:00
|
|
|
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
2019-11-08 19:56:03 +00:00
|
|
|
this.$router.push({ name: 'sessionExpired' });
|
|
|
|
});
|
2020-08-11 04:16:43 +00:00
|
|
|
|
|
|
|
this.$bvToast.toast('List saved', {
|
|
|
|
title: 'Success',
|
|
|
|
variant: 'success',
|
|
|
|
});
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
async loadBoard(id) {
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
await this.$store.dispatch('LOAD_BOARD', id)
|
|
|
|
.catch(() => {
|
|
|
|
this.$router.replace({ path: '/' });
|
|
|
|
});
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
this.loadBoardGames();
|
|
|
|
},
|
2019-11-08 19:56:03 +00:00
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
loadBoardGames() {
|
|
|
|
const { lists } = this.board;
|
2019-12-13 07:07:15 +00:00
|
|
|
|
2020-08-18 21:35:32 +00:00
|
|
|
if (lists.length === 0) {
|
2020-08-18 18:56:10 +00:00
|
|
|
return this.$bvModal.show('add-list');
|
2019-12-13 07:07:15 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
const boardGames = lists.length > 0
|
|
|
|
? lists.map(({ games }) => games).flat()
|
|
|
|
: [];
|
2019-11-08 19:56:03 +00:00
|
|
|
|
2020-08-18 21:35:32 +00:00
|
|
|
// eslint-disable-next-line
|
2020-08-18 18:56:10 +00:00
|
|
|
console.log(boardGames);
|
|
|
|
|
2020-08-18 21:35:32 +00:00
|
|
|
return boardGames;
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
// if (!hasLists && flattenedList.length === 0) {
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// const dedupedList = Array.from(new Set(flattenedList));
|
|
|
|
//
|
|
|
|
// return dedupedList.length > this.queryLimit
|
|
|
|
// ? this.loadGamesInChunks(dedupedList)
|
|
|
|
// : this.loadGames(dedupedList);
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
loadGames(gameList) {
|
2020-08-18 18:56:10 +00:00
|
|
|
// eslint-disable-next-line
|
|
|
|
console.log(gameList);
|
|
|
|
// if (gameList && gameList.length > 0) {
|
|
|
|
// this.loading = true;
|
|
|
|
//
|
|
|
|
// this.$store
|
|
|
|
// .dispatch('LOAD_BOARD_GAMES', gameList.toString())
|
|
|
|
// .then(() => {
|
|
|
|
// this.loading = false;
|
|
|
|
// })
|
|
|
|
// .catch(() => {
|
|
|
|
// this.$bvToast.toast('Error loading games', { title: 'Error', variant: 'error' });
|
|
|
|
// });
|
|
|
|
// }
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
loadGamesInChunks(gameList) {
|
2020-08-18 18:56:10 +00:00
|
|
|
// eslint-disable-next-line
|
|
|
|
console.log(gameList);
|
|
|
|
// const chunkedGameList = chunk(gameList, this.queryLimit);
|
|
|
|
//
|
|
|
|
// chunkedGameList.forEach((gameListChunk) => {
|
|
|
|
// this.loadGames(gameListChunk);
|
|
|
|
// });
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
2018-10-19 05:15:28 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
2020-08-15 00:00:55 +00:00
|
|
|
.board {
|
2019-11-14 21:10:10 +00:00
|
|
|
user-select: none;
|
|
|
|
display: flex;
|
|
|
|
align-items: flex-start;
|
2020-08-15 00:00:55 +00:00
|
|
|
height: calc(100vh - 58px);
|
2020-07-22 20:44:48 +00:00
|
|
|
padding: 0 1rem;
|
2019-11-14 21:10:10 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
overflow-x: auto;
|
|
|
|
overflow-x: overlay;
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.list-placeholder {
|
|
|
|
opacity: 0.25;
|
|
|
|
}
|
2018-10-19 05:15:28 +00:00
|
|
|
</style>
|