ShoppingList li Element wird richtig erstellt
This commit is contained in:
1 parent
0564d81b25
commit
71d7d373eb
1 file changed
+37
-9
@@ -1,11 +1,39 @@
|
||||
|
||||
|
||||
export class ShoppingList{
|
||||
constructor(id){
|
||||
this.shoppingListName;
|
||||
this.lastModified = "";
|
||||
this.created = "";
|
||||
this.id = id;
|
||||
this.remove = false;
|
||||
}
|
||||
}
|
||||
export class ShoppingList {
|
||||
constructor(name) {
|
||||
this.listName = name;
|
||||
this.lastModified = "";
|
||||
this.created = "";
|
||||
this.listID = 0;
|
||||
}
|
||||
|
||||
static fromJSON(listAsJSON) {
|
||||
const list = new ShoppingList(listAsJSON.listName);
|
||||
list.listID = listAsJSON.listID;
|
||||
return list;
|
||||
}
|
||||
|
||||
render() {
|
||||
const li = document.createElement("li");
|
||||
const a = document.createElement("a");
|
||||
const editButton = document.createElement("button");
|
||||
const deleteButton = document.createElement("button");
|
||||
|
||||
li.classList.add("list");
|
||||
li.id = this.listID;
|
||||
|
||||
a.setAttribute("href", `/list/${this.listID}`);
|
||||
a.textContent = this.listName;
|
||||
|
||||
editButton.classList.add("list__editButton");
|
||||
editButton.textContent = "Liste bearbeiten";
|
||||
|
||||
deleteButton.classList.add("list__deleteButton");
|
||||
deleteButton.textContent = "Liste löschen";
|
||||
|
||||
li.append(a, editButton, deleteButton);
|
||||
|
||||
return li;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user