in this code in which part existing field value is mapped in this code ? async function…
- User
in this code in which part existing field value is mapped in this code ?
async function getFieldnamesfrom1stapi( fieldNameContainer, fields, choicesContainer, selectedEventValue, buttonContainer, container, selectedFieldName = null, selectedChoices = [], obj, ruleIndex, fieldIndex ) { if (!selectedEventValue) { console.error("Select an event before proceeding."); return; }
// // Create the field dropdown // const fieldDropdown = document.createElement('fw-select'); // fieldDropdown.classList.add('field-name-dropdown'); // fieldDropdown.setAttribute('label', 'Ticket Fields'); // fieldDropdown.setAttribute('required', 'true'); // fieldDropdown.setAttribute('placeholder', 'Choose a field'); // fieldDropdown.setAttribute('hint-text', 'Select singular option');
// Create the field dropdown const fieldDropdown = document.createElement('fw-select'); fieldDropdown.classList.add('field-name-dropdown'); fieldDropdown.setAttribute('label', 'Ticket Fields'); fieldDropdown.setAttribute('required', 'true'); fieldDropdown.setAttribute('placeholder', 'Choose a field'); fieldDropdown.setAttribute('hint-text', 'Select singular option '); fieldDropdown.style.marginBottom = '30px';
const selectedFields = Array.from(container.querySelectorAll('.field-name-dropdown')) .map((dropdown) => dropdown.value) .filter((value) => value);
fields .filter((field) => !selectedFields.includes(field.name)) .forEach((field) => { const option = document.createElement('fw-select-option'); option.setAttribute('value', field.name); option.textContent = field.label; fieldDropdown.appendChild(option);
if (selectedFieldName && field.name === selectedFieldName) { option.setAttribute('selected', 'selected'); } });fieldNameContainer.appendChild(fieldDropdown);
const deleteButton = document.createElement('fw-button'); deleteButton.setAttribute('size', 'icon'); deleteButton.classList.add('delete-button'); deleteButton.innerHTML = '';
const deleteButtonWrapper = document.createElement('div'); deleteButtonWrapper.classList.add('delete-button-container', 'mt-5');
deleteButtonWrapper.style.marginBottom = '80px';deleteButtonWrapper.appendChild(deleteButton); buttonContainer.appendChild(deleteButtonWrapper);
const existingAddButton = container.querySelector('.add-button'); if (existingAddButton) { existingAddButton.remove(); }
const addButton = document.createElement('fw-button'); addButton.setAttribute('size', 'icon'); addButton.classList.add('add-button'); addButton.innerHTML = ''; addButton.disabled = true;
const isFirstSet = container.querySelectorAll('.field-name-dropdown').length === 1;
addButton.style.marginTop = '';
if (isFirstSet) { addButton.style.marginTop = '48px'; } else { addButton.style.marginTop = '-150px'; }
// Append the Add button to the container buttonContainer.appendChild(addButton);
- Assistant
- User
ok in that part after mapping existing fields values . freeze the fields dropdown not the choices dropdown
- Assistant
- User
it is not freezing fields dropdown
- Assistant
- User
fieldDropdown.addEventListener("fwChange", async (event) => { const newSelectedFieldName = event.target.value;
if (!newSelectedFieldName) {
choicesContainer.innerHTML = ""; const findRule = ticketworkflowconditions[ruleIndex]; if (findRule) { findRule.event.combination[fieldIndex] = {}; } console.log("Field deselected. Choices cleared."); return;}
const newSelectedField = fields.find((field) => field.name === newSelectedFieldName); if (newSelectedField) { const findRule = ticketworkflowconditions[ruleIndex]; if (findRule) {
findRule.event.combination[fieldIndex] = { [newSelectedFieldName]: selectedChoices || [], }; }console.log(`Field changed. Updated backend:`, JSON.stringify(ticketworkflowconditions, null, 2)); await showingitschoices( choicesContainer, newSelectedField, selectedEventValue, newSelectedFieldName, buttonContainer, container, fieldNameContainer, [], // Clear choices if necessary obj, ruleIndex, fieldIndex ); console.log(`Field changed to: ${newSelectedFieldName}`);} else { console.error("Field not found in the Dropdown"); }
checkAddButtonVisibility(); });
add your logic in this code without removing anything
- Assistant
Certainly! Below is your original
fieldDropdown.addEventListener("fwChange", ...)code where I've added logic to freeze thefieldDropdownafter a field is selected. It is carefully incorporated without removing any of your existing code or logic. - User
- Assistant