2020-08-18 18:56:10 +00:00
|
|
|
<template lang="html">
|
2020-08-22 12:24:24 +00:00
|
|
|
<b-button
|
|
|
|
variant="primary"
|
|
|
|
v-b-modal:create-board
|
|
|
|
>
|
2020-10-05 18:42:04 +00:00
|
|
|
{{ $t('boards.create') }}
|
2020-08-18 18:56:10 +00:00
|
|
|
|
|
|
|
<b-modal
|
|
|
|
id="create-board"
|
|
|
|
title="Create board"
|
2020-08-22 18:59:58 +00:00
|
|
|
size="lg"
|
2020-08-22 12:24:24 +00:00
|
|
|
@show="resetBoard"
|
2020-08-18 18:56:10 +00:00
|
|
|
@hidden="resetBoard"
|
|
|
|
>
|
|
|
|
<form ref="createBoardForm" @submit.stop.prevent="submit">
|
|
|
|
<b-form-group
|
|
|
|
label="Board name"
|
|
|
|
label-for="name"
|
|
|
|
>
|
|
|
|
<b-form-input
|
|
|
|
id="name"
|
|
|
|
v-model="board.name"
|
2020-08-25 04:23:22 +00:00
|
|
|
autofocus
|
2020-08-18 18:56:10 +00:00
|
|
|
required
|
|
|
|
/>
|
|
|
|
</b-form-group>
|
|
|
|
|
|
|
|
<b-form-group
|
2020-08-25 06:26:10 +00:00
|
|
|
label="Board description"
|
2020-08-18 18:56:10 +00:00
|
|
|
label-for="description"
|
|
|
|
description="Optional"
|
|
|
|
>
|
|
|
|
<b-form-textarea
|
|
|
|
v-model="board.description"
|
|
|
|
maxlength="280"
|
2020-08-26 16:28:58 +00:00
|
|
|
rows="2"
|
2020-08-18 18:56:10 +00:00
|
|
|
/>
|
|
|
|
</b-form-group>
|
|
|
|
|
2020-08-26 16:28:58 +00:00
|
|
|
<platform-picker
|
|
|
|
v-model="board.platforms"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<hr />
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
<b-form-group label="Board template">
|
|
|
|
<b-form-radio-group
|
|
|
|
v-model="selectedTemplate"
|
|
|
|
:options="boardTemplatesOptions"
|
|
|
|
buttons
|
|
|
|
name="radios-btn-default"
|
|
|
|
description="Optional"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<b-row v-if="selectedTemplate" class="mt-3">
|
|
|
|
<b-col v-for="column in boardTemplates[selectedTemplate]" :key="column">
|
|
|
|
<b-card
|
|
|
|
:header="column"
|
|
|
|
header-tag="header"
|
|
|
|
header-class="p-1 pl-2"
|
|
|
|
hide-footer
|
|
|
|
/>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
</b-form-group>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<template v-slot:modal-footer="{ cancel }">
|
|
|
|
<b-button @click="cancel">
|
|
|
|
Cancel
|
|
|
|
</b-button>
|
|
|
|
|
|
|
|
<b-button
|
|
|
|
variant="primary"
|
2020-08-25 04:23:22 +00:00
|
|
|
:disabled="saving"
|
2020-08-18 18:56:10 +00:00
|
|
|
@click="submit"
|
|
|
|
>
|
|
|
|
<b-spinner small v-if="saving" />
|
|
|
|
<span v-else>Save</span>
|
|
|
|
</b-button>
|
|
|
|
</template>
|
|
|
|
</b-modal>
|
|
|
|
</b-button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-08-22 18:59:58 +00:00
|
|
|
import PlatformPicker from '@/components/Board/PlatformPicker';
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
export default {
|
2020-08-22 18:59:58 +00:00
|
|
|
components: {
|
|
|
|
PlatformPicker,
|
|
|
|
},
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
board: {},
|
|
|
|
platformCategories: {
|
|
|
|
1: 'console',
|
|
|
|
2: 'arcade',
|
|
|
|
3: 'platform',
|
|
|
|
4: 'operating_system',
|
|
|
|
5: 'portable_console',
|
|
|
|
6: 'computer',
|
|
|
|
},
|
|
|
|
saving: false,
|
|
|
|
selectedTemplate: null,
|
|
|
|
boardTemplatesOptions: [
|
|
|
|
{ value: null, text: 'Blank' },
|
|
|
|
{ value: 'standard', text: 'Standard' },
|
|
|
|
{ value: 'detailed', text: 'Detailed' },
|
|
|
|
{ value: 'completionist', text: 'Completionist' },
|
|
|
|
],
|
|
|
|
boardTemplates: {
|
|
|
|
standard: ['Owned', 'Wishlist'],
|
|
|
|
detailed: ['Physical', 'Digital', 'Wishlist'],
|
|
|
|
completionist: ['Owned', 'Playing', 'Completed'],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
resetBoard() {
|
|
|
|
this.board = {
|
|
|
|
name: null,
|
|
|
|
description: null,
|
|
|
|
theme: null,
|
2020-08-25 04:23:22 +00:00
|
|
|
wallpaper: null,
|
2020-08-18 18:56:10 +00:00
|
|
|
platforms: [],
|
|
|
|
lists: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
submit(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if (this.$refs.createBoardForm.checkValidity()) {
|
|
|
|
this.createBoard();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
async createBoard() {
|
|
|
|
const { selectedTemplate, boardTemplates, board } = this;
|
|
|
|
|
2020-08-23 07:34:16 +00:00
|
|
|
if (board.platforms.length === 0) {
|
|
|
|
return this.$bvToast.toast('Please select at least 1 platform', { title: 'Error', variant: 'error' });
|
|
|
|
}
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
this.saving = true;
|
|
|
|
|
|
|
|
const lists = selectedTemplate && boardTemplates[selectedTemplate]
|
|
|
|
? boardTemplates[selectedTemplate].map((name) => {
|
|
|
|
const list = {
|
|
|
|
name,
|
|
|
|
games: [],
|
|
|
|
settings: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
return list;
|
|
|
|
})
|
2020-08-25 06:21:44 +00:00
|
|
|
: [{
|
|
|
|
name: 'List name here',
|
|
|
|
games: [],
|
|
|
|
settings: {},
|
|
|
|
}];
|
2020-08-18 18:56:10 +00:00
|
|
|
|
|
|
|
const payload = {
|
|
|
|
...board,
|
|
|
|
lists,
|
|
|
|
};
|
|
|
|
|
|
|
|
await this.$store.dispatch('CREATE_BOARD', payload)
|
|
|
|
.catch(() => {
|
|
|
|
this.saving = false;
|
2020-08-23 07:34:16 +00:00
|
|
|
this.$bvToast.toast('There was an error creating board', { title: 'Error', variant: 'error' });
|
2020-08-18 18:56:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.saving = false;
|
|
|
|
this.$bvToast.toast('Board crated', { title: 'Success', variant: 'success' });
|
2020-08-24 16:44:45 +00:00
|
|
|
return this.$bvModal.hide('create-board');
|
2020-08-18 18:56:10 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|