WIP: Add a review button on book form
This commit is contained in:
@@ -3,7 +3,6 @@ import { ref, computed } from 'vue'
|
|||||||
import {
|
import {
|
||||||
getBook,
|
getBook,
|
||||||
getImagePathOrDefault,
|
getImagePathOrDefault,
|
||||||
putReadBook,
|
|
||||||
putWantReadBook,
|
putWantReadBook,
|
||||||
putRateBook,
|
putRateBook,
|
||||||
putStartReadDate,
|
putStartReadDate,
|
||||||
@@ -15,6 +14,7 @@ import {
|
|||||||
import { useRouter, onBeforeRouteUpdate } from 'vue-router'
|
import { useRouter, onBeforeRouteUpdate } from 'vue-router'
|
||||||
import { VRating } from 'vuetify/components/VRating'
|
import { VRating } from 'vuetify/components/VRating'
|
||||||
import BookFormIcons from './BookFormIcons.vue'
|
import BookFormIcons from './BookFormIcons.vue'
|
||||||
|
import ReviewModal from './ReviewModal.vue'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -109,8 +109,9 @@ function goToAuthor() {
|
|||||||
:model-value="data.rating / 2"
|
:model-value="data.rating / 2"
|
||||||
@update:modelValue="onRatingUpdate"
|
@update:modelValue="onRatingUpdate"
|
||||||
active-color="bulma-body-color"
|
active-color="bulma-body-color"
|
||||||
class="centered"
|
class="centered mt-2"
|
||||||
/>
|
/>
|
||||||
|
<ReviewModal button-parent-class="centered mt-3" />
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<h3 class="title">{{ data.title }}</h3>
|
<h3 class="title">{{ data.title }}</h3>
|
||||||
@@ -141,12 +142,6 @@ img {
|
|||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.centered {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
.left-panel {
|
.left-panel {
|
||||||
margin-left: 3rem;
|
margin-left: 3rem;
|
||||||
|
|||||||
61
front/src/ReviewModal.vue
Normal file
61
front/src/ReviewModal.vue
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
buttonParentClass: String,
|
||||||
|
})
|
||||||
|
|
||||||
|
const open = ref(false)
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div :class="buttonParentClass">
|
||||||
|
<button @click="open = true" class="button is-large is-responsive">
|
||||||
|
<span class="icon">
|
||||||
|
<b-icon-pen/>
|
||||||
|
</span>
|
||||||
|
<span>{{$t('bookform.reviewbtn')}}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Teleport to="body">
|
||||||
|
<div v-if="open">
|
||||||
|
<div @click="open = false" class="modal-backdrop"></div>
|
||||||
|
<div class="modal has-background-dark">
|
||||||
|
<h2 class="subtitle">{{$t('bookform.reviewbtn')}}</h2>
|
||||||
|
<textarea class="textarea" :placeholder="$t('bookform.reviewbtn')"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.modal-backdrop {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
height: 80%;
|
||||||
|
width: 80%;
|
||||||
|
top: 10%;
|
||||||
|
left: 10%;
|
||||||
|
box-shadow: 2px 2px 20px 1px;
|
||||||
|
overflow-x: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 15px;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -59,6 +59,7 @@
|
|||||||
},
|
},
|
||||||
"bookform": {
|
"bookform": {
|
||||||
"error": "Error when loading book: {error}",
|
"error": "Error when loading book: {error}",
|
||||||
|
"reviewbtn": "My review",
|
||||||
"read": "Read",
|
"read": "Read",
|
||||||
"startread": "Started",
|
"startread": "Started",
|
||||||
"wantread": "Interested"
|
"wantread": "Interested"
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
},
|
},
|
||||||
"bookform": {
|
"bookform": {
|
||||||
"error": "Erreur pendant le chargement du livre: {error}",
|
"error": "Erreur pendant le chargement du livre: {error}",
|
||||||
|
"reviewbtn": "Ma critique",
|
||||||
"read": "Lu",
|
"read": "Lu",
|
||||||
"startread": "Commencé",
|
"startread": "Commencé",
|
||||||
"wantread": "À lire"
|
"wantread": "À lire"
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
.clickable {
|
.clickable {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.centered {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type UserBookPutUpdate struct {
|
|||||||
WantRead *bool `json:"wantread"`
|
WantRead *bool `json:"wantread"`
|
||||||
Rating *int `json:"rating"`
|
Rating *int `json:"rating"`
|
||||||
StartDate *string `json:"startDate"`
|
StartDate *string `json:"startDate"`
|
||||||
|
Review *string `json:"review"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileInfoPost struct {
|
type FileInfoPost struct {
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ func PutUserBookHandler(ac appcontext.AppContext) {
|
|||||||
}
|
}
|
||||||
updateRating(&userbook, &userBookPut)
|
updateRating(&userbook, &userBookPut)
|
||||||
}
|
}
|
||||||
|
if userBookPut.Review != nil {
|
||||||
|
userbook.Review = *userBookPut.Review
|
||||||
|
}
|
||||||
ac.Db.Save(&userbook)
|
ac.Db.Save(&userbook)
|
||||||
ac.C.String(http.StatusOK, "Success")
|
ac.C.String(http.StatusOK, "Success")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user