ShoppingItemList Klasse erstellt
Diese Klasse repräsentiert einen Gegenstand in der List, er handelt das Rendering von sich selbst zB wie es im Normalzustand aussieht und wie es beim Bearbeiten aussieht. Die Funktion render() kann dabei von außen aufgerufen werden um ein <li> Element zurückzubekommen
This commit is contained in:
1 parent
c0e4057ae1
commit
b92002f3cc
1 file changed
+23
@@ -0,0 +1,23 @@
|
||||
export class ShoppingListItem {
|
||||
|
||||
constructor(name, amount, onChange) {
|
||||
this.name = name;
|
||||
this.amount = amount;
|
||||
this.isDone = false;
|
||||
this.isEditing = false;
|
||||
this.remove = false;
|
||||
this.onChange = onChange;
|
||||
}
|
||||
|
||||
//gibt ein <li> Element zurück
|
||||
render() {
|
||||
let li;
|
||||
if (this.isEditing) {
|
||||
li = this.#renderEditing();
|
||||
} else {
|
||||
li = this.#renderNormal()
|
||||
}
|
||||
return li;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user