w wydatkach domyslnie tylko z wydatkami >0

This commit is contained in:
Mateusz Gruszczyński
2025-08-18 00:16:26 +02:00
parent 04995f4ab4
commit 5d977c644b
2 changed files with 1 additions and 38 deletions

View File

@@ -4,10 +4,9 @@ document.addEventListener('DOMContentLoaded', () => {
const filterButtons = document.querySelectorAll('.range-btn');
const rows = document.querySelectorAll('#listsTableBody tr');
const categoryButtons = document.querySelectorAll('.category-filter');
const onlyWith = document.getElementById('onlyWithExpenses');
window.selectedCategoryId = "";
let initialLoad = true; // flaga - true tylko przy pierwszym wejściu
let initialLoad = true;
function updateTotal() {
let total = 0;
@@ -74,7 +73,6 @@ document.addEventListener('DOMContentLoaded', () => {
}
function applyExpenseFilter() {
if (!onlyWith || !onlyWith.checked) return;
rows.forEach(row => {
const amt = parseFloat(row.querySelector('.list-checkbox').dataset.amount || 0);
if (amt <= 0) row.style.display = 'none';
@@ -121,23 +119,6 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
// Checkbox "tylko z wydatkami"
if (onlyWith) {
onlyWith.addEventListener('change', () => {
if (initialLoad) {
filterByLast30Days();
} else {
const activeRange = document.querySelector('.range-btn.active');
if (activeRange) {
filterByRange(activeRange.dataset.range);
}
}
applyExpenseFilter();
applyCategoryFilter();
updateTotal();
});
}
// Obsługa kliknięcia w kategorię
categoryButtons.forEach(btn => {
btn.addEventListener('click', () => {