feat: update PDF export button visibility logic to check if the month is complete
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m49s
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m49s
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user