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
|
2020-09-24 04:15:31 +00:00
|
|
|
v-b-tooltip.hover.left
|
|
|
|
title="Board settings"
|
2020-08-25 04:23:22 +00:00
|
|
|
class="mt-3"
|
2020-10-14 00:36:41 +00:00
|
|
|
variant="primary"
|
2020-10-08 17:55:26 +00:00
|
|
|
size="sm"
|
2020-08-25 04:23:22 +00:00
|
|
|
ref="addList"
|
|
|
|
>
|
2020-10-08 17:55:26 +00:00
|
|
|
<icon name="gear" white />
|
2020-08-15 00:02:34 +00:00
|
|
|
|
|
|
|
<b-modal
|
|
|
|
id="board-settings"
|
2020-08-26 17:34:23 +00:00
|
|
|
size="lg"
|
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"
|
|
|
|
:footer-bg-variant="nightMode ? 'dark' : null"
|
|
|
|
:footer-text-variant="nightMode ? 'white' : null"
|
2020-10-14 21:48:27 +00:00
|
|
|
footer-class="d-flex justify-content-between"
|
2020-08-25 04:23:22 +00:00
|
|
|
@show="init"
|
2020-08-25 23:37:33 +00:00
|
|
|
@hide="hide"
|
2020-08-15 00:02:34 +00:00
|
|
|
>
|
2020-10-14 00:36:41 +00:00
|
|
|
<template v-slot:modal-header="{ close }">
|
|
|
|
<modal-header
|
2020-10-14 21:48:27 +00:00
|
|
|
:title="$t('board.settings.title')"
|
|
|
|
@close="close"
|
|
|
|
/>
|
2020-10-14 00:36:41 +00:00
|
|
|
</template>
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
<form ref="boardSettingsForm" @submit.stop.prevent="submit">
|
|
|
|
<b-form-group
|
2020-10-14 21:48:27 +00:00
|
|
|
:label="$t('board.settings.nameLabel')"
|
2020-08-25 04:23:22 +00:00
|
|
|
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-10-14 21:48:27 +00:00
|
|
|
:label="$t('board.settings.descriptionLabel')"
|
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-31 21:38:40 +00:00
|
|
|
<!-- <b-form-group
|
2020-08-25 04:23:22 +00:00
|
|
|
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-31 21:38:40 +00:00
|
|
|
</b-form-group> -->
|
2020-08-25 04:23:22 +00:00
|
|
|
|
|
|
|
<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"
|
|
|
|
>
|
2020-08-31 21:35:22 +00:00
|
|
|
<b-dropdown-item
|
|
|
|
variant="danger"
|
|
|
|
v-if="wallpaper"
|
|
|
|
@click="removeWallpaper"
|
|
|
|
>
|
2020-10-14 21:48:27 +00:00
|
|
|
{{ $t('board.settings.removeWallpaper') }}
|
2020-08-25 04:23:22 +00:00
|
|
|
</b-dropdown-item>
|
2020-08-31 21:35:22 +00:00
|
|
|
|
|
|
|
<b-dropdown-item
|
|
|
|
variant="primary"
|
|
|
|
v-b-modal:wallpapers
|
|
|
|
>
|
2020-10-14 21:48:27 +00:00
|
|
|
{{ $t('board.settings.uploadWallpaper') }}
|
2020-08-31 21:35:22 +00:00
|
|
|
</b-dropdown-item>
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
<b-dropdown-item
|
|
|
|
v-for="file in wallpapers"
|
|
|
|
:key="file.name"
|
2020-08-26 15:47:12 +00:00
|
|
|
@click="setWallpaper(file.fullPath)"
|
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>
|
2020-10-14 21:48:27 +00:00
|
|
|
{{ $t('board.settings.noWallpapers') }}
|
2020-08-25 06:34:28 +00:00
|
|
|
|
2020-10-14 21:48:27 +00:00
|
|
|
<b-button v-b-modal:wallpapers>
|
|
|
|
{{ $t('board.settings.managefiles') }}
|
|
|
|
</b-button>
|
|
|
|
</div>
|
2020-08-25 06:34:28 +00:00
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
<b-img
|
2020-08-26 16:13:04 +00:00
|
|
|
v-if="wallpaper && wallpaperUrl"
|
2020-08-25 04:23:22 +00:00
|
|
|
thumbnail
|
2020-08-25 06:34:28 +00:00
|
|
|
class="mb-3"
|
2020-08-26 16:13:04 +00:00
|
|
|
:src="wallpaperUrl"
|
2020-08-25 04:23:22 +00:00
|
|
|
fluid
|
|
|
|
/>
|
2020-08-15 00:02:34 +00:00
|
|
|
|
2020-10-14 21:48:27 +00:00
|
|
|
<b-button v-b-toggle.platforms>
|
|
|
|
{{ $t('board.settings.changePlatform') }}
|
|
|
|
</b-button>
|
2020-08-31 21:38:31 +00:00
|
|
|
|
|
|
|
<b-collapse id="platforms" class="mt-2">
|
|
|
|
<platform-picker v-model="board.platforms" />
|
|
|
|
</b-collapse>
|
2020-08-25 04:23:22 +00:00
|
|
|
</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
|
|
|
>
|
2020-10-14 21:48:27 +00:00
|
|
|
{{ $t('board.settings.deleteBoard') }}
|
2020-08-15 06:40:27 +00:00
|
|
|
</b-button>
|
2020-08-25 04:23:22 +00:00
|
|
|
|
|
|
|
<b-button
|
|
|
|
variant="primary"
|
|
|
|
:disabled="saving"
|
|
|
|
@click="saveSettings"
|
|
|
|
>
|
|
|
|
<b-spinner small v-if="saving" />
|
2020-10-14 21:48:27 +00:00
|
|
|
<span v-else>{{ $t('global.save') }}</span>
|
2020-08-25 04:23:22 +00:00
|
|
|
</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>
|
2020-10-14 00:08:56 +00:00
|
|
|
import { mapState, mapGetters } from 'vuex';
|
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 {
|
|
|
|
saving: false,
|
2020-08-25 04:23:22 +00:00
|
|
|
description: null,
|
|
|
|
name: null,
|
|
|
|
platforms: null,
|
|
|
|
theme: null,
|
|
|
|
wallpaper: null,
|
2020-08-26 16:13:04 +00:00
|
|
|
wallpaperUrl: null,
|
2020-08-15 00:02:34 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-08-26 00:06:49 +00:00
|
|
|
...mapState(['board', 'user', 'wallpapers']),
|
2020-10-14 00:08:56 +00:00
|
|
|
...mapGetters(['nightMode']),
|
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 15:47:12 +00:00
|
|
|
async setWallpaper(wallpaper) {
|
2020-08-26 16:13:04 +00:00
|
|
|
this.wallpaper = wallpaper;
|
|
|
|
this.wallpaperUrl = await this.$store.dispatch('LOAD_WALLPAPER', wallpaper);
|
|
|
|
this.$bus.$emit('RELOAD_WALLPAPER');
|
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;
|
|
|
|
|
2020-08-26 16:13:04 +00:00
|
|
|
if (this.wallpaper) {
|
|
|
|
this.wallpaperUrl = await this.$store.dispatch('LOAD_WALLPAPER', this.wallpaper);
|
|
|
|
}
|
2020-08-25 04:23:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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' });
|
2020-09-28 23:26:19 +00:00
|
|
|
this.$router.push({ name: 'dashboard' });
|
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);
|
|
|
|
|
2020-09-01 17:43:48 +00:00
|
|
|
if (board.name !== this.name) {
|
|
|
|
this.$store.commit('UPDATE_BOARD_NAME', payload);
|
|
|
|
}
|
|
|
|
|
2020-08-25 04:23:22 +00:00
|
|
|
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>
|