Bookform: fix scrollTo on mobile view
regression of previous commit
This commit is contained in:
@@ -12,7 +12,6 @@ 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 BookFormIcons from './BookFormIcons.vue'
|
import BookFormIcons from './BookFormIcons.vue'
|
||||||
@@ -27,7 +26,6 @@ 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)
|
||||||
@@ -48,8 +46,6 @@ async function onReadIconClick() {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
@@ -64,8 +60,6 @@ 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)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import { useTemplateRef, nextTick } from 'vue'
|
||||||
import BigIcon from './BigIcon.vue'
|
import BigIcon from './BigIcon.vue'
|
||||||
import BookDateWidget from './BookDateWidget.vue'
|
import BookDateWidget from './BookDateWidget.vue'
|
||||||
import DateWidget from './DateWidget.vue'
|
import DateWidget from './DateWidget.vue'
|
||||||
@@ -10,6 +11,8 @@ const props = defineProps({
|
|||||||
read: Boolean,
|
read: Boolean,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const mobiledatesel = useTemplateRef('mobiledates')
|
||||||
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
'onWantReadIconClick',
|
'onWantReadIconClick',
|
||||||
'onStartReadIconClick',
|
'onStartReadIconClick',
|
||||||
@@ -23,6 +26,18 @@ function isStartReadExpanded() {
|
|||||||
let isReadUnset = !props.read ? true : false
|
let isReadUnset = !props.read ? true : false
|
||||||
return isStartReadDateSet && isReadUnset
|
return isStartReadDateSet && isReadUnset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onReadIconClick() {
|
||||||
|
emit('onReadIconClick')
|
||||||
|
await nextTick()
|
||||||
|
mobiledatesel.value.scrollIntoView()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onStartReadIconClick() {
|
||||||
|
emit('onStartReadIconClick')
|
||||||
|
await nextTick()
|
||||||
|
mobiledatesel.value.scrollIntoView()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -47,7 +62,7 @@ function isStartReadExpanded() {
|
|||||||
:legend="$t('bookform.wantread')"
|
:legend="$t('bookform.wantread')"
|
||||||
:is-set="isStartReadExpanded()"
|
:is-set="isStartReadExpanded()"
|
||||||
:is-readonly="props.read"
|
:is-readonly="props.read"
|
||||||
@click="props.read ? null : $emit('onStartReadIconClick')"
|
@click="props.read ? null : onStartReadIconClick()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -58,7 +73,7 @@ function isStartReadExpanded() {
|
|||||||
icon="BIconCheckCircle"
|
icon="BIconCheckCircle"
|
||||||
:legend="$t('bookform.read')"
|
:legend="$t('bookform.read')"
|
||||||
:isSet="props.read"
|
:isSet="props.read"
|
||||||
@click="$emit('onReadIconClick')"
|
@click="onReadIconClick"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<BookDateWidget
|
<BookDateWidget
|
||||||
@@ -69,7 +84,7 @@ function isStartReadExpanded() {
|
|||||||
:is-expanded="isStartReadExpanded()"
|
:is-expanded="isStartReadExpanded()"
|
||||||
:is-readonly="props.read"
|
:is-readonly="props.read"
|
||||||
@onStartDateChange="(d) => $emit('onStartReadDateChange', d)"
|
@onStartDateChange="(d) => $emit('onStartReadDateChange', d)"
|
||||||
@onIconClick="$emit('onStartReadIconClick')"
|
@onIconClick="onStartReadIconClick"
|
||||||
/>
|
/>
|
||||||
<BookDateWidget
|
<BookDateWidget
|
||||||
class="is-hidden-mobile"
|
class="is-hidden-mobile"
|
||||||
@@ -82,7 +97,7 @@ function isStartReadExpanded() {
|
|||||||
:isExpanded="props.read"
|
:isExpanded="props.read"
|
||||||
@onStartDateChange="(d) => $emit('onStartReadDateChange', d)"
|
@onStartDateChange="(d) => $emit('onStartReadDateChange', d)"
|
||||||
@onEndDateChange="(d) => $emit('onEndReadDateChange', d)"
|
@onEndDateChange="(d) => $emit('onEndReadDateChange', d)"
|
||||||
@onIconClick="$emit('onReadIconClick')"
|
@onIconClick="onReadIconClick"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user