main.js -> list.js, Frontend rendering komplett entfernt
This commit is contained in:
1 parent
c371cf00df
commit
de864daf3d
1 file changed
+49
@@ -0,0 +1,49 @@
|
||||
import { ShoppingListItem } from "../shared/ShoppingList.js";
|
||||
import { ShoppingCategory } from "./ShoppingCategory.js";
|
||||
|
||||
const addItemForm = document.querySelector(".addItemForm");
|
||||
const addCategoryForm = document.querySelector(".addCategoryForm")
|
||||
const itemListElement = document.querySelector(".displayedList");
|
||||
const deleteAllDoneItemsButton = document.querySelector(".deleteAllDoneItemsButton");
|
||||
|
||||
const currentList = document.querySelector(".list");
|
||||
|
||||
let listElements = []; // Liste der erstellten Items und Kategorien
|
||||
|
||||
function addNewCategory(categoryName) {
|
||||
let id = currentList.id;
|
||||
fetch(`/api/list/${id}/category/`,
|
||||
{
|
||||
method: "POST"
|
||||
, body: JSON.stringify({ "categoryName": categoryName })
|
||||
, headers: { "Content-Type": "application/json" }
|
||||
}).then(r => console.log("Add new category"));
|
||||
listElements.push(new ShoppingCategory(categoryName, renderAddItemPrompt, renderItemList));
|
||||
renderItemList();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
export function addNewItem(itemName, itemAmount, categoryID) {
|
||||
let id = currentList.id;
|
||||
fetch(`/api/list/${id}/item`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
"itemName": itemName,
|
||||
"itemAmount": itemAmount,
|
||||
"categoryID": categoryID
|
||||
}),
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}).then(r => console.log("added new item"));
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
Reference in new issue
Block a user