addItem für frotnend implemenentiert
das item wird entsprechend nach vorhandener categoryID einer Kategorie unterstellt oder nicht fixes #3
This commit is contained in:
1 parent
65cdc95b72
commit
ab8a85e1f1
1 file changed
+11
-1
@@ -1,7 +1,17 @@
|
||||
import { ShoppingCategory } from "./ShoppingCategory.js";
|
||||
import { ShoppingItem } from "./ShoppingItem.js";
|
||||
|
||||
export function addItem() {
|
||||
export function addItem(itemAsJSON) {
|
||||
let list;
|
||||
if (!itemAsJSON.categoryID) {
|
||||
list = document.querySelector(".displayedList");
|
||||
} else {
|
||||
list = document.getElementById(`${itemAsJSON.categoryID}`).querySelector("ul");
|
||||
}
|
||||
|
||||
const item = ShoppingItem.fromJSON(itemAsJSON);
|
||||
|
||||
list.appendChild(item.render());
|
||||
}
|
||||
|
||||
export function deleteItem(li) {
|
||||
|
||||
Reference in new issue
Block a user