Compare commits

..
3 Commits
2 changed files with 11 additions and 1 deletions

No files matched your search

@@ -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")) {
@@ -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() {