From 995d1080f3c08ff20af50953cf150c130cd1c2d3 Mon Sep 17 00:00:00 2001 From: Felix Schlusche Date: Tue, 2 Dec 2025 15:18:46 +0100 Subject: [PATCH] feat: update PDF export button visibility logic to check if the month is complete --- public/js/main.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index 03fdc83..bedf6cb 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -1086,20 +1086,19 @@ async function loadMonthlyView() { updateStatistics(entries); updateBridgeDaysDisplay(); - // Show/hide PDF export button based on whether last day has complete times + // Show/hide PDF export button based on whether the month is complete (in the past) const pdfButton = document.getElementById('btnExportPDF'); const pdfButtonMobile = document.getElementById('btnExportPDFMobile'); - // Check if last day of month has start and end time (and they're different) - const lastDayDate = `${displayYear}-${String(displayMonth + 1).padStart(2, '0')}-${String(lastDay).padStart(2, '0')}`; - const lastDayEntry = entries.find(e => e.date === lastDayDate); + // Check if the displayed month is in the past (not current month or future) + const today = new Date(); + const currentYear = today.getFullYear(); + const currentMonth = today.getMonth(); - const isLastDayComplete = lastDayEntry && - lastDayEntry.startTime && - lastDayEntry.endTime && - lastDayEntry.startTime !== lastDayEntry.endTime; + const isMonthComplete = (displayYear < currentYear) || + (displayYear === currentYear && displayMonth < currentMonth); - if (isLastDayComplete) { + if (isMonthComplete) { pdfButton.style.display = ''; if (pdfButtonMobile) pdfButtonMobile.style.display = ''; } else {