2020-08-18 18:56:10 +00:00
|
|
|
<template lang="html">
|
2020-08-22 12:24:24 +00:00
|
|
|
<b-button
|
2021-01-05 23:27:28 +00:00
|
|
|
:variant="nightMode ? 'dark' : 'light'"
|
|
|
|
:class="buttonClass"
|
2020-08-22 12:24:24 +00:00
|
|
|
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"
|
2020-10-14 00:08:56 +00:00
|
|
|
:header-bg-variant="nightMode ? 'dark' : null"
|
|
|
|
:header-text-variant="nightMode ? 'white' : null"
|
|
|
|
:body-bg-variant="nightMode ? 'dark' : null"
|
|
|
|
:body-text-variant="nightMode ? 'white' : null"
|
2020-11-23 23:29:02 +00:00
|
|
|
hide-footer
|
|
|
|
scrollable
|
|
|
|
@show="init"
|
|
|
|
@hidden="init"
|
2020-08-18 18:56:10 +00:00
|
|
|
>
|
2020-10-14 00:35:40 +00:00
|
|
|
<template v-slot:modal-header="{ close }">
|
|
|
|
<modal-header
|
2020-10-14 21:47:02 +00:00
|
|
|
:title="$t('boards.create')"
|
2020-11-23 23:29:02 +00:00
|
|
|
:subtitle="modalSubtitle"
|
2020-10-14 21:47:02 +00:00
|
|
|
@close="close"
|
|
|
|
/>
|
2020-10-14 00:35:40 +00:00
|
|
|
</template>
|
|
|
|
|
2020-11-23 23:29:02 +00:00
|
|
|
<template v-if="activeStep === 1">
|
|
|
|
<b-form-input
|
|
|
|
v-model.trim="board.name"
|
|
|
|
class="mb-2"
|
|
|
|
placeholder="e.g. PS4 collection, Nintendo Switch, Xbox..."
|
|
|
|
autofocus
|
|
|
|
required
|
|
|
|
/>
|
2020-08-18 18:56:10 +00:00
|
|
|
|
2020-11-23 23:29:02 +00:00
|
|
|
<b-button
|
|
|
|
v-if="!showDescriptionField"
|
|
|
|
size="sm"
|
|
|
|
@click="showDescriptionField = !showDescriptionField"
|
2020-08-18 18:56:10 +00:00
|
|
|
>
|
2020-11-23 23:29:02 +00:00
|
|
|
Add description
|
|
|
|
</b-button>
|
2020-08-18 18:56:10 +00:00
|
|
|
|
2020-11-23 23:29:02 +00:00
|
|
|
<b-collapse v-model="showDescriptionField">
|
|
|
|
<b-form-group
|
|
|
|
label="Board description (optional)"
|
|
|
|
label-for="description"
|
|
|
|
>
|
|
|
|
<b-form-textarea
|
|
|
|
v-model="board.description"
|
|
|
|
maxlength="280"
|
|
|
|
rows="2"
|
|
|
|
/>
|
|
|
|
</b-form-group>
|
|
|
|
</b-collapse>
|
2020-08-26 16:28:58 +00:00
|
|
|
|
2020-11-23 23:29:02 +00:00
|
|
|
<b-button
|
|
|
|
class="d-flex ml-auto"
|
|
|
|
:variant="board.name ? 'primary' : 'secondary'"
|
|
|
|
:disabled="!board.name"
|
|
|
|
v-if="activeStep < 4"
|
|
|
|
@click="activeStep = activeStep + 1"
|
|
|
|
>
|
|
|
|
Next: choose platforms
|
|
|
|
</b-button>
|
|
|
|
</template>
|
2020-08-26 16:28:58 +00:00
|
|
|
|
2020-11-23 23:29:02 +00:00
|
|
|
<template v-if="activeStep === 2">
|
2020-12-21 18:10:15 +00:00
|
|
|
<div
|
|
|
|
v-if="board.platforms.length"
|
|
|
|
class="mb-3 d-flex justify-content-end align-items-center"
|
|
|
|
>
|
|
|
|
<b-button
|
|
|
|
variant="secondary"
|
|
|
|
@click="activeStep = activeStep + 1"
|
|
|
|
>
|
|
|
|
Optional: choose a board template
|
|
|
|
</b-button>
|
|
|
|
|
|
|
|
<span class="mx-2">or</span>
|
|
|
|
|
|
|
|
<b-button
|
|
|
|
variant="primary"
|
|
|
|
@click="createBoard"
|
|
|
|
>
|
|
|
|
<b-spinner small v-if="saving" />
|
|
|
|
<span v-else>Create board</span>
|
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
|
2020-11-23 23:29:02 +00:00
|
|
|
<platform-picker v-model="board.platforms" />
|
|
|
|
|
|
|
|
<div class="d-flex justify-content-end align-items-center">
|
|
|
|
<b-button
|
|
|
|
variant="secondary"
|
|
|
|
:disabled="!board.platforms.length"
|
|
|
|
v-if="activeStep < 4"
|
|
|
|
@click="activeStep = activeStep + 1"
|
|
|
|
>
|
|
|
|
Optional: choose a board template
|
|
|
|
</b-button>
|
|
|
|
|
|
|
|
<span class="mx-2">or</span>
|
|
|
|
|
|
|
|
<b-button
|
|
|
|
:variant="board.platforms.length ? 'primary' : 'secondary'"
|
|
|
|
:disabled="!board.platforms.length"
|
|
|
|
v-if="activeStep < 4"
|
|
|
|
@click="createBoard"
|
|
|
|
>
|
|
|
|
<b-spinner small v-if="saving" />
|
|
|
|
<span v-else>Create board</span>
|
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-if="activeStep === 3">
|
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>
|
|
|
|
|
|
|
|
<b-button
|
|
|
|
variant="primary"
|
2020-11-23 23:29:02 +00:00
|
|
|
class="d-flex ml-auto"
|
|
|
|
@click="createBoard"
|
2020-08-18 18:56:10 +00:00
|
|
|
>
|
|
|
|
<b-spinner small v-if="saving" />
|
2020-11-21 06:23:40 +00:00
|
|
|
<span v-else>Create board</span>
|
2020-08-18 18:56:10 +00:00
|
|
|
</b-button>
|
2020-11-22 03:31:18 +00:00
|
|
|
</template>
|
2020-08-18 18:56:10 +00:00
|
|
|
</b-modal>
|
|
|
|
</b-button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-08-22 18:59:58 +00:00
|
|
|
import PlatformPicker from '@/components/Board/PlatformPicker';
|
2020-10-14 00:08:56 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2020-08-22 18:59:58 +00:00
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
export default {
|
2020-08-22 18:59:58 +00:00
|
|
|
components: {
|
|
|
|
PlatformPicker,
|
|
|
|
},
|
|
|
|
|
2021-01-05 23:27:28 +00:00
|
|
|
props: {
|
|
|
|
buttonClass: String,
|
|
|
|
},
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-11-23 23:29:02 +00:00
|
|
|
board: {
|
|
|
|
name: '',
|
|
|
|
description: '',
|
|
|
|
},
|
|
|
|
activeStep: 1,
|
|
|
|
stepTitles: {
|
|
|
|
1: 'Name your board',
|
|
|
|
2: 'Game search will be limited to the platforms selected.',
|
|
|
|
3: 'Use a board template or start from scratch',
|
|
|
|
},
|
|
|
|
showDescriptionField: false,
|
2020-08-18 18:56:10 +00:00
|
|
|
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'],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2020-10-14 00:08:56 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters(['nightMode']),
|
2020-11-23 23:29:02 +00:00
|
|
|
|
|
|
|
modalSubtitle() {
|
|
|
|
return this.stepTitles[this.activeStep];
|
|
|
|
},
|
2020-10-14 00:08:56 +00:00
|
|
|
},
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
methods: {
|
2020-11-23 23:29:02 +00:00
|
|
|
init() {
|
|
|
|
this.showDescriptionField = false;
|
|
|
|
this.activeStep = 1;
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
this.board = {
|
2020-11-23 23:29:02 +00:00
|
|
|
name: '',
|
|
|
|
description: '',
|
2020-08-18 18:56:10 +00:00
|
|
|
theme: null,
|
2020-08-25 04:23:22 +00:00
|
|
|
wallpaper: null,
|
2020-08-18 18:56:10 +00:00
|
|
|
platforms: [],
|
|
|
|
lists: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2020-11-23 18:03:20 +00:00
|
|
|
createBoard() {
|
2020-08-18 18:56:10 +00:00
|
|
|
const { selectedTemplate, boardTemplates, board } = this;
|
|
|
|
|
2020-08-23 07:34:16 +00:00
|
|
|
if (board.platforms.length === 0) {
|
2020-12-10 05:26:57 +00:00
|
|
|
return this.$bvToast.toast('Please select at least 1 platform', { variant: 'error' });
|
2020-08-23 07:34:16 +00:00
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2020-11-23 23:14:34 +00:00
|
|
|
return this.$store.dispatch('CREATE_BOARD', payload)
|
2020-11-23 18:03:20 +00:00
|
|
|
.then(({ id }) => {
|
|
|
|
this.saving = false;
|
2020-12-10 05:26:57 +00:00
|
|
|
this.$bvToast.toast('Board crated');
|
2020-11-23 18:03:20 +00:00
|
|
|
this.$bvModal.hide('create-board');
|
|
|
|
this.$router.push({ name: 'board', params: { id } });
|
|
|
|
})
|
2020-08-18 18:56:10 +00:00
|
|
|
.catch(() => {
|
|
|
|
this.saving = false;
|
2020-12-10 05:26:57 +00:00
|
|
|
this.$bvToast.toast('There was an error creating board', { variant: 'error' });
|
2020-08-18 18:56:10 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|