2022-05-09 01:21:46 +02:00
|
|
|
<template>
|
2022-06-04 19:07:38 +02:00
|
|
|
<div id="page-wrapper" class="bg-bg page overflow-y-auto p-4 md:p-8" :class="streamLibraryItem ? 'streaming' : ''">
|
2022-05-09 01:21:46 +02:00
|
|
|
<div class="max-w-6xl mx-auto">
|
2022-06-04 19:07:38 +02:00
|
|
|
<div class="flex flex-wrap sm:flex-nowrap justify-center mb-6">
|
2022-05-09 01:21:46 +02:00
|
|
|
<div class="w-48 min-w-48">
|
2023-10-19 00:10:53 +02:00
|
|
|
<div class="w-full h-60">
|
2022-05-09 01:21:46 +02:00
|
|
|
<covers-author-image :author="author" rounded="0" />
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-04 19:07:38 +02:00
|
|
|
<div class="flex-grow py-4 sm:py-0 px-4 md:px-8">
|
2022-05-09 01:21:46 +02:00
|
|
|
<div class="flex items-center mb-8">
|
|
|
|
<h1 class="text-2xl">{{ author.name }}</h1>
|
|
|
|
|
2022-05-09 01:48:57 +02:00
|
|
|
<button v-if="userCanUpdate" class="w-8 h-8 rounded-full flex items-center justify-center mx-4 cursor-pointer text-gray-300 hover:text-warning transform hover:scale-125 duration-100" @click="editAuthor">
|
2022-05-09 01:21:46 +02:00
|
|
|
<span class="material-icons text-base">edit</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2022-11-09 00:10:08 +01:00
|
|
|
<p v-if="author.description" class="text-white text-opacity-60 uppercase text-xs mb-2">{{ $strings.LabelDescription }}</p>
|
2024-02-18 18:32:24 +01:00
|
|
|
<p ref="description" id="author-description" class="text-white max-w-3xl text-base whitespace-pre-wrap" :class="{ 'show-full': showFullDescription }">{{ author.description }}</p>
|
|
|
|
<button v-if="isDescriptionClamped" class="py-0.5 flex items-center text-slate-300 hover:text-white" @click="showFullDescription = !showFullDescription">
|
2024-05-04 00:12:49 +02:00
|
|
|
{{ showFullDescription ? $strings.ButtonReadLess : $strings.ButtonReadMore }} <span class="material-icons text-xl pl-1">{{ showFullDescription ? 'expand_less' : 'expand_more' }}</span>
|
2024-02-18 18:32:24 +01:00
|
|
|
</button>
|
2022-05-09 01:21:46 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="py-4">
|
2022-11-13 00:22:16 +01:00
|
|
|
<widgets-item-slider :items="libraryItems" shelf-id="author-books" :bookshelf-view="$constants.BookshelfView.AUTHOR">
|
2022-05-20 00:42:34 +02:00
|
|
|
<nuxt-link :to="`/library/${currentLibraryId}/bookshelf?filter=authors.${$encode(author.id)}`" class="hover:underline">
|
2022-11-09 00:10:08 +01:00
|
|
|
<h2 class="text-lg">{{ libraryItems.length }} {{ $strings.LabelBooks }}</h2>
|
2022-05-20 00:42:34 +02:00
|
|
|
</nuxt-link>
|
2022-05-09 01:21:46 +02:00
|
|
|
</widgets-item-slider>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-for="series in authorSeries" :key="series.id" class="py-4">
|
2022-11-13 00:22:16 +01:00
|
|
|
<widgets-item-slider :items="series.items" :shelf-id="series.id" :bookshelf-view="$constants.BookshelfView.AUTHOR">
|
2022-05-20 00:42:34 +02:00
|
|
|
<nuxt-link :to="`/library/${currentLibraryId}/series/${series.id}`" class="hover:underline">
|
|
|
|
<h2 class="text-lg">{{ series.name }}</h2>
|
|
|
|
</nuxt-link>
|
2022-11-09 00:10:08 +01:00
|
|
|
<p class="text-white text-opacity-40 text-base px-2">{{ $strings.LabelSeries }}</p>
|
2022-05-09 01:21:46 +02:00
|
|
|
</widgets-item-slider>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2023-05-13 23:47:38 +02:00
|
|
|
async asyncData({ store, app, params, redirect, query }) {
|
2023-10-19 00:10:53 +02:00
|
|
|
const author = await app.$axios.$get(`/api/authors/${params.id}?include=items,series`).catch((error) => {
|
2022-05-09 01:21:46 +02:00
|
|
|
console.error('Failed to get author', error)
|
|
|
|
return null
|
|
|
|
})
|
|
|
|
|
|
|
|
if (!author) {
|
|
|
|
return redirect(`/library/${store.state.libraries.currentLibraryId}/authors`)
|
|
|
|
}
|
|
|
|
|
2023-05-13 23:47:38 +02:00
|
|
|
if (query.library) {
|
|
|
|
store.commit('libraries/setCurrentLibrary', query.library)
|
|
|
|
}
|
|
|
|
|
2022-05-09 01:21:46 +02:00
|
|
|
return {
|
|
|
|
author
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
2024-02-18 18:32:24 +01:00
|
|
|
return {
|
|
|
|
isDescriptionClamped: false,
|
|
|
|
showFullDescription: false
|
|
|
|
}
|
2022-05-09 01:21:46 +02:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
streamLibraryItem() {
|
|
|
|
return this.$store.state.streamLibraryItem
|
|
|
|
},
|
|
|
|
currentLibraryId() {
|
|
|
|
return this.$store.state.libraries.currentLibraryId
|
|
|
|
},
|
|
|
|
libraryItems() {
|
|
|
|
return this.author.libraryItems || []
|
|
|
|
},
|
|
|
|
authorSeries() {
|
|
|
|
return this.author.series || []
|
2022-05-09 01:48:57 +02:00
|
|
|
},
|
|
|
|
userCanUpdate() {
|
|
|
|
return this.$store.getters['user/getUserCanUpdate']
|
2022-05-09 01:21:46 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2024-02-18 18:32:24 +01:00
|
|
|
checkDescriptionClamped() {
|
|
|
|
if (!this.$refs.description) return
|
|
|
|
this.isDescriptionClamped = this.$refs.description.scrollHeight > this.$refs.description.clientHeight
|
|
|
|
},
|
2022-05-09 01:21:46 +02:00
|
|
|
editAuthor() {
|
|
|
|
this.$store.commit('globals/showEditAuthorModal', this.author)
|
|
|
|
},
|
|
|
|
authorUpdated(author) {
|
|
|
|
if (author.id === this.author.id) {
|
|
|
|
console.log('Author was updated', author)
|
|
|
|
this.author = {
|
|
|
|
...author,
|
|
|
|
series: this.authorSeries,
|
|
|
|
libraryItems: this.libraryItems
|
|
|
|
}
|
2024-02-18 18:32:24 +01:00
|
|
|
this.$nextTick(this.checkDescriptionClamped)
|
2022-05-09 01:21:46 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
authorRemoved(author) {
|
|
|
|
if (author.id === this.author.id) {
|
|
|
|
console.warn('Author was removed')
|
|
|
|
this.$router.replace(`/library/${this.currentLibraryId}/authors`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (!this.author) this.$router.replace('/')
|
2024-02-18 18:32:24 +01:00
|
|
|
this.checkDescriptionClamped()
|
2022-05-09 01:21:46 +02:00
|
|
|
|
|
|
|
this.$root.socket.on('author_updated', this.authorUpdated)
|
|
|
|
this.$root.socket.on('author_removed', this.authorRemoved)
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.$root.socket.off('author_updated', this.authorUpdated)
|
|
|
|
this.$root.socket.off('author_removed', this.authorRemoved)
|
|
|
|
}
|
|
|
|
}
|
2024-02-18 18:32:24 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
#author-description {
|
|
|
|
overflow: hidden;
|
|
|
|
display: -webkit-box;
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
-webkit-line-clamp: 4;
|
|
|
|
max-height: 6.25rem;
|
|
|
|
transition: all 0.3s ease-in-out;
|
|
|
|
}
|
|
|
|
#author-description.show-full {
|
|
|
|
-webkit-line-clamp: unset;
|
|
|
|
max-height: 999rem;
|
|
|
|
}
|
2024-05-04 00:12:49 +02:00
|
|
|
</style>
|