Commit f3b2b8bd authored by Floréal Cabanettes's avatar Floréal Cabanettes

Add delete subtr functionality

parent 3b4d0490
......@@ -56,6 +56,20 @@ form button {
padding: 5px 10px;
}
button#send {
width: 100px;
}
button#add-subtr, button#del-subtr {
width: 80px;
text-align: center;
}
form .newline button {
margin-top: 15px;
margin-left: 114px;
}
#login {
height: calc(100% - 110px);
padding-top: calc(50% - 90px);
......
......@@ -53,6 +53,9 @@
<button id="send">Envoyer</button>
<button id="add-subtr">+ item</button>
<button id="reset">Annuler</button>
<div class="newline">
<button id="del-subtr" style="display: none;">- item</button>
</div>
</form>
</div>
......
......@@ -13,7 +13,7 @@ trackmybank.init = function() {
e.preventDefault();
});
$("#add-subtr").on("click touch", trackmybank.add_transaction);
trackmybank.transaction_html = $("#transactions .transaction:first");
$("#del-subtr").on("click touch", trackmybank.del_transaction);
$("#reset").on("click touch", trackmybank.cancel);
};
......@@ -28,7 +28,9 @@ trackmybank.set_datemask = function (element) {
weekStart: 1,
todayBtn: "linked",
language: "fr",
autoclose: true
autoclose: true,
forceParse: false,
todayHighlight: true
}).attr("readonly", "readonly");
};
......@@ -54,17 +56,29 @@ trackmybank.login = function() {
}
trackmybank.init_special_fields();
credentials.token = data["token"];
$("#date_t").val( moment().format('DD/MM/YYYY') );
trackmybank.transaction_html = $("#transactions .transaction:first").clone();
}
});
};
trackmybank.add_transaction = function () {
$("#transactions").append(trackmybank.transaction_html.clone());
$("#del-subtr").show();
};
trackmybank.del_transaction = function () {
let transactions = $("#transactions .transaction");
transactions.last().remove();
if (transactions.length === 1) {
$("#del-subtr").hide();
}
};
trackmybank.cancel = function() {
$("#transactions .transaction").remove();
trackmybank.add_transaction();
$("#del-subtr").hide();
};
trackmybank.hide_notify = function() {
......
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