async function showingitschoices( choicesContainer, selectedField, selectedEventValue,…
- User
async function showingitschoices( choicesContainer, selectedField, selectedEventValue, selectedFieldName, buttonContainer, container, fieldNameContainer, selectedChoices = null ) { choicesContainer.innerHTML = '';
const choicesDropdown = document.createElement('fw-select'); choicesDropdown.classList.add('choices-dropdown'); choicesDropdown.setAttribute('label',
${selectedFieldName}); choicesDropdown.setAttribute('required', 'true'); choicesDropdown.setAttribute('placeholder',Choose ${selectedFieldName}); choicesDropdown.setAttribute('hint-text', 'Select singular option');selectedField.choices.forEach(choice => { const option = document.createElement('fw-select-option'); option.setAttribute('value', choice.id); option.textContent = choice.value; choicesDropdown.appendChild(option);
if (selectedChoices && selectedChoices.includes(String(choice.id))) { option.setAttribute('selected', 'selected'); }});
choicesContainer.appendChild(choicesDropdown);
const addButton = document.createElement('button'); addButton.textContent = 'Add'; addButton.classList.add('btn', 'btn-primary', 'mt-2'); buttonContainer.appendChild(addButton);
choicesDropdown.addEventListener('fwChange', (event) => { const selectedChoiceId = event.target.value;
if (!ticketworkflowconditions[selectedEventValue]) { ticketworkflowconditions[selectedEventValue] = { combinations: [{ isEnabled: true, fields: {} }] }; } let combination = ticketworkflowconditions[selectedEventValue].combinations[0]; combination.fields[selectedFieldName] = selectedChoiceId; console.log(`Updated JSON with field: ${selectedFieldName}, choice: ${selectedChoiceId}`); console.log(`Updated ticketworkflowconditions: ${JSON.stringify(ticketworkflowconditions, null, 2)}`);});
addButton.addEventListener('click', () => { createAdditionalDropdowns(container); }); }
add button should be only one time added for each choices
- Assistant