From 95d792e72f038de022fe3fdba4ded61ff69265db Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 2 Sep 2025 22:05:16 +1000 Subject: [PATCH] added a set of titles when adding new bill / new bill types, allows to toggle date to be when quit or normal date, with normal date we use data, with when quit, we have growth we will use for simple growth and then date(s) can be factored in based on when I quit which is changable in the main financial data --- templates/bills.html | 91 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 12 deletions(-) diff --git a/templates/bills.html b/templates/bills.html index 3e37c0e..1711748 100644 --- a/templates/bills.html +++ b/templates/bills.html @@ -38,8 +38,12 @@ #}
-
- +
+
Bill Type
+
Frequency
+
+
+
{% for bt in bill_types %} {% endfor %}
-
-
+
+
+ + + +
+
+
+ +
- +
@@ -165,9 +184,9 @@ {% for bd in bill_data %} {% if loop.first %}
-
-
-
+
+
+
{% endif %} @@ -222,9 +241,28 @@ function NewBill() { - $.ajax( { type: 'POST', url: '/newbill', - contentType: 'application/json', data: JSON.stringify( { 'name': $('#new-bill-data-type').val(), 'amount': $('#new-bill-data-amount').val(), 'bill_date': $('#new-bill-data-date').val() } ), + if( $('#new-bill-data-growth').hasClass('d-none') ) + { + // if growth is hidden, then we have normal bill + $.ajax( { type: 'POST', url: '/newbill', + contentType: 'application/json', + data: JSON.stringify( { + 'name': $('#new-bill-data-type').val(), + 'amount': $('#new-bill-data-amount').val(), + 'bill_date': $('#new-bill-data-date').val() } ), success: function() { window.location='bills' } } ) + } + else + { + // if growth is visible, then we have future bill/growth & no date + $.ajax( { type: 'POST', url: '/newbill', + contentType: 'application/json', + data: JSON.stringify( { + 'name': $('#new-bill-data-type').val(), + 'amount': $('#new-bill-data-amount').val(), + 'growth': $('#new-bill-data-growth').val() } ), + success: function() { window.location='bills' } } ) + } } function CancelNewBill() @@ -396,6 +434,35 @@ // make the new bill drop-down default to the same as the current tab $("#new-bill-data-type").val( {{bill_ui.last_tab}} ) } ) + + $(function () { + let disabled = false; + + $('#toggleDateBtn').on('click', function () { + disabled = !disabled; + + if (disabled) { + $('#new-bill-data-date').addClass('d-none') + $('#new-bill-data-growth').removeClass('d-none') + $(this) + .removeClass('btn-outline-danger') + .addClass('btn-outline-success') + .html('Normal date'); + $('#new-bill-data-date-label').addClass('d-none') + $('#new-bill-data-growth-label').removeClass('d-none') + } else { + $('#new-bill-data-date').removeClass('d-none') + $('#new-bill-data-growth').addClass('d-none') + $(this) + .removeClass('btn-outline-success') + .addClass('btn-outline-danger') + .html('When quit'); + $('#new-bill-data-date-label').removeClass('d-none') + $('#new-bill-data-growth-label').addClass('d-none') + } + }); + }); +