aboutsummaryrefslogtreecommitdiff
path: root/src/site/components/image-modal/AlbumInfo.vue
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2020-07-20 23:01:45 +0300
committerZephyrrus <[email protected]>2020-07-20 23:01:45 +0300
commit18bb451f793677a5bbfdc2c14128bae33c66dfde (patch)
tree12e5e02d793b11bfac3dafd5078a1f0b2464d6ce /src/site/components/image-modal/AlbumInfo.vue
parentfix: return the edited/changed/delete entity from API (diff)
downloadhost.fuwn.me-18bb451f793677a5bbfdc2c14128bae33c66dfde.tar.xz
host.fuwn.me-18bb451f793677a5bbfdc2c14128bae33c66dfde.zip
feat: implement all-in-one file detail viewer, tag editor and album selection modal
Diffstat (limited to 'src/site/components/image-modal/AlbumInfo.vue')
-rw-r--r--src/site/components/image-modal/AlbumInfo.vue73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/site/components/image-modal/AlbumInfo.vue b/src/site/components/image-modal/AlbumInfo.vue
new file mode 100644
index 0000000..9d57e55
--- /dev/null
+++ b/src/site/components/image-modal/AlbumInfo.vue
@@ -0,0 +1,73 @@
+<template>
+ <b-dropdown
+ v-model="selectedOptions"
+ multiple
+ expanded
+ scrollable
+ inline
+ aria-role="list"
+ max-height="500px">
+ <button slot="trigger" class="button is-primary" type="button">
+ <span>Albums ({{ selectedOptions.length }})</span>
+ <b-icon icon="menu-down" />
+ </button>
+
+ <b-dropdown-item
+ v-for="album in albums"
+ :key="album.id"
+ :value="album.id"
+ aria-role="listitem"
+ @click="handleClick(album.id)">
+ <span>{{ album. name }}</span>
+ </b-dropdown-item>
+ </b-dropdown>
+</template>
+
+<script>
+import { mapState } from 'vuex';
+
+export default {
+ name: 'Albuminfo',
+ props: {
+ imageId: {
+ type: Number,
+ default: 0,
+ },
+ imageAlbums: {
+ type: Array,
+ default: () => [],
+ },
+ },
+ data() {
+ return {
+ selectedOptions: this.imageAlbums.map((e) => e.id),
+ };
+ },
+ computed: {
+ ...mapState({
+ albums: (state) => state.albums.tinyDetails,
+ }),
+ },
+ methods: {
+ isAlbumSelected(id) {
+ if (!this.showingModalForFile) return false;
+ const found = this.showingModalForFile.albums.find((el) => el.id === id);
+ return !!(found && found.id);
+ },
+ async handleClick(id) {
+ // here the album should be already removed from the selected list
+ if (this.selectedOptions.indexOf(id) > -1) {
+ this.$handler.executeAction('images/addToAlbum', {
+ albumId: id,
+ fileId: this.imageId,
+ });
+ } else {
+ this.$handler.executeAction('images/removeFromAlbum', {
+ albumId: id,
+ fileId: this.imageId,
+ });
+ }
+ },
+ },
+};
+</script>