| | |
| | | data: this.changes.get(form.id)?.changes??{}, |
| | | }); |
| | | } |
| | | if (form.options.endpoint && !form.options.handled) { |
| | | console.log('Submitting form...'); |
| | | await this.handleServerSave(form, this.collectFormData(form.form)); |
| | | } |
| | | |
| | | if (form.options.endpoint && !form.options.handled) { |
| | | e.preventDefault(); |
| | | console.log('Submitting form...', this.changes.get(form.id)?.changes ?? {}); |
| | | await this.handleServerSave(form, this.changes.get(form.id)?.changes ?? {}); |
| | | } |
| | | |
| | | if (form.options.showSummary) { |
| | |
| | | } |
| | | |
| | | if (form.tabs) { |
| | | console.log('Updating step progress on change'); |
| | | this.updateStepProgress(form); |
| | | } |
| | | |
| | |
| | | async handleServerSave(form, changes) { |
| | | this.cancelServerSave(form.id); |
| | | |
| | | if (window.jvbQueue) { |
| | | if (form.useQueue && window.jvbQueue) { |
| | | changes.user = window.auth.getUser(); |
| | | window.jvbQueue.addToQueue({ |
| | | endpoint: form.options.endpoint, |
| | |
| | | headers: form.options.headers??{}, |
| | | }); |
| | | } else { |
| | | await window.auth.fetch(jvbBase.api+form.options.endpoint, { |
| | | await window.auth.fetch(jvbSettings.api+form.options.endpoint, { |
| | | body: changes, |
| | | headers: form.options.headers??{}, |
| | | method: 'POST', |
| | | }); |
| | | } |
| | | } |
| | |
| | | autoUpload: false, |
| | | imageMeta: true, |
| | | delay: 1500, |
| | | useQueue: true, |
| | | endpoint: Object.hasOwn(form.dataset, 'save') ? form.dataset.save: '', |
| | | showStatus: true, |
| | | showSummary: false, |
| | |
| | | |
| | | field.classList.remove('has-success'); |
| | | field.classList.add('has-error'); |
| | | field.scrollIntoView({ |
| | | behavior: "smooth", |
| | | block: "center", |
| | | inline: "nearest" |
| | | }); |
| | | field.querySelector(this.inputSelectors)?.focus(); |
| | | |
| | | if (item.ui.message) { |
| | | item.ui.message.hidden = false; |