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') + } + }); + }); +