Remove vform - working on form public page

This commit is contained in:
Julien Nahum
2023-12-24 20:19:59 +01:00
parent 8db2b09767
commit e2dd0295ff
32 changed files with 951 additions and 813 deletions

View File

@@ -0,0 +1,34 @@
import {hash} from "~/lib/utils.js"
import {useStorage} from "@vueuse/core"
export const pendingSubmission = (form) => {
const formPendingSubmissionKey = computed(() => {
return (form) ? form.form_pending_submission_key + '-' + hash(window.location.href) : ''
})
const enabled = computed(() => {
return form?.auto_save ?? false
})
const set = (value) => {
if (process.server || !enabled.value) return
useStorage(formPendingSubmissionKey.value).value = JSON.stringify(value)
}
const remove = () => {
return set(null)
}
const get = (defaultValue = {}) => {
if (process.server || !enabled.value) return
const pendingSubmission = useStorage(formPendingSubmissionKey.value).value
return pendingSubmission ? JSON.parse(pendingSubmission) : defaultValue
}
return {
enabled,
set,
get
}
}

View File

@@ -1,5 +1,5 @@
import Form from "~/composables/lib/vForm/Form.js"
export const useForm = (formData) => {
export const useForm = (formData = {}) => {
return new Form(formData)
}