now remembers ui values for which tab we are on and whether we clicked show estimated or not

This commit is contained in:
2025-08-22 16:51:04 +10:00
parent 5bd94fc2c5
commit b05f7b05e8
4 changed files with 61 additions and 6 deletions

View File

@@ -103,7 +103,7 @@
<!-- create tabbed view for each bill type -->
<nav id="bills-nav" class="nav nav-tabs">
{% for bt in bill_types %}
<button class="nav-link" id="tab-{{bt.name}}" data-bs-toggle="tab" data-bs-target="#tab-{{bt.id}}" type="button" role="tab" aria-controls="tab1" aria-selected="true">{{bt.name}}</button>
<button class="nav-link" id="tab-but-{{bt.id}}" data-bs-toggle="tab" data-bs-target="#tab-{{bt.id}}" type="button" role="tab" aria-controls="tab1" aria-selected="true" onClick="SaveTab('{{bt.id}}')">{{bt.name}}</button>
{% endfor %}
</nav>
@@ -157,9 +157,16 @@
function ToggleEstimated()
{
if( $("#showEstimated").is(":checked") )
{
val=1
$('.est').removeClass('d-none')
}
else
{
val=0
$('.est').addClass('d-none')
}
$.ajax( { type: 'POST', url: '/saveui', contentType: 'application/json', data: JSON.stringify( { 'show_estimated': val } ), success: function() { } } )
}
function StartNewBillData()
@@ -319,6 +326,11 @@
data: JSON.stringify( { 'bill_type': bt, 'which_growth': which } ), success: function() { window.location='bills' } } )
}
function SaveTab( last_tab )
{
$.ajax( { type: 'POST', url: '/saveui', contentType: 'application/json', data: JSON.stringify( { 'last_tab': last_tab } ), success: function() { } } )
}
$(document).ready(function () {
// if amount has enter key in it then save, but dont do this for other fields in new bill
$("#new-bill-data-amount").keyup(function(event){ if(event.which == 13){ $("#save-bill").click(); } event.preventDefault(); });
@@ -329,8 +341,15 @@
// force something to be active
$('#bills-nav .nav-link').first().addClass('active');
// now go back to last tab, as per something I dont know yet :)
$('#tab-Water').tab('show');
{% if bill_ui %}
// if we have data on it - go back to last tab
$('#tab-but-{{bill_ui.last_tab}}').tab('show');
{% if bill_ui.show_estimated %}
$('#showEstimated').click()
{% endif %}
{% else %}
$('#tab-but-1').tab('show');
{% endif %}
} )
</script>
</body>