2021-12-01 03:02:40 +01:00
|
|
|
<template>
|
2022-12-17 23:36:41 +01:00
|
|
|
<div ref="card" :id="`series-card-${index}`" :style="{ width: width + 'px', height: height + 'px' }" class="rounded-sm z-30 cursor-pointer" @mousedown.prevent @mouseup.prevent @mousemove.prevent @mouseover="mouseover" @mouseleave="mouseleave" @click="clickCard">
|
2021-12-04 23:21:10 +01:00
|
|
|
<div class="absolute top-0 left-0 w-full box-shadow-book shadow-height" />
|
2021-12-25 20:57:48 +01:00
|
|
|
<div class="w-full h-full bg-primary relative rounded overflow-hidden z-0">
|
2022-08-23 23:07:53 +02:00
|
|
|
<covers-group-cover v-if="series" ref="cover" :id="seriesId" :name="displayTitle" :book-items="books" :width="width" :height="height" :book-cover-aspect-ratio="bookCoverAspectRatio" />
|
2021-12-01 03:02:40 +01:00
|
|
|
</div>
|
|
|
|
|
2022-01-24 23:46:14 +01:00
|
|
|
<div class="absolute z-10 top-1.5 right-1.5 rounded-md leading-3 text-sm p-1 font-semibold text-white flex items-center justify-center" style="background-color: #cd9d49dd">{{ books.length }}</div>
|
|
|
|
|
2023-04-29 23:26:56 +02:00
|
|
|
<div v-if="seriesPercentInProgress > 0" class="absolute bottom-0 left-0 h-1 shadow-sm max-w-full z-10 rounded-b w-full" :class="isSeriesFinished ? 'bg-success' : 'bg-yellow-400'" :style="{ width: seriesPercentInProgress * 100 + '%' }" />
|
2022-04-21 15:55:29 +02:00
|
|
|
|
2021-12-26 20:42:27 +01:00
|
|
|
<div v-if="hasValidCovers" class="bg-black bg-opacity-60 absolute top-0 left-0 w-full h-full flex items-center justify-center text-center transition-opacity" :class="isHovering ? '' : 'opacity-0'" :style="{ padding: `${sizeMultiplier}rem` }">
|
2023-02-11 22:02:56 +01:00
|
|
|
<p :style="{ fontSize: 1.2 * sizeMultiplier + 'rem' }">{{ displayTitle }}</p>
|
2021-12-02 22:49:03 +01:00
|
|
|
</div>
|
2022-04-21 15:55:29 +02:00
|
|
|
|
2022-12-31 23:58:19 +01:00
|
|
|
<span v-if="!isHovering && rssFeed" class="absolute z-10 material-icons text-success" :style="{ top: 0.5 * sizeMultiplier + 'rem', left: 0.5 * sizeMultiplier + 'rem', fontSize: 1.5 * sizeMultiplier + 'rem' }">rss_feed</span>
|
|
|
|
|
2023-02-11 22:02:56 +01:00
|
|
|
<div v-if="!isAlternativeBookshelfView" class="categoryPlacard absolute z-10 left-0 right-0 mx-auto -bottom-6 h-6 rounded-md text-center" :style="{ width: Math.min(200, width) + 'px' }">
|
2021-12-02 22:49:03 +01:00
|
|
|
<div class="w-full h-full shinyBlack flex items-center justify-center rounded-sm border" :style="{ padding: `0rem ${0.5 * sizeMultiplier}rem` }">
|
2022-07-31 00:07:54 +02:00
|
|
|
<p class="truncate" :style="{ fontSize: labelFontSize + 'rem' }">{{ displayTitle }}</p>
|
2021-12-01 03:02:40 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-10 01:23:23 +02:00
|
|
|
<div v-else class="absolute z-30 left-0 right-0 mx-auto -bottom-8 h-8 py-1 rounded-md text-center">
|
2023-02-11 22:51:23 +01:00
|
|
|
<p class="truncate" :style="{ fontSize: labelFontSize * sizeMultiplier + 'rem' }">{{ displayTitle }}</p>
|
2022-10-29 18:17:51 +02:00
|
|
|
<p v-if="displaySortLine" class="truncate text-gray-400" :style="{ fontSize: 0.8 * sizeMultiplier + 'rem' }">{{ displaySortLine }}</p>
|
2022-05-10 01:23:23 +02:00
|
|
|
</div>
|
2021-12-01 03:02:40 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
index: Number,
|
2021-12-02 22:49:03 +01:00
|
|
|
width: Number,
|
|
|
|
height: Number,
|
2021-12-18 03:52:11 +01:00
|
|
|
bookCoverAspectRatio: Number,
|
2022-05-10 01:23:23 +02:00
|
|
|
bookshelfView: {
|
|
|
|
type: Number,
|
|
|
|
default: 0
|
|
|
|
},
|
2021-12-18 03:52:11 +01:00
|
|
|
isCategorized: Boolean,
|
|
|
|
seriesMount: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
2022-07-31 00:07:54 +02:00
|
|
|
},
|
2022-10-29 18:17:51 +02:00
|
|
|
sortingIgnorePrefix: Boolean,
|
|
|
|
orderBy: String
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
series: null,
|
|
|
|
isSelectionMode: false,
|
|
|
|
selected: false,
|
|
|
|
isHovering: false,
|
|
|
|
imageReady: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-10-29 18:17:51 +02:00
|
|
|
dateFormat() {
|
|
|
|
return this.store.state.serverSettings.dateFormat
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
labelFontSize() {
|
|
|
|
if (this.width < 160) return 0.75
|
|
|
|
return 0.875
|
|
|
|
},
|
|
|
|
sizeMultiplier() {
|
2021-12-02 22:49:03 +01:00
|
|
|
if (this.bookCoverAspectRatio === 1) return this.width / (120 * 1.6 * 2)
|
|
|
|
return this.width / 240
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
2022-03-13 01:50:31 +01:00
|
|
|
seriesId() {
|
|
|
|
return this.series ? this.series.id : ''
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
title() {
|
|
|
|
return this.series ? this.series.name : ''
|
|
|
|
},
|
2022-07-31 00:07:54 +02:00
|
|
|
nameIgnorePrefix() {
|
|
|
|
return this.series ? this.series.nameIgnorePrefix : ''
|
|
|
|
},
|
|
|
|
displayTitle() {
|
|
|
|
if (this.sortingIgnorePrefix) return this.nameIgnorePrefix || this.title
|
|
|
|
return this.title
|
|
|
|
},
|
2022-10-29 18:17:51 +02:00
|
|
|
displaySortLine() {
|
2023-04-12 18:55:59 +02:00
|
|
|
switch (this.orderBy) {
|
|
|
|
case 'addedAt':
|
|
|
|
return `${this.$strings.LabelAdded} ${this.$formatDate(this.addedAt, this.dateFormat)}`
|
|
|
|
case 'totalDuration':
|
2023-04-29 23:26:56 +02:00
|
|
|
return `${this.$strings.LabelDuration} ${this.$elapsedPrettyExtended(this.totalDuration, false)}`
|
2023-04-12 18:55:59 +02:00
|
|
|
case 'lastBookUpdated':
|
2023-04-29 23:26:56 +02:00
|
|
|
const lastUpdated = Math.max(...this.books.map((x) => x.updatedAt), 0)
|
2023-04-12 18:55:59 +02:00
|
|
|
return `${this.$strings.LabelLastBookUpdated} ${this.$formatDate(lastUpdated, this.dateFormat)}`
|
|
|
|
case 'lastBookAdded':
|
2023-04-29 23:26:56 +02:00
|
|
|
const lastBookAdded = Math.max(...this.books.map((x) => x.addedAt), 0)
|
|
|
|
return `${this.$strings.LabelLastBookAdded} ${this.$formatDate(lastBookAdded, this.dateFormat)}`
|
2023-04-12 18:55:59 +02:00
|
|
|
default:
|
|
|
|
return null
|
2022-10-29 18:17:51 +02:00
|
|
|
}
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
books() {
|
|
|
|
return this.series ? this.series.books || [] : []
|
|
|
|
},
|
2022-04-24 23:56:30 +02:00
|
|
|
addedAt() {
|
|
|
|
return this.series ? this.series.addedAt : 0
|
|
|
|
},
|
2022-10-29 18:17:51 +02:00
|
|
|
totalDuration() {
|
|
|
|
return this.series ? this.series.totalDuration : 0
|
|
|
|
},
|
2022-04-21 15:55:29 +02:00
|
|
|
seriesBookProgress() {
|
|
|
|
return this.books
|
|
|
|
.map((libraryItem) => {
|
|
|
|
return this.store.getters['user/getUserMediaProgress'](libraryItem.id)
|
|
|
|
})
|
|
|
|
.filter((p) => !!p)
|
|
|
|
},
|
|
|
|
seriesBooksFinished() {
|
|
|
|
return this.seriesBookProgress.filter((p) => p.isFinished)
|
|
|
|
},
|
2023-04-29 23:26:56 +02:00
|
|
|
hasSeriesBookInProgress() {
|
|
|
|
return this.seriesBookProgress.some((p) => !p.isFinished && p.progress > 0)
|
|
|
|
},
|
|
|
|
seriesPercentInProgress() {
|
|
|
|
let totalFinishedAndInProgress = this.seriesBooksFinished.length
|
|
|
|
if (this.hasSeriesBookInProgress) totalFinishedAndInProgress += 1
|
|
|
|
return Math.min(1, Math.max(0, totalFinishedAndInProgress / this.books.length))
|
|
|
|
},
|
2022-04-21 15:55:29 +02:00
|
|
|
isSeriesFinished() {
|
|
|
|
return this.books.length === this.seriesBooksFinished.length
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
store() {
|
|
|
|
return this.$store || this.$nuxt.$store
|
|
|
|
},
|
|
|
|
currentLibraryId() {
|
|
|
|
return this.store.state.libraries.currentLibraryId
|
2021-12-02 02:07:03 +01:00
|
|
|
},
|
|
|
|
seriesBooksRoute() {
|
2022-03-13 01:50:31 +01:00
|
|
|
return `/library/${this.currentLibraryId}/series/${this.seriesId}`
|
2021-12-02 22:49:03 +01:00
|
|
|
},
|
|
|
|
hasValidCovers() {
|
2022-03-13 01:50:31 +01:00
|
|
|
var validCovers = this.books.map((bookItem) => bookItem.media.coverPath)
|
2021-12-02 22:49:03 +01:00
|
|
|
return !!validCovers.length
|
2022-05-10 01:23:23 +02:00
|
|
|
},
|
|
|
|
isAlternativeBookshelfView() {
|
|
|
|
const constants = this.$constants || this.$nuxt.$constants
|
2022-10-22 16:13:20 +02:00
|
|
|
return this.bookshelfView == constants.BookshelfView.DETAIL
|
2022-12-31 23:58:19 +01:00
|
|
|
},
|
|
|
|
rssFeed() {
|
|
|
|
return this.series ? this.series.rssFeed : null
|
2021-12-01 03:02:40 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setEntity(_series) {
|
|
|
|
this.series = _series
|
|
|
|
},
|
|
|
|
setSelectionMode(val) {
|
|
|
|
this.isSelectionMode = val
|
|
|
|
},
|
|
|
|
mouseover() {
|
|
|
|
this.isHovering = true
|
|
|
|
},
|
|
|
|
mouseleave() {
|
|
|
|
this.isHovering = false
|
|
|
|
},
|
|
|
|
clickCard() {
|
|
|
|
if (!this.series) return
|
|
|
|
var router = this.$router || this.$nuxt.$router
|
2021-12-04 01:07:42 +01:00
|
|
|
router.push(`/library/${this.currentLibraryId}/series/${this.seriesId}`)
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
|
|
|
imageLoaded() {
|
|
|
|
this.imageReady = true
|
|
|
|
},
|
|
|
|
destroy() {
|
|
|
|
// destroy the vue listeners, etc
|
|
|
|
this.$destroy()
|
|
|
|
|
|
|
|
// remove the element from the DOM
|
|
|
|
if (this.$el && this.$el.parentNode) {
|
|
|
|
this.$el.parentNode.removeChild(this.$el)
|
|
|
|
} else if (this.$el && this.$el.remove) {
|
|
|
|
this.$el.remove()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-12-18 03:52:11 +01:00
|
|
|
mounted() {
|
|
|
|
if (this.seriesMount) {
|
|
|
|
this.setEntity(this.seriesMount)
|
|
|
|
}
|
|
|
|
},
|
2021-12-02 22:49:03 +01:00
|
|
|
beforeDestroy() {}
|
2021-12-01 03:02:40 +01:00
|
|
|
}
|
2021-12-04 23:21:10 +01:00
|
|
|
</script>
|