From cee5e31646d8d359a90fccb290b0ab46a780bbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Wed, 17 Sep 2025 21:56:04 +0200 Subject: [PATCH] podzial dzienny --- static/js/chart_split_controls.js | 32 ++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/static/js/chart_split_controls.js b/static/js/chart_split_controls.js index 4664fde..ef72b57 100644 --- a/static/js/chart_split_controls.js +++ b/static/js/chart_split_controls.js @@ -28,12 +28,29 @@ document.addEventListener('DOMContentLoaded', function() { // Obsługa kliknięć przycisków czasu toggleMonthlySplit.addEventListener('click', function() { setActiveTimeSplit('monthly'); - loadExpenses('monthly'); + + const startDate = document.getElementById('startDate')?.value || null; + const endDate = document.getElementById('endDate')?.value || null; + + if (startDate && endDate) { + loadExpenses('monthly', startDate, endDate); + } else { + loadExpenses('monthly'); + } }); toggleDailySplit.addEventListener('click', function() { setActiveTimeSplit('daily'); - loadExpenses('daily'); + + const startDate = document.getElementById('startDate')?.value || null; + const endDate = document.getElementById('endDate')?.value || null; + + // Przy podziale dziennym, jeśli zakres dat jest podany, użyj 'custom' + if (startDate && endDate) { + loadExpenses('custom', startDate, endDate); + } else { + loadExpenses('daily'); + } }); // Obsługa kliknięcia przycisku podziału kategorii @@ -54,5 +71,14 @@ document.addEventListener('DOMContentLoaded', function() { // Inicjalizacja - domyślnie ustaw podział dzienny setActiveTimeSplit('daily'); - loadExpenses('daily'); + + const startDate = document.getElementById('startDate')?.value || null; + const endDate = document.getElementById('endDate')?.value || null; + + if (startDate && endDate) { + loadExpenses('custom', startDate, endDate); + } else { + loadExpenses('daily'); + } + });