fix js, html
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const checkboxes = document.querySelectorAll('.list-checkbox');
|
||||
const totalEl = document.getElementById('listsTotal');
|
||||
const filterButtons = document.querySelectorAll('.filter-btn');
|
||||
const filterButtons = document.querySelectorAll('.range-btn');
|
||||
const rows = document.querySelectorAll('#listsTableBody tr');
|
||||
|
||||
const onlyWith = document.getElementById('onlyWithExpenses');
|
||||
const customStart = document.getElementById('customStart');
|
||||
const customEnd = document.getElementById('customEnd');
|
||||
|
||||
// Przywróć zapisane daty
|
||||
if (localStorage.getItem('customStart')) {
|
||||
customStart.value = localStorage.getItem('customStart');
|
||||
}
|
||||
if (localStorage.getItem('customEnd')) {
|
||||
customEnd.value = localStorage.getItem('customEnd');
|
||||
}
|
||||
|
||||
function updateTotal() {
|
||||
let total = 0;
|
||||
checkboxes.forEach(cb => {
|
||||
@@ -32,6 +40,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
btn.classList.add('active');
|
||||
const range = btn.dataset.range;
|
||||
|
||||
// Czyść lokalne daty przy kliknięciu zakresu
|
||||
localStorage.removeItem('customStart');
|
||||
localStorage.removeItem('customEnd');
|
||||
|
||||
const now = new Date();
|
||||
const todayStr = now.toISOString().slice(0, 10);
|
||||
const year = now.getFullYear();
|
||||
@@ -58,7 +70,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ISO week helper
|
||||
function getISOWeek(date) {
|
||||
const target = new Date(date.valueOf());
|
||||
const dayNr = (date.getDay() + 6) % 7;
|
||||
@@ -68,11 +79,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
return 1 + Math.floor(dayDiff / 7);
|
||||
}
|
||||
|
||||
// Zakres dat: kliknij „Zastosuj zakres”
|
||||
document.getElementById('applyCustomRange').addEventListener('click', () => {
|
||||
const start = customStart.value;
|
||||
const end = customEnd.value;
|
||||
|
||||
// Zapamiętaj daty
|
||||
localStorage.setItem('customStart', start);
|
||||
localStorage.setItem('customEnd', end);
|
||||
|
||||
filterButtons.forEach(b => b.classList.remove('active'));
|
||||
|
||||
rows.forEach(row => {
|
||||
@@ -85,7 +99,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
updateTotal();
|
||||
});
|
||||
|
||||
// Filtrowanie tylko list z wydatkami
|
||||
if (onlyWith) {
|
||||
onlyWith.addEventListener('change', () => {
|
||||
applyExpenseFilter();
|
||||
@@ -100,6 +113,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (amt <= 0) row.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Domyślnie kliknij „Miesiąc”
|
||||
const defaultBtn = document.querySelector('.range-btn[data-range="month"]');
|
||||
if (defaultBtn && !customStart.value && !customEnd.value) {
|
||||
defaultBtn.click();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
@@ -138,4 +157,4 @@ document.getElementById("showAllLists").addEventListener("change", function () {
|
||||
url.searchParams.delete("show_all");
|
||||
}
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
});
|
||||
|
@@ -38,14 +38,13 @@
|
||||
<div class="card-body">
|
||||
|
||||
<div class="d-flex flex-wrap gap-2 mb-3">
|
||||
<button class="btn btn-outline-light btn-sm range-btn active" data-range="all">🌐 Wszystko</button>
|
||||
<button class="btn btn-outline-light btn-sm range-btn" data-range="day">🗓️ Dzień</button>
|
||||
<button class="btn btn-outline-light btn-sm range-btn" data-range="week">📆 Tydzień</button>
|
||||
<button class="btn btn-outline-light btn-sm range-btn" data-range="month">📅 Miesiąc</button>
|
||||
<button class="btn btn-outline-light btn-sm range-btn active" data-range="month">📅 Miesiąc</button>
|
||||
<button class="btn btn-outline-light btn-sm range-btn" data-range="year">📈 Rok</button>
|
||||
<button class="btn btn-outline-light btn-sm range-btn" data-range="all">🌐 Wszystko</button>
|
||||
</div>
|
||||
|
||||
<!-- Tu: checkbox w jednej linii lub wycentrowany -->
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" id="onlyWithExpenses">
|
||||
<label class="form-check-label ms-2 text-white" for="onlyWithExpenses">Pokaż tylko listy z
|
||||
@@ -114,7 +113,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Przyciski zakresu czasu -->
|
||||
|
||||
<div class="d-flex flex-wrap gap-2 mb-3">
|
||||
<button class="btn btn-outline-light btn-sm range-btn active" data-range="monthly">📅 Miesięczne</button>
|
||||
<button class="btn btn-outline-light btn-sm range-btn" data-range="quarterly">📊 Kwartalne</button>
|
||||
|
Reference in New Issue
Block a user