MCPcopy Create free account
hub / github.com/docusealco/docuseal /

Class

app/javascript/application.js:154–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152safeRegisterElement('confirm-upload', ConfirmUpload)
153
154safeRegisterElement('template-builder', class extends HTMLElement {
155 connectedCallback () {
156 document.addEventListener('turbo:submit-end', this.onSubmit)
157
158 this.appElem = document.createElement('div')
159
160 this.appElem.classList.add('md:h-screen')
161
162 const template = reactive(JSON.parse(this.dataset.template))
163
164 this.app = createApp(TemplateBuilder, {
165 template,
166 customFields: reactive(JSON.parse(this.dataset.customFields || '[]')),
167 dynamicDocuments: reactive(JSON.parse(this.dataset.dynamicDocuments || '[]')),
168 backgroundColor: '#faf7f5',
169 locale: this.dataset.locale,
170 withPhone: this.dataset.withPhone === 'true',
171 withPrefillable: template.fields?.some((f) => f.prefillable),
172 withVerification: ['true', 'false'].includes(this.dataset.withVerification) ? this.dataset.withVerification === 'true' : null,
173 withKba: ['true', 'false'].includes(this.dataset.withKba) ? this.dataset.withKba === 'true' : null,
174 withLogo: this.dataset.withLogo !== 'false',
175 withFieldsDetection: this.dataset.withFieldsDetection === 'true',
176 withDetectExistingFields: this.dataset.withDetectExistingFields === 'true',
177 withRevisions: true,
178 withRevisionsMenu: this.dataset.withRevisionsMenu === 'true',
179 editable: this.dataset.editable !== 'false',
180 authenticityToken: document.querySelector('meta[name="csrf-token"]')?.content,
181 withCustomFields: true,
182 withPayment: this.dataset.withPayment === 'true',
183 isPaymentConnected: this.dataset.isPaymentConnected === 'true',
184 withFormula: this.dataset.withFormula === 'true',
185 withSendButton: this.dataset.withSendButton !== 'false',
186 withSignYourselfButton: this.dataset.withSignYourselfButton !== 'false',
187 withConditions: this.dataset.withConditions === 'true',
188 withDynamicDocuments: this.dataset.withDynamicDocuments === 'true',
189 withGoogleDrive: this.dataset.withGoogleDrive === 'true',
190 pagePreviewFormat: this.dataset.pagePreviewFormat || '.jpg',
191 withReplaceAndCloneUpload: true,
192 withDownload: true,
193 currencies: (this.dataset.currencies || '').split(',').filter(Boolean),
194 acceptFileTypes: this.dataset.acceptFileTypes,
195 showTourStartForm: this.dataset.showTourStartForm === 'true'
196 })
197
198 this.component = this.app.mount(this.appElem)
199
200 this.appendChild(this.appElem)
201 }
202
203 onSubmit = (e) => {
204 if (e.detail.success) {
205 if (e.detail?.formSubmission?.formElement?.id === 'submitters_form') {
206 e.detail.fetchResponse.response.json().then((data) => {
207 this.component.template.submitters = data.submitters
208 })
209 }
210
211 if (e.detail?.formSubmission?.formElement?.action?.endsWith('/prefillable_fields')) {

Callers

nothing calls this directly

Calls 1

textMethod · 0.80

Tested by

no test coverage detected