Prechádzať zdrojové kódy

Allowances can now be updated.

Lee Morgan 11 mesiacov pred
rodič
commit
5368584bfc

+ 12 - 0
src/views/js/data/Allowance.js

@@ -17,6 +17,18 @@ export default class Allowance{
         return this._name;
     }
 
+    set name(v){
+        this._name = v;
+    }
+
+    set amount(v){
+        if(this._isPercent){
+            this._amount = v;
+        }else{
+            this._amount = Format.dollarsToCents(v);
+        }
+    }
+
     get isPercent(){
         return this._isPercent;
     }

+ 8 - 1
src/views/js/pages/EditAllowance.js

@@ -11,7 +11,14 @@ export default class EditAllowance extends Page{
 
     submit(allowance){
         event.preventDefault();
-        console.log("submitting");
+
+        const select = this.container.querySelector.bind(this.container);
+        allowance.name = select(".name").value;
+        allowance.isPercent = select(".isPercent").checked;
+        allowance.amount = select(".amount").value;
+
+        user.account.save();
+        changePage("viewAllowances");
     }
 
     updateAmount(allowance){