w wydatkach domyslnie tylko z wydatkami >0
This commit is contained in:
@@ -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', () => {
|
||||
|
@@ -75,15 +75,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-center mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="onlyWithExpenses">
|
||||
<label class="form-check-label ms-2 text-white" for="onlyWithExpenses">
|
||||
Pokaż tylko listy z wydatkami
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<div>
|
||||
<button id="selectAllBtn" class="btn btn-sm btn-outline-light">Zaznacz wszystko</button>
|
||||
@@ -123,15 +114,6 @@
|
||||
<td>{{ '%.2f'|format(list.total_expense) }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% if list|length == 0 %}
|
||||
<tr>
|
||||
<td colspan="12" class="text-center py-4">
|
||||
Brak list zakupowych do wyświetlenia
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user