function checkAddButtonVisibility() { const dropdowns =…
- User
function checkAddButtonVisibility() { const dropdowns = container.querySelectorAll(".field-name-dropdown"); const selectedFieldValues = Array.from(dropdowns) .map((dropdown) => dropdown.value) .filter((value) => value !== "");
const areAllFieldsSelected = selectedFieldValues.length >= fields.length; const lastDropdownWrapper = dropdowns.length > 0 ? dropdowns[dropdowns.length - 1].closest(".button-container") : null; if (areAllFieldsSelected) { console.log("All fields are selected. Hiding Add Button."); if (addButton.parentNode) { addButton.parentNode.removeChild(addButton); } } else { console.log("Fields are still available. Add Button will be shown."); if (dropdowns.length > 0 && lastDropdownWrapper) { if (!lastDropdownWrapper.contains(addButton)) { lastDropdownWrapper.appendChild(addButton); addButton.style.visibility = "visible"; } } addButton.disabled = false; // Always enable Add Button if it's displayed. }}
in this in which part addbutton disable true
- Assistant
In the provided
checkAddButtonVisibilityfunction, theaddButtonis disabled only in the case where the button is hidden. To disable theaddButtonwhen all fields are selected, you need to setaddButton.disabled = true;right before you remove theaddButtonfrom the DOM.Here's how you can modify the function to disable the
addButtonwhen it is hidden: - User
add button should always be enabled
- Assistant
If the requirement is that the "Add Button" should always be enabled, regardless of whether it is displayed or hidden, you need to modify the function accordingly. This means you should not disable the button when all fields are selected; instead, you should manage its visibility only.
- User
deleteButton.addEventListener("click", () => { console.log(
Delete button clicked for mapping at index ${fieldIndex});const modal = document.getElementById("composition"); if (modal) { modal.setAttribute("is-open", "true"); modal.querySelector("fw-modal-title").innerHTML =
<span>Delete Mapping</span>; modal.querySelector("fw-modal-content").innerHTML =<span>Are you sure you want to delete this field mapping?</span>;modal.addEventListener( "fwSubmit", () => { const findRule = ticketworkflowconditions[ruleIndex]; if (findRule) { const combination = findRule.event.combination; // Ensure the correct combination is removed if (combination[fieldIndex]) { combination.splice(fieldIndex, 1); // Remove the specific combination at fieldIndex } ticketworkflowconditions[ruleIndex] = { ...findRule, event: { ...findRule.event, combination }, }; console.log(`Updated ticketworkflowconditions after delete:`, JSON.stringify(ticketworkflowconditions, null, 2)); } // Remove UI elements fieldNameContainer.removeChild(fieldDropdown); choicesContainer.innerHTML = ""; buttonContainer.removeChild(deleteButtonWrapper); modal.removeAttribute("is-open"); checkAddButtonVisibility(); }, { once: true } ); modal.querySelector("fw-modal-footer").addEventListener( "fwClose", () => { modal.removeAttribute("is-open"); console.log("Delete operation was cancelled."); }, { once: true } ); - Assistant
- User
deleteButton.addEventListener("click", () => { console.log(
Delete button clicked for mapping at index ${fieldIndex}); - Assistant