api und frontend funktionen ausgelagert in unterschiedliche dateien
This commit is contained in:
1 parent
de864daf3d
commit
2bed4c24a4
3 files changed
+59
-37
No files matched your search
@@ -1,45 +1,11 @@
|
||||
import { ShoppingListItem } from "../shared/ShoppingList.js";
|
||||
import { ShoppingListItem } from "../shared/";
|
||||
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");
|
||||
import * as api from "./listAPI.js"
|
||||
import * as ui from "./listFrontend.js"
|
||||
|
||||
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() {
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
export function addItem(currentList, 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;
|
||||
}
|
||||
|
||||
|
||||
export function deleteItem() {
|
||||
|
||||
}
|
||||
|
||||
export function addCategory() {
|
||||
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 deleteCategory() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
export function addItem() {
|
||||
|
||||
}
|
||||
|
||||
export function deleteItem() {
|
||||
|
||||
}
|
||||
|
||||
export function addCategory() {
|
||||
|
||||
}
|
||||
|
||||
export function deleteCategory() {
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user