diff --git a/src/main/resources/static/js/list/list.js b/src/main/resources/static/js/list/list.js index 43e5307..08e25c9 100644 --- a/src/main/resources/static/js/list/list.js +++ b/src/main/resources/static/js/list/list.js @@ -65,6 +65,7 @@ function init() { const checkbox = li.querySelector("input[type=checkbox]"); deleteCategory(checkbox.checked, li.id); } + }); document.querySelector(".displayedList").addEventListener("change", (e) => { if (e.target.matches(".item__markAsDone")) { diff --git a/src/main/resources/static/js/list/listFrontend.js b/src/main/resources/static/js/list/listFrontend.js index 74cad93..50401b8 100644 --- a/src/main/resources/static/js/list/listFrontend.js +++ b/src/main/resources/static/js/list/listFrontend.js @@ -22,7 +22,14 @@ export function addCategory(categoryAsJSON) { const list = document.querySelector(".displayedList"); const category = ShoppingCategory.fromJSON(categoryAsJSON); - list.appendChild(category.render()); + list.appendChild(category.render()); //fügt Kategorie der Liste hinzu + + const categorySelect = document.querySelector(".addItemForm__categorySelect"); + const newCategoryOption = document.createElement("option"); + newCategoryOption.setAttribute("value", categoryAsJSON.id); + newCategoryOption.textContent = category.categoryName; + + categorySelect.appendChild(newCategoryOption); } export function deleteCategory(deleteAllItems, categoryID) { @@ -32,6 +39,8 @@ export function deleteCategory(deleteAllItems, categoryID) { if (ul) document.querySelector(".displayedList").append(...ul.children); } category.remove() + document.querySelector(`option[value='${categoryID}']`).remove(); + } export function deleteAllDoneItems() {