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-05-25 22:47:52 +03:00
|
|
|
|
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-05-25 22:47:52 +03:00
|
|
|
submissionSlug: this.dataset.submissionSlug,
|
|
|
|
|
authenticityToken: this.dataset.authenticityToken,
|
|
|
|
|
values: reactive(JSON.parse(this.dataset.values)),
|
|
|
|
|
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()
|
|
|
|
|
}
|
|
|
|
|
})
|