| | |
| | | if (this.subscribers.size > 0) { |
| | | e.preventDefault(); |
| | | console.log('Cancelling scheduled backup and manually backing up'); |
| | | |
| | | |
| | | |
| | | if (form.options.cache) { |
| | | this.cancelBackup(); |
| | | await this.backup(); |
| | | const storedData = await this.store.get(form.id); |
| | | |
| | | if (form.options.cache) { |
| | | this.notify('form-submit', { |
| | | config: form, |
| | | data: storedData.changes |
| | |
| | | let index = config.ui.items?.children?.length??0; |
| | | el.dataset.index = index; |
| | | manyRefs.inputs?.forEach(input => { |
| | | window.prefixInput(input, `${el.dataset.fieldName}:${index}:`) |
| | | let wrapper = el.closest('[data-field]'); |
| | | window.prefixInput(input, `${el.dataset.fieldName}:${index}:`, wrapper); |
| | | }); |
| | | } |
| | | }, |
| | |
| | | let index = config.ui.items?.children?.length??0; |
| | | el.dataset.index = index; |
| | | manyRefs.inputs?.forEach(input => { |
| | | window.prefixInput(input, `${el.dataset.fieldName}:${index}:`) |
| | | let wrapper = window.closest('.tag-item'); |
| | | window.prefixInput(input, `${el.dataset.fieldName}:${index}:`, wrapper) |
| | | }); |
| | | |
| | | if (refs.label) { |
| | |
| | | * @param {HTMLElement} container |
| | | */ |
| | | reindexList(container) { |
| | | const fieldName = container.dataset.field || container.dataset.repeaterId || container.dataset.tagListId; |
| | | |
| | | Array.from(container.children).forEach((item, index) => { |
| | | item.dataset.index = `${index}`; |
| | | Array.from(item.children).forEach(child => { |
| | | if (child.type === 'hidden') { |
| | | window.prefixInput( |
| | | child, |
| | | `${container.dataset.field}:${index}:${child.dataset.field}` |
| | | ); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | //schedule save |
| | | // Find ALL inputs within this item, not just direct children |
| | | const inputs = item.querySelectorAll('input, select, textarea'); |
| | | |
| | | inputs.forEach(input => { |
| | | // Skip inputs that shouldn't be re-indexed (like file inputs) |
| | | if (input.type === 'file') return; |
| | | |
| | | // Get the field name from the input's data-field or name |
| | | const inputField = input.dataset.field || input.name.split(':').pop(); |
| | | |
| | | // Re-prefix with the new index, passing item as wrapper |
| | | window.prefixInput( |
| | | input, |
| | | `${fieldName}:${index}:`, |
| | | item // Pass the item as wrapper for label lookup |
| | | ); |
| | | }); |
| | | }); |
| | | } |
| | | /********************************************************************** |
| | | VALIDATION |