2020-08-18 18:56:10 +00:00
|
|
|
<template lang="html">
|
2021-03-23 23:52:34 +00:00
|
|
|
<div class="mx-2 mb-2" v-if="user">
|
2021-04-02 06:47:20 +00:00
|
|
|
<pre>[ADD ISOTOPE LAYOUT]</pre>
|
|
|
|
<pre>[ALLOW REORGANIZING AND SAVE]</pre>
|
|
|
|
<pre>[SHOW PUBLIC BOARDS]</pre>
|
2021-01-20 21:04:48 +00:00
|
|
|
<div v-if="showPlaceholder" class="boards">
|
2020-11-04 00:27:46 +00:00
|
|
|
<b-card
|
|
|
|
v-for="n in 3"
|
|
|
|
:key="n"
|
|
|
|
no-body
|
2021-01-20 21:04:48 +00:00
|
|
|
class="mb-3 p-1 mt-3"
|
2020-11-04 00:27:46 +00:00
|
|
|
>
|
2021-01-20 21:04:48 +00:00
|
|
|
<b-skeleton-img />
|
2020-11-04 00:27:46 +00:00
|
|
|
</b-card>
|
2021-01-20 21:04:48 +00:00
|
|
|
</div>
|
2020-11-04 00:27:46 +00:00
|
|
|
|
2020-11-23 18:09:33 +00:00
|
|
|
<empty-state
|
2021-03-23 23:52:34 +00:00
|
|
|
v-if="!loading && sortedBoards.length === 0"
|
2020-11-23 18:09:33 +00:00
|
|
|
title="Boards"
|
|
|
|
message="Use boards to easily organize your video game collections"
|
|
|
|
>
|
2021-02-01 21:11:31 +00:00
|
|
|
<b-button
|
2021-02-21 18:14:46 +00:00
|
|
|
:variant="darkTheme ? 'dark' : 'primary'"
|
2021-02-01 21:11:31 +00:00
|
|
|
v-b-modal:create-board
|
|
|
|
>
|
|
|
|
{{ $t('boards.create') }}
|
|
|
|
</b-button>
|
2020-11-23 18:09:33 +00:00
|
|
|
</empty-state>
|
2020-11-22 03:31:18 +00:00
|
|
|
|
2021-03-11 00:06:47 +00:00
|
|
|
<portal to="dock">
|
2021-02-01 21:11:31 +00:00
|
|
|
<b-button
|
2021-02-15 23:54:56 +00:00
|
|
|
variant="primary"
|
2021-02-01 21:11:31 +00:00
|
|
|
v-b-modal:create-board
|
|
|
|
>
|
|
|
|
{{ $t('boards.create') }}
|
|
|
|
</b-button>
|
2021-03-11 00:06:47 +00:00
|
|
|
</portal>
|
2020-11-22 03:31:18 +00:00
|
|
|
|
2021-01-20 21:04:48 +00:00
|
|
|
<div class="boards">
|
|
|
|
<b-card
|
|
|
|
v-for="board in sortedBoards"
|
|
|
|
:key="board.id"
|
|
|
|
no-body
|
2021-02-21 18:14:46 +00:00
|
|
|
:bg-variant="darkTheme ? 'dark' : null"
|
|
|
|
:text-variant="darkTheme ? 'white' : null"
|
2021-02-22 02:36:54 +00:00
|
|
|
class="overflow-hidden clickable position-relative"
|
2021-01-20 21:04:48 +00:00
|
|
|
@click="viewBoard(board.id)"
|
|
|
|
>
|
|
|
|
<mini-board
|
|
|
|
:board="board"
|
2021-02-27 05:14:49 +00:00
|
|
|
:background-image="getWallpaperUrl(board.backgroundUrl)"
|
2021-01-20 21:04:48 +00:00
|
|
|
/>
|
2021-02-22 02:36:54 +00:00
|
|
|
|
|
|
|
<b-button
|
2021-02-22 02:37:37 +00:00
|
|
|
class="position-absolute edit-board-button"
|
2021-02-22 02:36:54 +00:00
|
|
|
:variant="darkTheme ? 'info' : 'light'"
|
|
|
|
size="sm"
|
|
|
|
@click.stop="editBoard(board)"
|
|
|
|
>
|
|
|
|
<i class="fas fa-edit fa-fw" aria-hidden />
|
|
|
|
</b-button>
|
2021-01-20 21:04:48 +00:00
|
|
|
</b-card>
|
2021-02-22 02:36:54 +00:00
|
|
|
|
|
|
|
<edit-board-modal />
|
2021-01-20 21:04:48 +00:00
|
|
|
</div>
|
2021-03-11 00:06:47 +00:00
|
|
|
</div>
|
2020-08-18 18:56:10 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-12-16 21:21:23 +00:00
|
|
|
import MiniBoard from '@/components/Board/MiniBoard';
|
2021-02-22 02:36:54 +00:00
|
|
|
import EditBoardModal from '@/components/Board/EditBoardModal';
|
2020-11-22 03:31:18 +00:00
|
|
|
import EmptyState from '@/components/EmptyState';
|
2020-08-26 18:07:13 +00:00
|
|
|
import { mapState, mapGetters } from 'vuex';
|
2020-08-18 18:56:10 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-12-16 21:21:23 +00:00
|
|
|
MiniBoard,
|
2021-02-22 02:36:54 +00:00
|
|
|
EditBoardModal,
|
2020-11-22 03:31:18 +00:00
|
|
|
EmptyState,
|
2020-08-18 18:56:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2021-03-23 23:52:34 +00:00
|
|
|
...mapState(['user', 'boards', 'wallpapers', 'gameLists']),
|
2021-02-21 18:14:46 +00:00
|
|
|
...mapGetters(['platformNames', 'sortedBoards', 'darkTheme']),
|
2020-09-06 14:53:04 +00:00
|
|
|
|
|
|
|
hasLists() {
|
|
|
|
return Object.keys(this.gameLists).length > 0;
|
|
|
|
},
|
2020-12-17 19:26:08 +00:00
|
|
|
|
|
|
|
showPlaceholder() {
|
2020-12-18 04:46:31 +00:00
|
|
|
return this.loading && Object.keys(this.boards).length === 0;
|
2020-12-17 19:26:08 +00:00
|
|
|
},
|
2020-08-18 18:56:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.load();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
load() {
|
2020-08-22 12:24:24 +00:00
|
|
|
this.loadPlatforms();
|
|
|
|
},
|
|
|
|
|
2021-02-22 02:36:54 +00:00
|
|
|
editBoard(board) {
|
|
|
|
this.$store.commit('SET_ACTIVE_BOARD', board);
|
|
|
|
this.$bvModal.show('edit-board');
|
|
|
|
},
|
|
|
|
|
2021-02-27 05:14:49 +00:00
|
|
|
getWallpaperUrl(url) {
|
|
|
|
if (!url) {
|
2021-02-27 05:35:08 +00:00
|
|
|
return '';
|
2021-02-27 05:14:49 +00:00
|
|
|
}
|
2020-08-28 21:56:20 +00:00
|
|
|
|
2021-02-27 05:14:49 +00:00
|
|
|
if (url && url.includes('igdb.com')) {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2021-02-27 05:35:08 +00:00
|
|
|
const wallpaperObject = this.wallpapers.find(({ fullPath }) => fullPath === url);
|
2021-02-27 05:14:49 +00:00
|
|
|
|
2021-02-27 05:35:08 +00:00
|
|
|
return wallpaperObject && wallpaperObject.url
|
2021-02-27 05:14:49 +00:00
|
|
|
? wallpaperObject.url
|
2021-02-27 05:35:08 +00:00
|
|
|
: '';
|
2020-08-28 21:56:20 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getPlatformImage(id) {
|
|
|
|
const { platformNames } = this;
|
|
|
|
|
|
|
|
return id && platformNames && platformNames[id] && platformNames[id].logoFormat
|
2021-04-04 05:48:59 +00:00
|
|
|
? `/static/logos/platforms/${platformNames[id].slug}.${platformNames[id].logoFormat}`
|
2020-08-28 21:56:20 +00:00
|
|
|
: '';
|
|
|
|
},
|
|
|
|
|
2020-08-22 12:24:24 +00:00
|
|
|
async loadPlatforms() {
|
|
|
|
await this.$store.dispatch('LOAD_IGDB_PLATFORMS')
|
|
|
|
.catch(() => {
|
2020-12-10 05:26:57 +00:00
|
|
|
this.$bvToast.toast('There was an error loading platforms', { variant: 'error' });
|
2020-08-22 12:24:24 +00:00
|
|
|
});
|
2020-11-22 05:00:17 +00:00
|
|
|
|
|
|
|
this.loadBoards();
|
2020-08-18 18:56:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
async loadBoards() {
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
await this.$store.dispatch('LOAD_BOARDS')
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false;
|
2020-09-23 23:01:39 +00:00
|
|
|
this.$store.commit('SET_SESSION_EXPIRED', true);
|
2020-08-18 18:56:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
viewBoard(id) {
|
|
|
|
this.$router.push({ name: 'board', params: { id } });
|
|
|
|
},
|
|
|
|
|
|
|
|
async deleteBoard(id) {
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
await this.$store.dispatch('DELETE_BOARD', id)
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false;
|
|
|
|
|
2020-12-10 05:26:57 +00:00
|
|
|
this.$bvToast.toast('There was an error deleting board', { variant: 'error' });
|
2020-08-18 18:56:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.loading = false;
|
2020-12-10 05:26:57 +00:00
|
|
|
this.$bvToast.toast('Board removed');
|
2020-08-18 18:56:10 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-08-26 21:23:28 +00:00
|
|
|
|
2020-12-16 21:21:23 +00:00
|
|
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
|
|
|
.boards {
|
|
|
|
display: grid;
|
|
|
|
grid-gap: 1rem;
|
2021-03-19 20:40:47 +00:00
|
|
|
grid-template-columns: repeat(auto-fit, 320px);
|
2020-08-26 21:23:28 +00:00
|
|
|
}
|
2021-02-22 02:36:54 +00:00
|
|
|
|
|
|
|
.edit-board-button {
|
|
|
|
right: .5rem;
|
|
|
|
bottom: .5rem;
|
|
|
|
}
|
2020-08-26 21:23:28 +00:00
|
|
|
</style>
|