onDelete für Kategorien hinzugefügt
This commit is contained in:
1 parent
a0c17a9541
commit
1e542236d0
2 files changed
+4
-3
No files matched your search
@@ -1,10 +1,11 @@
|
||||
export class ShoppingCategory {
|
||||
|
||||
constructor(categoryName) {
|
||||
constructor(categoryName, onDelete) {
|
||||
this.categoryName = categoryName;
|
||||
this.itemsInCategory = [];
|
||||
this.remove = false;
|
||||
this.isEditing = false;
|
||||
this.onDelete = onDelete;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
+2
-2
@@ -8,10 +8,11 @@ const itemListElement = document.querySelector(".list__displayedList");
|
||||
let listElements = []; // Liste der erstellten Items und Kategorien
|
||||
|
||||
function addNewCategory(categoryName) {
|
||||
listElements.push(new ShoppingCategory(categoryName));
|
||||
listElements.push(new ShoppingCategory(categoryName, renderItemList));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function addNewItem(itemName, itemAmount, category) {
|
||||
if (category) {
|
||||
category = listElements.find((element) => element instanceof ShoppingCategory && element.categoryName == category)
|
||||
@@ -24,7 +25,6 @@ function addNewItem(itemName, itemAmount, category) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function renderItemList() {
|
||||
listElements = listElements.filter(item => !item.remove)
|
||||
itemListElement.innerHTML = ""; //reset innerItemList
|
||||
|
||||
Reference in new issue
Block a user