Book form mobile view: scroll to dates when opened

This commit is contained in:
2026-03-07 20:45:20 +01:00
parent 8a707610bf
commit d398de1b47

View File

@@ -12,6 +12,7 @@ import {
putEndReadDateUnset, putEndReadDateUnset,
putUnreadBook, putUnreadBook,
} from './api.js' } from './api.js'
import { useTemplateRef, nextTick } from 'vue'
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 BigIcon from './BigIcon.vue' import BigIcon from './BigIcon.vue'
@@ -28,6 +29,7 @@ let data = ref(null)
let error = ref(null) let error = ref(null)
getBook(data, error, props.id) getBook(data, error, props.id)
const imagePathOrDefault = computed(() => getImagePathOrDefault(data.value.coverPath)) const imagePathOrDefault = computed(() => getImagePathOrDefault(data.value.coverPath))
const mobiledatesel = useTemplateRef('mobiledates')
onBeforeRouteUpdate(async (to, from) => { onBeforeRouteUpdate(async (to, from) => {
getBook(data, error, to.params.id) getBook(data, error, to.params.id)
@@ -42,12 +44,14 @@ function onRatingUpdate(rating) {
putRateBook(props.id, { rating: data.value.rating }) putRateBook(props.id, { rating: data.value.rating })
} }
function onReadIconClick() { async function onReadIconClick() {
data.value.read = !data.value.read data.value.read = !data.value.read
if (data.value.read) { if (data.value.read) {
data.value.wantread = false data.value.wantread = false
data.value.endReadDate = today data.value.endReadDate = today
putEndReadDate(props.id, today) putEndReadDate(props.id, today)
await nextTick()
mobiledatesel.value.scrollIntoView()
} else { } else {
putUnreadBook(props.id) putUnreadBook(props.id)
} }
@@ -58,10 +62,12 @@ function onWantReadIconClick() {
putWantReadBook(props.id, { wantread: data.value.wantread }) putWantReadBook(props.id, { wantread: data.value.wantread })
} }
function onStartReadIconClick() { async function onStartReadIconClick() {
if (!data.value.startReadDate) { if (!data.value.startReadDate) {
data.value.startReadDate = today data.value.startReadDate = today
putStartReadDate(props.id, data.value.startReadDate) putStartReadDate(props.id, data.value.startReadDate)
await nextTick()
mobiledatesel.value.scrollIntoView()
} else { } else {
data.value.startReadDate = null data.value.startReadDate = null
putStartReadDateUnset(props.id) putStartReadDateUnset(props.id)
@@ -186,7 +192,7 @@ function goToAuthor() {
@onIconClick="onReadIconClick" @onIconClick="onReadIconClick"
/> />
</div> </div>
<div class="mobile-dates pt-3 is-hidden-desktop"> <div ref="mobiledates" class="mobile-dates pt-3 is-hidden-desktop">
<div class="mobiledate"> <div class="mobiledate">
<DateWidget <DateWidget
v-if="isStartReadExpanded() || data.read" v-if="isStartReadExpanded() || data.read"