2020-08-15 00:02:34 +00:00
|
|
|
<template lang="html">
|
2020-08-25 04:23:22 +00:00
|
|
|
<b-button
|
|
|
|
v-b-modal:board-settings
|
|
|
|
class="mt-3"
|
|
|
|
ref="addList"
|
|
|
|
>
|
|
|
|
<b-icon-gear-fill />
|
2020-08-15 00:02:34 +00:00
|
|
|
|
|
|
|
<b-modal
|
|
|
|
id="board-settings"
|
|
|
|
title="Board settings"
|
2020-08-25 04:23:22 +00:00
|
|
|
scrollable
|
|
|
|
@show="init"
|
2020-08-25 23:37:33 +00:00
|
|
|
@hide="hide"
|
2020-08-15 00:02:34 +00:00
|
|
|
>
|
2020-08-25 04:23:22 +00:00
|
|
|
<form ref="boardSettingsForm" @submit.stop.prevent="submit">
|
|
|
|
<b-form-group
|
|
|
|
label="Board name"
|
|
|
|
label-for="name"
|
|
|
|
>
|
|
|
|
<b-form-input
|
|
|
|
id="name"
|
|
|
|
v-model="name"
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
</b-form-group>
|
2020-08-15 00:02:34 +00:00
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
<b-form-group
|
2020-08-25 23:37:33 +00:00
|
|
|
label="Board description"
|
2020-08-25 04:23:22 +00:00
|
|
|
label-for="description"
|
|
|
|
>
|
|
|
|
<b-form-textarea
|
|
|
|
id="description"
|
|
|
|
v-model="description"
|
|
|
|
maxlength="280"
|
|
|
|
rows="3"
|
|
|
|
/>
|
|
|
|
</b-form-group>
|
2020-08-15 00:02:34 +00:00
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
<b-form-group
|
|
|
|
label="Board theme"
|
|
|
|
label-for="theme"
|
|
|
|
>
|
2020-08-15 00:02:34 +00:00
|
|
|
<b-form-select
|
|
|
|
id="theme"
|
2020-08-25 06:34:28 +00:00
|
|
|
disabled
|
2020-08-25 04:23:22 +00:00
|
|
|
v-model="theme"
|
2020-08-15 00:02:34 +00:00
|
|
|
>
|
|
|
|
<b-form-select-option
|
|
|
|
v-for="{ id, name } in themes"
|
|
|
|
:key="id"
|
|
|
|
:value="id"
|
|
|
|
>
|
|
|
|
{{ name }}
|
|
|
|
</b-form-select-option>
|
|
|
|
</b-form-select>
|
2020-08-25 04:23:22 +00:00
|
|
|
</b-form-group>
|
|
|
|
|
|
|
|
<b-form-group
|
2020-08-25 06:34:28 +00:00
|
|
|
v-if="wallpapers.length"
|
2020-08-25 04:23:22 +00:00
|
|
|
label="Board wallpaper"
|
|
|
|
label-for="wallpaper"
|
|
|
|
>
|
|
|
|
<b-dropdown
|
|
|
|
id="wallpaper"
|
|
|
|
text="Select wallpaper"
|
|
|
|
boundary="viewport"
|
|
|
|
>
|
|
|
|
<b-dropdown-item variant="danger" v-if="wallpaper" @click="removeWallpaper">
|
|
|
|
Remove wallpaper
|
|
|
|
</b-dropdown-item>
|
|
|
|
<b-dropdown-item
|
|
|
|
v-for="file in wallpapers"
|
|
|
|
:key="file.name"
|
2020-08-26 00:06:49 +00:00
|
|
|
@click="setWallpaper(file.url)"
|
2020-08-25 04:23:22 +00:00
|
|
|
>
|
|
|
|
<b-img
|
|
|
|
thumbnail
|
|
|
|
:src="file.url"
|
|
|
|
:alt="file.name"
|
|
|
|
fluid
|
|
|
|
/>
|
|
|
|
</b-dropdown-item>
|
|
|
|
</b-dropdown>
|
|
|
|
</b-form-group>
|
|
|
|
|
2020-08-25 06:34:28 +00:00
|
|
|
<div v-else>
|
|
|
|
No wallpapers uploaded yet.
|
|
|
|
<b-button v-b-modal:file-settings>Manage files</b-button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
<b-img
|
|
|
|
v-if="wallpaper"
|
|
|
|
thumbnail
|
2020-08-25 06:34:28 +00:00
|
|
|
class="mb-3"
|
2020-08-26 00:06:49 +00:00
|
|
|
:src="wallpaper"
|
2020-08-25 04:23:22 +00:00
|
|
|
fluid
|
|
|
|
/>
|
2020-08-15 00:02:34 +00:00
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
<platform-picker
|
|
|
|
v-model="board.platforms"
|
|
|
|
/>
|
|
|
|
</form>
|
2020-08-15 06:40:27 +00:00
|
|
|
|
|
|
|
<template v-slot:modal-footer>
|
|
|
|
<b-button
|
|
|
|
variant="danger"
|
2020-08-25 04:23:22 +00:00
|
|
|
@click="confirmDelete"
|
2020-08-15 06:40:27 +00:00
|
|
|
>
|
|
|
|
Delete board
|
|
|
|
</b-button>
|
2020-08-25 04:23:22 +00:00
|
|
|
|
|
|
|
<b-button
|
|
|
|
variant="primary"
|
|
|
|
:disabled="saving"
|
|
|
|
@click="saveSettings"
|
|
|
|
>
|
|
|
|
<b-spinner small v-if="saving" />
|
|
|
|
<span v-else>Save</span>
|
|
|
|
</b-button>
|
2020-08-15 06:40:27 +00:00
|
|
|
</template>
|
2020-08-15 00:02:34 +00:00
|
|
|
</b-modal>
|
2020-08-25 04:23:22 +00:00
|
|
|
</b-button>
|
2020-08-15 00:02:34 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapState } from 'vuex';
|
|
|
|
import themes from '@/themes';
|
2020-08-25 04:23:22 +00:00
|
|
|
import PlatformPicker from '@/components/Board/PlatformPicker';
|
2020-08-15 00:02:34 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-08-25 04:23:22 +00:00
|
|
|
PlatformPicker,
|
2020-08-15 00:02:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
themes,
|
|
|
|
saving: false,
|
2020-08-25 04:23:22 +00:00
|
|
|
description: null,
|
|
|
|
name: null,
|
|
|
|
platforms: null,
|
|
|
|
theme: null,
|
|
|
|
wallpaper: null,
|
2020-08-15 00:02:34 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-08-26 00:06:49 +00:00
|
|
|
...mapState(['board', 'user', 'wallpapers']),
|
2020-08-15 00:02:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-08-25 23:37:33 +00:00
|
|
|
hide() {
|
|
|
|
this.$bus.$off('WALLPAPER_UPLOADED', this.loadWallpapers);
|
|
|
|
},
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
async loadWallpapers() {
|
2020-08-26 00:06:49 +00:00
|
|
|
await this.$store.dispatch('LOAD_WALLPAPERS')
|
|
|
|
.catch(() => {
|
|
|
|
this.$bvToast.toast('There was an error loading wallpapers', { title: 'Error', variant: 'danger' });
|
|
|
|
});
|
2020-08-25 04:23:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
removeWallpaper() {
|
|
|
|
this.wallpaper = null;
|
2020-08-15 00:02:34 +00:00
|
|
|
},
|
|
|
|
|
2020-08-26 00:06:49 +00:00
|
|
|
async setWallpaper(url) {
|
|
|
|
this.wallpaper = url;
|
2020-08-25 04:23:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
submit(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2020-08-26 00:06:49 +00:00
|
|
|
if (this.$refs.boardSettingsForm.checkValidity()) {
|
|
|
|
this.saveSettings();
|
2020-08-25 04:23:22 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
async init() {
|
2020-08-25 23:37:33 +00:00
|
|
|
this.$bus.$on('WALLPAPER_UPLOADED', this.loadWallpapers);
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
const { board } = this;
|
|
|
|
|
|
|
|
this.description = board.description;
|
|
|
|
this.name = board.name;
|
|
|
|
this.platforms = board.platforms;
|
|
|
|
this.theme = board.theme || 'default';
|
|
|
|
this.wallpaper = board.wallpaper;
|
|
|
|
|
|
|
|
this.loadWallpapers();
|
|
|
|
},
|
|
|
|
|
|
|
|
confirmDelete() {
|
|
|
|
this.$bvModal.msgBoxConfirm('Are you sure you want to delete this board?', {
|
|
|
|
title: 'Delete board',
|
2020-08-15 00:02:34 +00:00
|
|
|
okVariant: 'danger',
|
2020-08-25 04:23:22 +00:00
|
|
|
okTitle: 'Yes, delete board',
|
2020-08-15 00:02:34 +00:00
|
|
|
})
|
|
|
|
.then((value) => {
|
|
|
|
if (value) {
|
|
|
|
this.deleteBoard();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
async deleteBoard() {
|
|
|
|
this.loading = true;
|
2020-08-15 00:02:34 +00:00
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
await this.$store.dispatch('DELETE_BOARD', this.board.id)
|
2020-08-15 00:02:34 +00:00
|
|
|
.catch(() => {
|
2020-08-25 04:23:22 +00:00
|
|
|
this.loading = false;
|
|
|
|
this.$bvToast.toast('There was an error deleting board', { title: 'Error', variant: 'error' });
|
2020-08-15 00:02:34 +00:00
|
|
|
});
|
2020-08-25 04:23:22 +00:00
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
this.$bvToast.toast('Board removed', { title: 'Success', variant: 'success' });
|
|
|
|
this.$router.push({ name: 'home' });
|
2020-08-15 00:02:34 +00:00
|
|
|
},
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
async saveSettings() {
|
|
|
|
this.saving = true;
|
|
|
|
const wallpaperChanged = this.board.wallpaper !== this.wallpaper;
|
|
|
|
|
|
|
|
const { board } = this;
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
...board,
|
|
|
|
description: this.description,
|
|
|
|
name: this.name,
|
|
|
|
platforms: this.platforms,
|
|
|
|
theme: this.theme,
|
|
|
|
wallpaper: this.wallpaper,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$store.commit('SET_BOARD', payload);
|
|
|
|
|
|
|
|
await this.$store.dispatch('SAVE_BOARD')
|
|
|
|
.catch(() => {
|
|
|
|
this.saving = false;
|
|
|
|
|
|
|
|
this.$bvToast.toast('There was an error renaming list', { title: 'Error', variant: 'danger' });
|
|
|
|
});
|
|
|
|
|
|
|
|
this.saving = false;
|
|
|
|
this.$bvToast.toast('Board settings saved', { title: 'Saved', variant: 'success' });
|
|
|
|
this.$bvModal.hide('board-settings');
|
|
|
|
|
|
|
|
if (wallpaperChanged) {
|
|
|
|
this.$bus.$emit('RELOAD_WALLPAPER');
|
|
|
|
}
|
|
|
|
},
|
2020-08-15 00:02:34 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
<style lang="scss" rel="stylesheet/scss">
|
|
|
|
.dropdown-menu {
|
|
|
|
max-height: 400px;
|
|
|
|
max-width: 360px;
|
|
|
|
overflow: auto;
|
|
|
|
}
|
2020-08-15 00:02:34 +00:00
|
|
|
</style>
|