form autosubmit (#92)
* Hide form title via URL param * FormUrlPrefill smal fixes * form autosubmit --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
556fcb9e1a
commit
4da7e4460f
|
@ -1,5 +1,10 @@
|
|||
<template>
|
||||
<form v-if="dataForm" @submit.prevent="">
|
||||
<div v-if="isAutoSubmit">
|
||||
<p class="text-center p-4">
|
||||
<loader class="h-6 w-6 text-nt-blue mx-auto" />
|
||||
</p>
|
||||
</div>
|
||||
<form v-else-if="dataForm" @submit.prevent="">
|
||||
<transition name="fade" mode="out-in" appear>
|
||||
<template v-for="group, groupIndex in fieldGroups">
|
||||
<div v-if="currentFieldGroupIndex===groupIndex" :key="groupIndex" class="form-group flex flex-wrap w-full">
|
||||
|
@ -105,7 +110,8 @@ export default {
|
|||
* Used to force refresh components by changing their keys
|
||||
*/
|
||||
formVersionId: 1,
|
||||
darkModeEnabled: document.body.classList.contains('dark')
|
||||
darkModeEnabled: document.body.classList.contains('dark'),
|
||||
isAutoSubmit: false
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -242,6 +248,11 @@ export default {
|
|||
|
||||
mounted() {
|
||||
this.initForm()
|
||||
|
||||
if(window.location.href.includes('auto_submit=true')){
|
||||
this.isAutoSubmit = true
|
||||
this.submitForm()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
@ -265,6 +276,7 @@ export default {
|
|||
* If more than one page, show first page with error
|
||||
*/
|
||||
onSubmissionFailure() {
|
||||
this.isAutoSubmit = false
|
||||
if (this.fieldGroups.length > 1) {
|
||||
// Find first mistake and show page
|
||||
let pageChanged = false
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
@input="onChangeHideTitle"
|
||||
:help="hideTitleHelp"
|
||||
/>
|
||||
<toggle-switch-input :value="value.auto_submit" name="auto_submit" class="mt-4"
|
||||
label="Auto Submit Form"
|
||||
help="Form will auto submit immediate after open URL"
|
||||
@input="onChangeAutoSubmit"
|
||||
/>
|
||||
</collapse>
|
||||
</template>
|
||||
|
||||
|
@ -52,6 +57,9 @@ export default {
|
|||
methods: {
|
||||
onChangeHideTitle (val) {
|
||||
this.value.hide_title = val
|
||||
},
|
||||
onChangeAutoSubmit (val) {
|
||||
this.value.auto_submit = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ export default {
|
|||
|
||||
data: () => ({
|
||||
shareFormConfig: {
|
||||
hide_title: false
|
||||
hide_title: false,
|
||||
auto_submit: false
|
||||
}
|
||||
}),
|
||||
|
||||
|
|
Loading…
Reference in New Issue