|
|
@@ -0,0 +1,63 @@
|
|
|
+import Page from "./Page.js";
|
|
|
+import Elem from "../Elem.js";
|
|
|
+
|
|
|
+export default class EditIncome extends Page{
|
|
|
+ constructor(income){
|
|
|
+ super("EditIncome", ["home", "back-viewIncome", "logout"]);
|
|
|
+
|
|
|
+ this.render(income);
|
|
|
+ }
|
|
|
+
|
|
|
+ submit(income){
|
|
|
+ event.preventDefault();
|
|
|
+
|
|
|
+ const select = this.container.querySelector.bind(this.container);
|
|
|
+ income.name = select(".name").value;
|
|
|
+ income.amount = select(".amount").value;
|
|
|
+
|
|
|
+ user.account.save();
|
|
|
+ changePage("viewIncome");
|
|
|
+ }
|
|
|
+
|
|
|
+ render(income){
|
|
|
+ new Elem("form")
|
|
|
+ .addClass("standardForm")
|
|
|
+ .onsubmit(()=>{this.submit(income)})
|
|
|
+ .append(new Elem("h1")
|
|
|
+ .text(income.name)
|
|
|
+ )
|
|
|
+ .append(new Elem("h3")
|
|
|
+ .text("Income")
|
|
|
+ )
|
|
|
+ .append(new Elem("label")
|
|
|
+ .text("Name")
|
|
|
+ .append(new Elem("input")
|
|
|
+ .type("text")
|
|
|
+ .addClass("name")
|
|
|
+ .value(income.name)
|
|
|
+ .required()
|
|
|
+ .focus()
|
|
|
+ )
|
|
|
+ )
|
|
|
+ .append(new Elem("label")
|
|
|
+ .text("Amount")
|
|
|
+ .append(new Elem("input")
|
|
|
+ .type("number")
|
|
|
+ .addClass("amount")
|
|
|
+ .value(income.amount)
|
|
|
+ .step("0.01")
|
|
|
+ .min("0")
|
|
|
+ .required()
|
|
|
+ )
|
|
|
+ )
|
|
|
+ .append(new Elem("button")
|
|
|
+ .text("Update")
|
|
|
+ )
|
|
|
+ .append(new Elem("button")
|
|
|
+ .text(income.active ? "Archive" : "Restore")
|
|
|
+ .addClass("archive")
|
|
|
+ .type("button")
|
|
|
+ )
|
|
|
+ .appendTo(this.container);
|
|
|
+ }
|
|
|
+}
|