diff --git a/static/js/show_all_expense.js b/static/js/show_all_expense.js new file mode 100644 index 0000000..eba67b6 --- /dev/null +++ b/static/js/show_all_expense.js @@ -0,0 +1,17 @@ +document.addEventListener('DOMContentLoaded', function () { + const showAllCheckbox = document.getElementById('showAllLists'); + if (!showAllCheckbox) return; + + const params = new URLSearchParams(window.location.search); + if (!params.has('show_all')) { + params.set('show_all', 'true'); + window.history.replaceState({}, '', `${window.location.pathname}?${params.toString()}`); + } + showAllCheckbox.checked = params.get('show_all') === 'true'; + + showAllCheckbox.addEventListener('change', function () { + const urlParams = new URLSearchParams(window.location.search); + urlParams.set('show_all', showAllCheckbox.checked ? 'true' : 'false'); + window.location.search = urlParams.toString(); + }); +}); diff --git a/templates/expenses.html b/templates/expenses.html index b7d2765..d27e262 100644 --- a/templates/expenses.html +++ b/templates/expenses.html @@ -163,9 +163,9 @@ {% block scripts %} + - {% endblock %} \ No newline at end of file