fix: Update multiselect new skills
parent
859b91e5b7
commit
e3dc6b63f5
|
@ -1,6 +1,25 @@
|
|||
function handleSecondarySkillSelection(selectElement) {
|
||||
const skillCreator = document.querySelector("#skillCreator");
|
||||
const newSkillSelector = selectElement.closest(".row").cloneNode(true);
|
||||
const selectedOptions = Array.from(
|
||||
document.querySelectorAll("#skillCreator select[name='ssid']")
|
||||
).map((select) => select.value);
|
||||
|
||||
// Filter out already selected options
|
||||
const secondarySkillSelect =
|
||||
newSkillSelector.querySelector("#secondarySkill");
|
||||
const options = Array.from(secondarySkillSelect.options);
|
||||
options.forEach((option) => {
|
||||
if (selectedOptions.includes(option.value)) {
|
||||
option.remove();
|
||||
}
|
||||
});
|
||||
|
||||
// Check if there are any options left to select
|
||||
if (secondarySkillSelect.options.length <= 1) {
|
||||
return; // Exit if no options left
|
||||
}
|
||||
|
||||
newSkillSelector.querySelector("#secondarySkill").value = "";
|
||||
newSkillSelector.querySelector("#level").value = "1";
|
||||
newSkillSelector.querySelector(".btn-default").disabled = true;
|
||||
|
|
Loading…
Reference in New Issue