Files
docuseal/app/javascript/form.js
T

39 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-05-25 22:47:52 +03:00
import { createApp, reactive } from 'vue'
2023-05-31 23:19:20 +03:00
import Form from './submission_form/form'
2023-06-20 20:50:15 +00:00
import DownloadButton from './elements/download_button'
2023-05-25 22:47:52 +03:00
2023-06-20 20:50:15 +00:00
window.customElements.define('download-button', DownloadButton)
2023-05-31 23:19:20 +03:00
window.customElements.define('submission-form', class extends HTMLElement {
2023-05-25 22:47:52 +03:00
connectedCallback () {
this.appElem = document.createElement('div')
2023-05-31 23:19:20 +03:00
this.app = createApp(Form, {
2023-09-03 14:05:31 +03:00
submitter: JSON.parse(this.dataset.submitter),
2023-06-30 20:31:17 +03:00
canSendEmail: this.dataset.canSendEmail === 'true',
2023-09-22 21:50:39 +03:00
goToLast: this.dataset.goToLast === 'true',
2023-07-12 01:24:25 +03:00
isDemo: this.dataset.isDemo === 'true',
2023-09-03 20:44:54 +03:00
attribution: this.dataset.attribution !== 'false',
2024-01-26 17:43:52 +02:00
withConfetti: this.dataset.withConfetti !== 'false',
2024-05-12 12:08:18 +03:00
withDisclosure: this.dataset.withDisclosure === 'true',
withTypedSignature: this.dataset.withTypedSignature !== 'false',
2024-03-23 23:16:40 +02:00
authenticityToken: document.querySelector('meta[name="csrf-token"]')?.content,
2023-05-25 22:47:52 +03:00
values: reactive(JSON.parse(this.dataset.values)),
2024-04-05 16:16:30 +03:00
completedButton: JSON.parse(this.dataset.completedButton || '{}'),
completedMessage: JSON.parse(this.dataset.completedMessage || '{}'),
2024-01-14 12:11:13 +02:00
completedRedirectUrl: this.dataset.completedRedirectUrl,
2023-05-25 22:47:52 +03:00
attachments: reactive(JSON.parse(this.dataset.attachments)),
fields: JSON.parse(this.dataset.fields)
})
this.app.mount(this.appElem)
this.appendChild(this.appElem)
}
disconnectedCallback () {
this.app?.unmount()
this.appElem?.remove()
}
})