| | |
| | | let field = key.replace('_tempUpload', ''); |
| | | |
| | | if (Object.hasOwn(form.ui.uploads, field)) { |
| | | uploads.push(value); |
| | | uploads = [ |
| | | ... uploads, |
| | | ... value |
| | | ]; |
| | | } |
| | | } |
| | | } |
| | |
| | | }); |
| | | } |
| | | let changes = this.changes.get(form.id); |
| | | //If it is temporary uploads, we need to store them all |
| | | if (name.includes('_tempUpload')) { |
| | | if (!Object.hasOwn(changes.changes, name)) { |
| | | changes.changes[name] = []; |
| | | } |
| | | changes.changes[name].push(value); |
| | | } else { |
| | | changes.changes[name] = value; |
| | | } |
| | | |
| | | this.changes.set(form.id, changes); |
| | | if (form.options.cache) { |
| | | this.scheduleBackup(); |
| | |
| | | * @param {object} options |
| | | */ |
| | | registerForm(form, options) { |
| | | options = { |
| | | autoUpload: false, |
| | | imageMeta: true, |
| | | delay: 1500, |
| | | endpoint: Object.hasOwn(form.dataset, 'save') ? form.dataset.save: '', |
| | | showStatus: true, |
| | | showSummary: false, |
| | | cache: true, |
| | | ignore: [], |
| | | ... options |
| | | }; |
| | | //Bail if form already registered |
| | | if (Object.hasOwn(form.dataset, 'formId') && this.forms.has(form.dataset.formId)) return; |
| | | |
| | |
| | | element: form, |
| | | id: formId, |
| | | status: '', |
| | | options: { |
| | | autoUpload: options.autoUpload??false, |
| | | imageMeta: options.imageMeta??true, |
| | | delay: options.delay??1500, |
| | | endpoint: options.save??form.dataset.save??'', |
| | | showStatus: options.showStatus??true, |
| | | showSummary: options.showSummary??false, |
| | | cache: options.cache??true, |
| | | ignore: options.ignore??[] |
| | | }, |
| | | options: options, |
| | | ui: window.uiFromSelectors(this.selectors.forms, form) |
| | | }; |
| | | |