From ab8a85e1f1f1a81f7600e26a404319e066ba40e3 Mon Sep 17 00:00:00 2001 From: Tim Aldinger Date: Tue, 6 Oct 2026 16:28:09 +0200 Subject: [PATCH] =?UTF-8?q?addItem=20f=C3=BCr=20frotnend=20implemenentiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit das item wird entsprechend nach vorhandener categoryID einer Kategorie unterstellt oder nicht fixes #3 --- src/main/resources/static/js/list/listFrontend.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/resources/static/js/list/listFrontend.js b/src/main/resources/static/js/list/listFrontend.js index f5f9d05..9d7d16e 100644 --- a/src/main/resources/static/js/list/listFrontend.js +++ b/src/main/resources/static/js/list/listFrontend.js @@ -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) {