Fix the form pagination

This commit is contained in:
Julien Nahum 2024-01-17 12:43:52 +01:00
parent e0b6d422b1
commit 1f558dbcbb
4 changed files with 8 additions and 6 deletions

View File

@ -13,10 +13,10 @@ const { modelValue, disabled } = defineProps({
modelValue: { type: Boolean, default: false }, modelValue: { type: Boolean, default: false },
disabled: { type: Boolean, default: false } disabled: { type: Boolean, default: false }
}) })
const emit = defineEmits(['update:modelValue']) const emits = defineEmits(['update:modelValue'])
const onClick = () => { const onClick = () => {
if (disabled) return if (disabled) return
emit('update:modelValue', !modelValue) emits('update:modelValue', !modelValue)
} }
</script> </script>

View File

@ -48,7 +48,7 @@
<slot v-if="isLastPage" name="submit-btn" :submitForm="submitForm" /> <slot v-if="isLastPage" name="submit-btn" :submitForm="submitForm" />
<open-form-button v-else native-type="button" :color="form.color" :theme="theme" class="mt-2 px-8 mx-1" <open-form-button v-else native-type="button" :color="form.color" :theme="theme" class="mt-2 px-8 mx-1"
@click="nextPage" @click.stop="nextPage"
> >
{{ currentFieldsPageBreak.next_btn_text }} {{ currentFieldsPageBreak.next_btn_text }}
</open-form-button> </open-form-button>
@ -171,6 +171,7 @@ export default {
* Returns the page break block for the current group of fields * Returns the page break block for the current group of fields
*/ */
currentFieldsPageBreak () { currentFieldsPageBreak () {
// Last block from current group
const block = this.currentFields[this.currentFields.length - 1] const block = this.currentFields[this.currentFields.length - 1]
if (block && block.type === 'nf-page-break') return block if (block && block.type === 'nf-page-break') return block
return null return null
@ -376,11 +377,13 @@ export default {
this.dataForm = useForm(formData) this.dataForm = useForm(formData)
}, },
previousPage () { previousPage () {
console.log('preivousPage', this.currentFieldGroupIndex)
this.currentFieldGroupIndex -= 1 this.currentFieldGroupIndex -= 1
window.scrollTo({ top: 0, behavior: 'smooth' }) window.scrollTo({ top: 0, behavior: 'smooth' })
return false return false
}, },
nextPage () { nextPage () {
console.log('nextPage',this.currentFieldGroupIndex)
this.currentFieldGroupIndex += 1 this.currentFieldGroupIndex += 1
window.scrollTo({ top: 0, behavior: 'smooth' }) window.scrollTo({ top: 0, behavior: 'smooth' })
return false return false

View File

@ -1,7 +1,6 @@
<template> <template>
<button :type="nativeType" :disabled="loading?true:null" :class="`py-${sizes['p-y']} px-${sizes['p-x']} text-${sizes['font']} ${theme.Button.body}`" :style="buttonStyle" <button :type="nativeType" :disabled="loading?true:null" :class="`py-${sizes['p-y']} px-${sizes['p-x']} text-${sizes['font']} ${theme.Button.body}`" :style="buttonStyle"
class="btn" @click="$emit('click',$event)" class="btn">
>
<template v-if="!loading"> <template v-if="!loading">
<slot /> <slot />
</template> </template>

View File

@ -55,7 +55,7 @@
/> />
<template v-else> <template v-else>
<div v-if="field.type === 'nf-text' && field.content" :id="field.id" :key="field.id" <div v-if="field.type === 'nf-text' && field.content" :id="field.id" :key="field.id"
class="nf-text w-full px-2 mb-3" :class="[getFieldAlignClasses(field)]" class="nf-text w-full mb-3" :class="[getFieldAlignClasses(field)]"
v-html="field.content" v-html="field.content"
/> />
<div v-if="field.type === 'nf-code' && field.content" :id="field.id" :key="field.id" <div v-if="field.type === 'nf-code' && field.content" :id="field.id" :key="field.id"