2020-08-18 18:56:10 +00:00
|
|
|
<template lang="html">
|
|
|
|
<div class="container-fluid">
|
|
|
|
<div class="px-2 my-2 d-flex justify-content-between align-items-center">
|
|
|
|
<h5>Boards</h5>
|
|
|
|
|
|
|
|
<create-board />
|
|
|
|
</div>
|
|
|
|
|
2020-08-25 23:38:19 +00:00
|
|
|
<div class="text-right" v-if="!loading && !boards.length">
|
|
|
|
<b-img src="/static/img/empty-state.png" fluid class="mr-5" />
|
|
|
|
</div>
|
|
|
|
|
2020-08-22 12:24:24 +00:00
|
|
|
<b-overlay :show="loading && !platforms.length" rounded="sm" variant="transparent">
|
2020-08-25 23:38:19 +00:00
|
|
|
<b-row no-gutters>
|
|
|
|
<b-col cols="12" sm="6" md="4" lg="3" v-for="board in boards" :key="board.id">
|
2020-08-18 18:56:10 +00:00
|
|
|
<b-card
|
2020-08-22 12:24:24 +00:00
|
|
|
:title="board.name"
|
2020-08-18 18:56:10 +00:00
|
|
|
tag="article"
|
2020-08-26 16:32:38 +00:00
|
|
|
class="m-2 clickable"
|
2020-08-26 16:29:08 +00:00
|
|
|
@click="viewBoard(board.id)"
|
2020-08-18 18:56:10 +00:00
|
|
|
>
|
|
|
|
<b-card-text>
|
2020-08-22 12:24:24 +00:00
|
|
|
{{ board.description }}
|
2020-08-18 18:56:10 +00:00
|
|
|
</b-card-text>
|
|
|
|
|
2020-08-26 06:35:17 +00:00
|
|
|
<!-- <b-button
|
2020-08-18 18:56:10 +00:00
|
|
|
variant="danger"
|
2020-08-22 12:24:24 +00:00
|
|
|
@click="confirmDelete(board.id)"
|
2020-08-18 18:56:10 +00:00
|
|
|
>
|
|
|
|
Delete board
|
2020-08-26 06:35:17 +00:00
|
|
|
</b-button> -->
|
2020-08-22 12:24:24 +00:00
|
|
|
|
2020-08-26 16:29:08 +00:00
|
|
|
<!-- <b-button
|
2020-08-22 12:24:24 +00:00
|
|
|
variant="primary"
|
|
|
|
@click="viewBoard(board.id)"
|
|
|
|
>
|
|
|
|
Open board
|
2020-08-26 16:29:08 +00:00
|
|
|
</b-button> -->
|
2020-08-18 18:56:10 +00:00
|
|
|
</b-card>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
</b-overlay>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import CreateBoard from '@/components/Board/CreateBoard';
|
|
|
|
|
|
|
|
import { mapState } from 'vuex';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
CreateBoard,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-08-22 12:24:24 +00:00
|
|
|
...mapState(['boards', 'platforms']),
|
2020-08-18 18:56:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.load();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
load() {
|
|
|
|
this.loadBoards();
|
2020-08-22 12:24:24 +00:00
|
|
|
this.loadPlatforms();
|
|
|
|
},
|
|
|
|
|
|
|
|
// getPlatformNames(boardPlatforms) {
|
|
|
|
// const platformNames = boardPlatforms.map((platform) => {
|
|
|
|
// this.platforms.find(({ id }) => id === platform)
|
|
|
|
// console.log(platform);
|
|
|
|
// })
|
|
|
|
// },
|
|
|
|
|
|
|
|
async loadPlatforms() {
|
|
|
|
await this.$store.dispatch('LOAD_IGDB_PLATFORMS')
|
|
|
|
.catch(() => {
|
|
|
|
this.$bvToast.toast('There was an error loading platforms', { title: 'Error', variant: 'error' });
|
|
|
|
});
|
2020-08-18 18:56:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
async loadBoards() {
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
await this.$store.dispatch('LOAD_BOARDS')
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false;
|
|
|
|
this.$bvToast.toast('There was an error loading boards', { title: 'Error', variant: 'error' });
|
|
|
|
});
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
viewBoard(id) {
|
|
|
|
this.$router.push({ name: 'board', params: { id } });
|
|
|
|
},
|
|
|
|
|
|
|
|
confirmDelete(id) {
|
|
|
|
this.$bvModal.msgBoxConfirm('Are you sure you want to delete this board?', {
|
|
|
|
title: 'Delete board',
|
|
|
|
okVariant: 'danger',
|
|
|
|
okTitle: 'Yes, delete board',
|
|
|
|
})
|
|
|
|
.then((value) => {
|
|
|
|
if (value) {
|
|
|
|
this.deleteBoard(id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async deleteBoard(id) {
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
await this.$store.dispatch('DELETE_BOARD', id)
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
this.$bvToast.toast('There was an error deleting board', { title: 'Error', variant: 'error' });
|
|
|
|
});
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
this.$bvToast.toast('Board removed', { title: 'Success', variant: 'success' });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|