0c9ea page break validation (#455)
* fix password reset bug * page break precognition validation * precognition validation tests --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -110,6 +110,7 @@
|
||||
:theme="theme"
|
||||
class="mt-2 px-8 mx-1"
|
||||
@click.stop="nextPage"
|
||||
:loading="dataForm.busy"
|
||||
>
|
||||
{{ currentFieldsPageBreak.next_btn_text }}
|
||||
</open-form-button>
|
||||
@@ -442,9 +443,17 @@ export default {
|
||||
return false
|
||||
},
|
||||
nextPage() {
|
||||
this.currentFieldGroupIndex += 1
|
||||
window.scrollTo({top: 0, behavior: 'smooth'})
|
||||
return false
|
||||
const fieldsToValidate = this.currentFields.map(f => f.id)
|
||||
this.dataForm.busy = true
|
||||
this.dataForm.validate('POST', '/forms/' + this.form.slug + '/answer', {}, fieldsToValidate)
|
||||
.then((data) => {
|
||||
this.currentFieldGroupIndex += 1
|
||||
this.dataForm.busy = false
|
||||
window.scrollTo({top: 0, behavior: 'smooth'})
|
||||
}).catch(err => {
|
||||
this.dataForm.busy = false
|
||||
})
|
||||
return false;
|
||||
},
|
||||
isFieldHidden(field) {
|
||||
return (new FormLogicPropertyResolver(field, this.dataFormValue)).isHidden()
|
||||
|
||||
37
client/composables/lib/vForm/Form.js
vendored
37
client/composables/lib/vForm/Form.js
vendored
@@ -146,6 +146,43 @@ class Form {
|
||||
})
|
||||
}
|
||||
|
||||
validate(method, url, config = {}, fieldsToValidate = {}) {
|
||||
this.startProcessing()
|
||||
const headers = {
|
||||
'Precognition': true,
|
||||
'Precognition-Validate-Only': Array.from(fieldsToValidate).join(),
|
||||
...config.headers
|
||||
}
|
||||
config = {
|
||||
body: {},
|
||||
params: {},
|
||||
url: url,
|
||||
method: method,
|
||||
headers,
|
||||
...config,
|
||||
}
|
||||
if (method.toLowerCase() === "get") {
|
||||
config.params = { ...this.data(), ...config.params }
|
||||
} else {
|
||||
config.body = { ...this.data(), ...config.data }
|
||||
|
||||
if (hasFiles(config.data) && !config.transformRequest) {
|
||||
config.transformRequest = [(data) => serialize(data)]
|
||||
}
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
opnFetch(config.url, config)
|
||||
.then((data) => {
|
||||
this.finishProcessing()
|
||||
resolve(data)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.handleErrors(error)
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
handleErrors(error) {
|
||||
this.busy = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user