Allow adding bookmarks to folders

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-09-24 00:05:33 +02:00
commit 89fbaa159f
8 changed files with 99 additions and 5 deletions

View file

@ -0,0 +1,40 @@
import { library } from '@fortawesome/fontawesome-svg-core'
import { faChevronRight } from '@fortawesome/free-solid-svg-icons'
import { mapState } from 'vuex'
import DialogModal from '../dialog_modal/dialog_modal.vue'
import Popover from '../popover/popover.vue'
library.add(faChevronRight)
const StatusBookmarkFolderMenu = {
props: [
'status'
],
data () {
return {}
},
components: {
DialogModal,
Popover
},
computed: {
...mapState({
folders: state => state.bookmarkFolders.allFolders
}),
folderId () {
return this.status.bookmark_folder_id
}
},
methods: {
toggleFolder (id) {
const value = id === this.folderId ? null : id
this.$store.dispatch('bookmark', { id: this.status.id, bookmark_folder_id: value })
.then(() => this.$emit('onSuccess'))
.catch(err => this.$emit('onError', err.error.error))
}
}
}
export default StatusBookmarkFolderMenu

View file

@ -0,0 +1,38 @@
<template>
<div class="StatusBookmarkFolderMenu">
<Popover
trigger="hover"
placement="left"
remove-padding
>
<template #content>
<div class="dropdown-menu">
<button
v-for="folder in folders"
:key="folder.id"
class="menu-item dropdown-item"
@click="toggleFolder(folder.id)"
>
<span
class="input menu-checkbox -radio"
:class="{ 'menu-checkbox-checked': status.bookmark_folder_id == folder.id }"
/>
{{ folder.name }}
</button>
</div>
</template>
<template #trigger>
<button class="menu-item dropdown-item -has-submenu">
{{ $t('bookmark_folders.select_folder') }}
<FAIcon
class="chevron-icon"
size="lg"
icon="chevron-right"
/>
</button>
</template>
</Popover>
</div>
</template>
<script src="./status_bookmark_folder_menu.js"></script>