| | |
| | | form: form.dataset.formId, |
| | | format: field.dataset.tagFormat??'first_field' |
| | | }; |
| | | console.log('Registering Tag List with config', config); |
| | | if (!config.ui.input || !config.ui.add || !config.ui.items) return; |
| | | |
| | | field.dataset.tagListId = config.id; |
| | |
| | | let index = config.ui.items?.children?.length??0; |
| | | el.dataset.index = index; |
| | | manyRefs.inputs?.forEach(input => { |
| | | let wrapper = window.closest('.tag-item'); |
| | | let wrapper = input.closest('.tag-item'); |
| | | window.prefixInput(input, `${el.dataset.fieldName}:${index}:`, wrapper) |
| | | }); |
| | | |
| | |
| | | } |
| | | }, |
| | | ); |
| | | |
| | | config.ui.inputs = Array.from(field.querySelectorAll(this.selectors.tagList.inputs)); |
| | | config.ui.value = Array.from(field.querySelectorAll(this.selectors.tagList.value)); |
| | | this.tagLists.set(config.id, config); |
| | | console.log('Adding tag list listeners to ', field); |
| | | this.addTagListListeners(field); |
| | | }); |
| | | |
| | |
| | | } |
| | | |
| | | handleTagListClick(e) { |
| | | if (e.target.matches(this.selectors.tagList.add)) { |
| | | if (window.targetCheck(e,this.selectors.tagList.add)) { |
| | | this.addTagListItem(e.target.closest('[data-tag-list-id]')); |
| | | } else if (e.target.matches(this.selectors.tagList.remove)) { |
| | | this.removeTagListItem(e.target.closest(this.selectors.tagList.remove)); |
| | |
| | | |
| | | let data = {}; |
| | | let hasValue = false; |
| | | |
| | | for (let input of config.ui.inputs) { |
| | | this.validateField(input); |
| | | const fieldName = input.name.replace('new_',''); |
| | |
| | | label = Object.values(data).join(', '); |
| | | break; |
| | | default: |
| | | if (format.includes('{')) { |
| | | if (config.format.includes('{')) { |
| | | let label = config.format; |
| | | for (const [key, value] of Object.entries(data)) { |
| | | label = label.replace(`{${key}}`, value); |