async function showingitschoices( choicesContainer, selectedField, selectedEventValue,…
- User
async function showingitschoices( choicesContainer, selectedField, selectedEventValue, selectedFieldName, buttonContainer, container, fieldNameContainer, selectedChoices = null, obj, ruleIndex, fieldIndex ) { choicesContainer.innerHTML = '';
console.log("Existing Choices Values:", selectedChoices);
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 multiple options'); choicesDropdown.setAttribute('multiple', 'true');// Map choices and pre-select based on selectedChoices selectedField.choices.forEach((choice) => { const option = document.createElement('fw-select-option'); option.setAttribute('value', choice.id); option.textContent = choice.value;
// Check if this choice is in the selectedChoices array if (selectedChoices && selectedChoices.includes(String(choice.id))) { option.setAttribute('selected', 'true'); console.log(`Existing value mapped: ${choice.value} (ID: ${choice.id}) for field: ${selectedFieldName}`); } choicesDropdown.appendChild(option);});
choicesContainer.appendChild(choicesDropdown);
// Event listener for fwChange to update JSON with selected choices choicesDropdown.addEventListener('fwChange', (event) => { const selectedChoiceIds = Array.isArray(event.target.value) ? event.target.value : [event.target.value];
const findRule = ticketworkflowconditions[ruleIndex]; const combination = findRule.event.combination; const newKeyValue = { [selectedFieldName]: selectedChoiceIds.length ? selectedChoiceIds : null }; combination.splice(fieldIndex, 1, newKeyValue); console.log(`Updated JSON with field: ${selectedFieldName}, choices: ${selectedChoiceIds}`); console.log(`Updated ticketworkflowconditions: ${JSON.stringify(ticketworkflowconditions, null, 2)}`);}); }
function createAdditionalDropdowns(container, obj, ruleIndex, fieldIndex, fields) { const fieldNameContainer = document.createElement('div'); fieldNameContainer.classList.add('col-md-2', 'field-name-container', 'offset-md-2'); const choicesContainer = document.createElement('div'); choicesContainer.classList.add('col-md-2', 'choices-container'); const buttonContainer = document.createElement('div'); buttonContainer.classList.add('col-md-3', 'button-container'); buttonContainer.style.marginTop = '-23px';
container.appendChild(fieldNameContainer); container.appendChild(choicesContainer); container.appendChild(buttonContainer);
fieldschoosingvalues( container.querySelector('.event-name-dropdown').value, fieldNameContainer, choicesContainer, buttonContainer, container, null, null, obj, ruleIndex, fieldIndex, fields );
- Assistant
There are a few potential reasons that could explain why is not being correctly mapped to the . Let's analyze your code and potential issues step by step:
- User
remove stringify
- Assistant