Commit 06ceb0a4 authored by Floréal Cabanettes's avatar Floréal Cabanettes

Add description to transactions

parent 295f1b39
...@@ -43,7 +43,9 @@ ...@@ -43,7 +43,9 @@
<div id="transactions"> <div id="transactions">
<div class="transaction"> <div class="transaction">
<hr width="50%"> <hr width="50%">
<label class="first">Montant</label> <label class="first">Description</label>
<input class="description" type="text" maxlength="255"/>
<label>Montant</label>
<input class="money amount" type="number" step="0.01"/> <input class="money amount" type="number" step="0.01"/>
<label>Catégorie</label> <label>Catégorie</label>
<select class="category select2"> <select class="category select2">
......
...@@ -81,14 +81,16 @@ trackmybank.send = function() { ...@@ -81,14 +81,16 @@ trackmybank.send = function() {
let valid = true; let valid = true;
$.each($("#transactions").find(".transaction"), function(t, transaction) { $.each($("#transactions").find(".transaction"), function(t, transaction) {
let tr = $(transaction); let tr = $(transaction);
let description = tr.find(".description").val();
let montant = tr.find(".amount").val(); let montant = tr.find(".amount").val();
let category = tr.find(".category").val(); let category = tr.find(".category").val();
if (montant === "" || category === "") { if (montant === "" || category === "" || description === "") {
trackmybank.notify("error", "Erreur : tous les champs sont requis !"); trackmybank.notify("error", "Erreur : tous les champs sont requis !");
valid = false; valid = false;
return false; return false;
} }
transactions.push({ transactions.push({
"description": description,
"amount": parseFloat(montant), "amount": parseFloat(montant),
"category": parseInt(category) "category": parseInt(category)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment