mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-06 07:59:43 +00:00
Add review deletion functionality and UI enhancements
- Implemented delete functionality for reviews in both the ReviewModal and ReviewsTable components. - Added confirmation prompts for review deletion actions. - Updated ReviewController to allow deletion of reviews by admins or the review owner. - Enhanced event handling to refresh the review list upon deletion. - Improved UI to include delete buttons for admins in the ratings page and reviews table.
This commit is contained in:
parent
d2285d952a
commit
633bc4805e
5 changed files with 106 additions and 5 deletions
|
|
@ -101,10 +101,13 @@
|
|||
</div>
|
||||
|
||||
<!-- Edit button -->
|
||||
<div class="flex-shrink-0 w-7">
|
||||
<div class="flex-shrink-0 w-7 flex flex-col gap-1">
|
||||
<button v-if="isReviewAuthor(review)" class="p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-gray-200" @click.stop="editReview(review)">
|
||||
<span class="material-symbols text-base">edit</span>
|
||||
</button>
|
||||
<button v-if="isAdmin && !isReviewAuthor(review)" class="p-0.5 rounded hover:bg-white/10 text-gray-400 hover:text-error transition-colors" title="Delete Review" @click.stop="deleteReviewAdmin(review)">
|
||||
<span class="material-symbols text-base">delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -121,7 +124,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<modals-review-modal @review-updated="fetchReviews" />
|
||||
<modals-review-modal @review-updated="fetchReviews" @review-deleted="fetchReviews" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -160,6 +163,9 @@ export default {
|
|||
currentUser() {
|
||||
return this.$store.state.user.user
|
||||
},
|
||||
isAdmin() {
|
||||
return this.currentUser.type === 'admin' || this.currentUser.type === 'root'
|
||||
},
|
||||
sortItems() {
|
||||
return [
|
||||
{ value: 'newest', text: this.$strings.LabelSortNewestFirst },
|
||||
|
|
@ -259,6 +265,18 @@ export default {
|
|||
isReviewAuthor(review) {
|
||||
return review.userId === this.currentUser.id
|
||||
},
|
||||
async deleteReviewAdmin(review) {
|
||||
if (!confirm(`Are you sure you want to delete ${review.user?.username || 'this'}'s review?`)) return
|
||||
|
||||
try {
|
||||
await this.$axios.$delete(`/api/reviews/${review.id}`)
|
||||
this.fetchReviews()
|
||||
this.$toast.success('Review deleted')
|
||||
} catch (error) {
|
||||
console.error('Failed to delete review', error)
|
||||
this.$toast.error('Failed to delete review')
|
||||
}
|
||||
},
|
||||
editReview(review) {
|
||||
this.$store.commit('globals/setReviewModal', {
|
||||
libraryItem: review.libraryItem,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue