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:
Chirag Chhatrala 2023-02-25 14:56:06 +05:30 committed by GitHub
parent 556fcb9e1a
commit 4da7e4460f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

View File

@ -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

View File

@ -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
}
}
}

View File

@ -37,7 +37,8 @@ export default {
data: () => ({
shareFormConfig: {
hide_title: false
hide_title: false,
auto_submit: false
}
}),