ul wird erstellt falls keins existiert
passiert wenn man im Frontend eine neue Kategorie erstellt
This commit is contained in:
1 parent
b5293e246c
commit
d9fd91ad8d
2 files changed
+11
-5
No files matched your search
@@ -15,6 +15,9 @@ export class ShoppingCategory extends HTMLElement {
|
||||
const deleteCategoryButton = document.createElement("button");
|
||||
const labelDeleteAllItems = document.createElement("label");
|
||||
const deleteAllItemsCheckbox = document.createElement("input");
|
||||
const ul = document.createElement("ul");
|
||||
|
||||
|
||||
|
||||
categoryHeaderDiv.classList.add("category__header");
|
||||
|
||||
@@ -35,6 +38,8 @@ export class ShoppingCategory extends HTMLElement {
|
||||
|
||||
this.prepend(categoryHeaderDiv);
|
||||
|
||||
if (!this.querySelector("ul")) this.append(ul);
|
||||
|
||||
this._rendered = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
|
||||
import { ShoppingCategory } from "../../../models/ShoppingCategory.js";
|
||||
|
||||
export function addCategory(categoryAsJSON) {
|
||||
const list = document.querySelector(".displayedList");
|
||||
const category = ShoppingCategory.fromJSON(categoryAsJSON);
|
||||
const category = document.createElement("shopping-category");
|
||||
|
||||
list.append(category.render()); //fügt Kategorie der Liste hinzu
|
||||
category.setAttribute("category-name", categoryAsJSON.categoryName);
|
||||
|
||||
list.append(category); //fügt Kategorie der Liste hinzu
|
||||
|
||||
const categorySelect = document.querySelector(".addItemForm__categorySelect");
|
||||
const newCategoryOption = document.createElement("option");
|
||||
newCategoryOption.setAttribute("value", category.categoryID);
|
||||
newCategoryOption.textContent = category.categoryName;
|
||||
newCategoryOption.setAttribute("value", categoryAsJSON.categoryID);
|
||||
newCategoryOption.textContent = categoryAsJSON.categoryName;
|
||||
|
||||
categorySelect.append(newCategoryOption);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user