Enhance Form Functionality and Submission Logic

- Added `restart` and `formManager` to the exposed properties in `OpenCompleteForm.vue` for improved form management.
- Implemented a watcher in `FormEditorPreview.vue` to reset the form when switching modes, enhancing user experience during form interactions.
- Updated the `restartForm` function in `FormEditorPreview.vue` to handle errors gracefully and ensure the form can be restarted correctly.
- Modified the `useFormSubmission.js` to conditionally perform submissions based on the form mode strategy, allowing for mock submissions in preview mode.

These changes aim to improve the overall functionality and user experience of form handling within the application, ensuring better management and interaction with forms.
This commit is contained in:
JhumanJ
2025-05-19 12:23:37 +02:00
parent 1ba7805e35
commit 088e76955d
3 changed files with 41 additions and 7 deletions

View File

@@ -398,7 +398,9 @@ const addPasswordError = (msg) => {
}
defineExpose({
addPasswordError
addPasswordError,
restart,
formManager
})
</script>

View File

@@ -142,6 +142,13 @@ watch(() => form.value.dark_mode, () => {
handleDarkModeChange()
})
// Watch for form mode changes to reset the form when switching modes
watch(formMode, () => {
if (previewFormSubmitted.value) {
restartForm()
}
})
onMounted(() => {
handleDarkModeChange()
})
@@ -163,7 +170,16 @@ function handleDarkModeChange() {
function restartForm() {
previewFormSubmitted.value = false
formPreview.value.restart()
try {
// Try using the component reference first
if (formPreview.value && typeof formPreview.value.restart === 'function') {
formPreview.value.restart()
return
}
} catch (error) {
console.error('Error restarting form:', error)
}
}
function toggleExpand() {