2021-09-29 00:36:41 +02:00
|
|
|
<template>
|
|
|
|
<div class="relative">
|
2024-06-03 08:04:03 +02:00
|
|
|
<div ref="shelf" class="w-full max-w-full bookshelf-row categorizedBookshelfRow relative overflow-x-scroll no-scroll overflow-y-hidden z-10" :style="{ paddingLeft: paddingLeft + 'em' }" @scroll="scrolled">
|
2024-06-23 18:15:39 +02:00
|
|
|
<div class="w-full h-full pt-6e">
|
2022-03-26 23:41:26 +01:00
|
|
|
<div v-if="shelf.type === 'book' || shelf.type === 'podcast'" class="flex items-center">
|
2021-12-18 03:52:11 +01:00
|
|
|
<template v-for="(entity, index) in shelf.entities">
|
2024-06-23 18:15:39 +02:00
|
|
|
<cards-lazy-book-card :key="entity.id" :ref="`shelf-book-${entity.id}`" :index="index" :book-mount="entity" :continue-listening-shelf="continueListeningShelf" class="relative mx-2e" @hook:updated="updatedBookCard" @select="selectItem" @edit="editItem" />
|
2021-09-29 00:36:41 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
2022-04-23 02:31:11 +02:00
|
|
|
<div v-if="shelf.type === 'episode'" class="flex items-center">
|
|
|
|
<template v-for="(entity, index) in shelf.entities">
|
2024-06-23 18:15:39 +02:00
|
|
|
<cards-lazy-book-card :key="entity.recentEpisode.id" :ref="`shelf-episode-${entity.recentEpisode.id}`" :index="index" :book-mount="entity" :continue-listening-shelf="continueListeningShelf" class="relative mx-2e" @hook:updated="updatedBookCard" @select="selectItem" @editPodcast="editItem" @edit="editEpisode" />
|
2022-04-23 02:31:11 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
2021-12-18 03:52:11 +01:00
|
|
|
<div v-if="shelf.type === 'series'" class="flex items-center">
|
2021-12-01 03:02:40 +01:00
|
|
|
<template v-for="entity in shelf.entities">
|
2024-06-23 18:15:39 +02:00
|
|
|
<cards-lazy-series-card :key="entity.name" :series-mount="entity" class="relative mx-2e" @hook:updated="updatedBookCard" />
|
2021-12-01 03:02:40 +01:00
|
|
|
</template>
|
|
|
|
</div>
|
2022-08-23 23:07:53 +02:00
|
|
|
<div v-if="shelf.type === 'tags'" class="flex items-center">
|
|
|
|
<template v-for="entity in shelf.entities">
|
2024-06-23 18:15:39 +02:00
|
|
|
<cards-group-card :key="entity.name" :group="entity" class="relative mx-2e" @hook:updated="updatedBookCard" />
|
2022-08-23 23:07:53 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
2021-12-18 03:52:11 +01:00
|
|
|
<div v-if="shelf.type === 'authors'" class="flex items-center">
|
2021-12-03 02:02:38 +01:00
|
|
|
<template v-for="entity in shelf.entities">
|
2024-10-06 17:25:08 +02:00
|
|
|
<cards-author-card :key="entity.id" :authorMount="entity" @hook:updated="updatedBookCard" class="mx-2e" @edit="editAuthor" />
|
2021-10-17 18:29:52 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
2023-04-25 01:25:30 +02:00
|
|
|
<div v-if="shelf.type === 'narrators'" class="flex items-center">
|
|
|
|
<template v-for="entity in shelf.entities">
|
2024-06-23 18:15:39 +02:00
|
|
|
<cards-narrator-card :key="entity.name" :narrator="entity" @hook:updated="updatedBookCard" class="mx-2e" />
|
2023-04-25 01:25:30 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
2021-09-29 00:36:41 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-06-03 08:04:03 +02:00
|
|
|
<div class="relative">
|
2024-06-23 18:15:39 +02:00
|
|
|
<div class="relative text-center categoryPlacard transform z-30 top-0 left-4e md:left-8e w-44e rounded-md">
|
2024-06-03 08:04:03 +02:00
|
|
|
<div class="w-full h-full shinyBlack flex items-center justify-center rounded-sm border" :style="{ padding: `0em 0.5em` }">
|
|
|
|
<p :style="{ fontSize: 0.9 + 'em' }">{{ $strings[shelf.labelStringKey] }}</p>
|
|
|
|
</div>
|
2021-09-29 00:36:41 +02:00
|
|
|
</div>
|
|
|
|
|
2024-06-23 18:15:39 +02:00
|
|
|
<div class="bookshelfDividerCategorized h-6e w-full absolute top-0 left-0 right-0 z-20"></div>
|
2024-06-03 08:04:03 +02:00
|
|
|
</div>
|
|
|
|
<div v-show="canScrollLeft && !isScrolling" class="hidden sm:flex absolute top-0 left-0 w-32 pr-8 bg-black book-shelf-arrow-left items-center justify-center cursor-pointer opacity-0 hover:opacity-100 z-40" @click="scrollLeft">
|
2024-07-08 18:36:37 +02:00
|
|
|
<span class="material-symbols text-white" :style="{ fontSize: 3.75 + 'em' }">chevron_left</span>
|
2021-09-29 00:36:41 +02:00
|
|
|
</div>
|
2024-06-03 08:04:03 +02:00
|
|
|
<div v-show="canScrollRight && !isScrolling" class="hidden sm:flex absolute top-0 right-0 w-32 pl-8 bg-black book-shelf-arrow-right items-center justify-center cursor-pointer opacity-0 hover:opacity-100 z-40" @click="scrollRight">
|
2024-07-08 18:36:37 +02:00
|
|
|
<span class="material-symbols text-white" :style="{ fontSize: 3.75 + 'em' }">chevron_right</span>
|
2021-09-29 00:36:41 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
index: Number,
|
|
|
|
shelf: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
|
|
|
},
|
2022-09-29 00:45:39 +02:00
|
|
|
continueListeningShelf: Boolean
|
2021-09-29 00:36:41 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
canScrollRight: false,
|
|
|
|
canScrollLeft: false,
|
|
|
|
isScrolling: false,
|
|
|
|
scrollTimer: null,
|
2022-05-10 01:23:23 +02:00
|
|
|
updateTimer: null
|
2021-09-29 00:36:41 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2024-06-03 08:04:03 +02:00
|
|
|
sizeMultiplier() {
|
|
|
|
return this.$store.getters['user/getSizeMultiplier']
|
2021-12-18 03:52:11 +01:00
|
|
|
},
|
2021-11-04 23:35:59 +01:00
|
|
|
paddingLeft() {
|
|
|
|
if (window.innerWidth < 768) return 1
|
|
|
|
return 2.5
|
2021-12-03 02:02:38 +01:00
|
|
|
},
|
|
|
|
currentLibraryId() {
|
|
|
|
return this.$store.state.libraries.currentLibraryId
|
2021-12-18 03:52:11 +01:00
|
|
|
},
|
|
|
|
isSelectionMode() {
|
2022-12-01 00:09:00 +01:00
|
|
|
return this.$store.getters['globals/getIsBatchSelectingMediaItems']
|
2021-09-29 00:36:41 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2022-04-24 00:17:05 +02:00
|
|
|
clearSelectedEntities() {
|
|
|
|
this.updateSelectionMode(false)
|
|
|
|
},
|
2022-03-15 00:53:49 +01:00
|
|
|
editAuthor(author) {
|
2022-05-10 01:23:23 +02:00
|
|
|
this.$store.commit('globals/showEditAuthorModal', author)
|
2022-03-15 00:53:49 +01:00
|
|
|
},
|
2022-05-04 00:21:22 +02:00
|
|
|
editItem(libraryItem) {
|
|
|
|
var itemIds = this.shelf.entities.map((e) => e.id)
|
|
|
|
this.$store.commit('setBookshelfBookIds', itemIds)
|
|
|
|
this.$store.commit('showEditModal', libraryItem)
|
2021-10-16 03:31:00 +02:00
|
|
|
},
|
2022-04-23 02:31:11 +02:00
|
|
|
editEpisode({ libraryItem, episode }) {
|
|
|
|
this.$store.commit('setSelectedLibraryItem', libraryItem)
|
|
|
|
this.$store.commit('globals/setSelectedEpisode', episode)
|
|
|
|
this.$store.commit('globals/setShowEditPodcastEpisodeModal', true)
|
|
|
|
},
|
2021-12-18 03:52:11 +01:00
|
|
|
updateSelectionMode(val) {
|
2022-12-01 00:09:00 +01:00
|
|
|
const selectedMediaItems = this.$store.state.globals.selectedMediaItems
|
2022-04-23 02:31:11 +02:00
|
|
|
if (this.shelf.type === 'book' || this.shelf.type === 'podcast') {
|
2021-12-18 03:52:11 +01:00
|
|
|
this.shelf.entities.forEach((ent) => {
|
|
|
|
var component = this.$refs[`shelf-book-${ent.id}`]
|
|
|
|
if (!component || !component.length) return
|
|
|
|
component = component[0]
|
|
|
|
component.setSelectionMode(val)
|
2022-12-01 00:09:00 +01:00
|
|
|
component.selected = selectedMediaItems.some((i) => i.id === ent.id)
|
2021-12-18 03:52:11 +01:00
|
|
|
})
|
2022-04-23 02:31:11 +02:00
|
|
|
} else if (this.shelf.type === 'episode') {
|
|
|
|
this.shelf.entities.forEach((ent) => {
|
|
|
|
var component = this.$refs[`shelf-episode-${ent.recentEpisode.id}`]
|
|
|
|
if (!component || !component.length) return
|
|
|
|
component = component[0]
|
|
|
|
component.setSelectionMode(val)
|
2022-12-01 00:09:00 +01:00
|
|
|
component.selected = selectedMediaItems.some((i) => i.id === ent.id)
|
2022-04-23 02:31:11 +02:00
|
|
|
})
|
2021-12-18 03:52:11 +01:00
|
|
|
}
|
|
|
|
},
|
2022-10-16 00:17:40 +02:00
|
|
|
selectItem(payload) {
|
|
|
|
this.$emit('selectEntity', payload)
|
2022-04-23 02:31:11 +02:00
|
|
|
},
|
|
|
|
itemSelectedEvt() {
|
|
|
|
this.updateSelectionMode(this.isSelectionMode)
|
2021-12-18 03:52:11 +01:00
|
|
|
},
|
2021-09-29 00:36:41 +02:00
|
|
|
scrolled() {
|
|
|
|
clearTimeout(this.scrollTimer)
|
|
|
|
this.scrollTimer = setTimeout(() => {
|
|
|
|
this.isScrolling = false
|
|
|
|
this.$nextTick(this.checkCanScroll)
|
|
|
|
}, 50)
|
|
|
|
},
|
|
|
|
scrollLeft() {
|
|
|
|
if (!this.$refs.shelf) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.isScrolling = true
|
|
|
|
this.$refs.shelf.scrollLeft = 0
|
|
|
|
},
|
|
|
|
scrollRight() {
|
|
|
|
if (!this.$refs.shelf) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.isScrolling = true
|
|
|
|
this.$refs.shelf.scrollLeft = 999
|
|
|
|
},
|
|
|
|
updatedBookCard() {
|
|
|
|
clearTimeout(this.updateTimer)
|
|
|
|
this.updateTimer = setTimeout(() => {
|
|
|
|
this.$nextTick(this.checkCanScroll)
|
|
|
|
}, 100)
|
|
|
|
},
|
|
|
|
checkCanScroll() {
|
|
|
|
if (!this.$refs.shelf) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var clientWidth = this.$refs.shelf.clientWidth
|
|
|
|
var scrollWidth = this.$refs.shelf.scrollWidth
|
|
|
|
var scrollLeft = this.$refs.shelf.scrollLeft
|
|
|
|
if (scrollWidth > clientWidth) {
|
|
|
|
this.canScrollRight = scrollLeft === 0
|
|
|
|
this.canScrollLeft = scrollLeft > 0
|
|
|
|
} else {
|
|
|
|
this.canScrollRight = false
|
|
|
|
this.canScrollLeft = false
|
|
|
|
}
|
|
|
|
}
|
2022-04-23 02:31:11 +02:00
|
|
|
},
|
|
|
|
mounted() {
|
2022-10-29 01:10:19 +02:00
|
|
|
this.$eventBus.$on('bookshelf_clear_selection', this.clearSelectedEntities)
|
2022-04-23 02:31:11 +02:00
|
|
|
this.$eventBus.$on('item-selected', this.itemSelectedEvt)
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2022-10-29 01:10:19 +02:00
|
|
|
this.$eventBus.$off('bookshelf_clear_selection', this.clearSelectedEntities)
|
2022-04-23 02:31:11 +02:00
|
|
|
this.$eventBus.$off('item-selected', this.itemSelectedEvt)
|
2021-09-29 00:36:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2021-11-04 23:35:59 +01:00
|
|
|
.categorizedBookshelfRow {
|
2021-09-29 00:36:41 +02:00
|
|
|
scroll-behavior: smooth;
|
2021-11-28 03:11:35 +01:00
|
|
|
background-image: var(--bookshelf-texture-img);
|
|
|
|
background-repeat: repeat-x;
|
2021-09-29 00:36:41 +02:00
|
|
|
}
|
2021-11-04 23:35:59 +01:00
|
|
|
|
2021-09-29 00:36:41 +02:00
|
|
|
.bookshelfDividerCategorized {
|
|
|
|
background: rgb(149, 119, 90);
|
|
|
|
background: linear-gradient(180deg, rgb(122, 94, 68) 0%, rgb(92, 62, 31) 17%, rgb(82, 54, 26) 88%, rgba(71, 48, 25, 1) 100%);
|
|
|
|
box-shadow: 2px 14px 8px #111111aa;
|
|
|
|
}
|
2021-11-07 02:31:46 +01:00
|
|
|
|
2021-09-29 00:36:41 +02:00
|
|
|
.book-shelf-arrow-right {
|
2024-06-24 23:44:29 +02:00
|
|
|
height: calc(100% - 1.5em);
|
2021-09-29 00:36:41 +02:00
|
|
|
background: rgb(48, 48, 48);
|
|
|
|
background: linear-gradient(90deg, rgba(48, 48, 48, 0) 0%, rgba(25, 25, 25, 0.25) 8%, rgba(17, 17, 17, 0.4) 28%, rgba(17, 17, 17, 0.6) 71%, rgba(10, 10, 10, 0.6) 86%, rgba(0, 0, 0, 0.7) 100%);
|
|
|
|
}
|
|
|
|
.book-shelf-arrow-left {
|
2024-06-24 23:44:29 +02:00
|
|
|
height: calc(100% - 1.5em);
|
2021-09-29 00:36:41 +02:00
|
|
|
background: rgb(48, 48, 48);
|
|
|
|
background: linear-gradient(-90deg, rgba(48, 48, 48, 0) 0%, rgba(25, 25, 25, 0.25) 8%, rgba(17, 17, 17, 0.4) 28%, rgba(17, 17, 17, 0.6) 71%, rgba(10, 10, 10, 0.6) 86%, rgba(0, 0, 0, 0.7) 100%);
|
|
|
|
}
|
2024-06-03 08:04:03 +02:00
|
|
|
</style>
|