From 2d0bce143a113a5311b6d2433a2ff11b84f0b9a8 Mon Sep 17 00:00:00 2001 From: Arthur Lefebvre Date: Sun, 15 Mar 2026 15:23:14 +0100 Subject: [PATCH] Book form: add a field to write a review --- front/src/BookForm.vue | 27 +++----- front/src/ReviewModal.vue | 61 ----------------- front/src/ReviewWidget.vue | 134 +++++++++++++++++++++++++++++++++++++ front/src/api.js | 6 +- front/src/locales/en.json | 4 ++ front/src/locales/fr.json | 4 ++ 6 files changed, 153 insertions(+), 83 deletions(-) delete mode 100644 front/src/ReviewModal.vue create mode 100644 front/src/ReviewWidget.vue diff --git a/front/src/BookForm.vue b/front/src/BookForm.vue index 7530207..d912649 100644 --- a/front/src/BookForm.vue +++ b/front/src/BookForm.vue @@ -3,8 +3,7 @@ import { ref, computed } from 'vue' import { getBook, getImagePathOrDefault, - putWantReadBook, - putRateBook, + putUpdateBook, putStartReadDate, putStartReadDateUnset, putEndReadDate, @@ -14,7 +13,7 @@ import { import { useRouter, onBeforeRouteUpdate } from 'vue-router' import { VRating } from 'vuetify/components/VRating' import BookFormIcons from './BookFormIcons.vue' -import ReviewModal from './ReviewModal.vue' +import ReviewWidget from './ReviewWidget.vue' const router = useRouter() const props = defineProps({ @@ -37,7 +36,12 @@ function onRatingUpdate(rating) { data.value.read = true data.value.wantread = false } - putRateBook(props.id, { rating: data.value.rating }) + putUpdateBook(props.id, { rating: data.value.rating }) +} + +function onReviewUpdate(review) { + data.value.review = review + putUpdateBook(props.id, { review: data.value.review }) } async function onReadIconClick() { @@ -53,7 +57,7 @@ async function onReadIconClick() { function onWantReadIconClick() { data.value.wantread = !data.value.wantread - putWantReadBook(props.id, { wantread: data.value.wantread }) + putUpdateBook(props.id, { wantread: data.value.wantread }) } async function onStartReadIconClick() { @@ -100,18 +104,6 @@ function goToAuthor() {
- -

{{ data.title }}

@@ -120,6 +112,7 @@ function goToAuthor() {
ISBN: {{ data.isbn }}
Inventaire ID: {{ data.inventaireid }}
OLID: {{ data.openlibraryid }}
+
-import { ref } from 'vue' - -const props = defineProps({ - buttonParentClass: String, -}) - -const open = ref(false) - - - - - - diff --git a/front/src/ReviewWidget.vue b/front/src/ReviewWidget.vue new file mode 100644 index 0000000..dfff48f --- /dev/null +++ b/front/src/ReviewWidget.vue @@ -0,0 +1,134 @@ + + + + + diff --git a/front/src/api.js b/front/src/api.js index d70e224..28f4cc9 100644 --- a/front/src/api.js +++ b/front/src/api.js @@ -122,11 +122,7 @@ export async function putStartReadDate(bookId, startdate) { return genericPayloadCall('/ws/book/' + bookId, { startDate: startdate }, 'PUT') } -export async function putWantReadBook(bookId, payload) { - return genericPayloadCall('/ws/book/' + bookId, payload, 'PUT') -} - -export async function putRateBook(bookId, payload) { +export async function putUpdateBook(bookId, payload) { return genericPayloadCall('/ws/book/' + bookId, payload, 'PUT') } diff --git a/front/src/locales/en.json b/front/src/locales/en.json index 44981d3..5f8853c 100644 --- a/front/src/locales/en.json +++ b/front/src/locales/en.json @@ -81,5 +81,9 @@ "releasedate": "Release date:", "publisher": "Publisher:", "importing": "Importing..." + }, + "review": { + "title": "My review", + "textplaceholder": "Write my review..." } } diff --git a/front/src/locales/fr.json b/front/src/locales/fr.json index 745bbb0..6272885 100644 --- a/front/src/locales/fr.json +++ b/front/src/locales/fr.json @@ -81,5 +81,9 @@ "releasedate": "Date de publication : ", "publisher": "Maison d'édition : ", "importing": "Import en cours..." + }, + "review": { + "title": "Ma critique", + "textplaceholder": "Écrire ma critique..." } }