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);
|
updateStatistics(entries);
|
||||||
updateBridgeDaysDisplay();
|
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 pdfButton = document.getElementById('btnExportPDF');
|
||||||
const pdfButtonMobile = document.getElementById('btnExportPDFMobile');
|
const pdfButtonMobile = document.getElementById('btnExportPDFMobile');
|
||||||
|
|
||||||
// Check if last day of month has start and end time (and they're different)
|
// Check if the displayed month is in the past (not current month or future)
|
||||||
const lastDayDate = `${displayYear}-${String(displayMonth + 1).padStart(2, '0')}-${String(lastDay).padStart(2, '0')}`;
|
const today = new Date();
|
||||||
const lastDayEntry = entries.find(e => e.date === lastDayDate);
|
const currentYear = today.getFullYear();
|
||||||
|
const currentMonth = today.getMonth();
|
||||||
|
|
||||||
const isLastDayComplete = lastDayEntry &&
|
const isMonthComplete = (displayYear < currentYear) ||
|
||||||
lastDayEntry.startTime &&
|
(displayYear === currentYear && displayMonth < currentMonth);
|
||||||
lastDayEntry.endTime &&
|
|
||||||
lastDayEntry.startTime !== lastDayEntry.endTime;
|
|
||||||
|
|
||||||
if (isLastDayComplete) {
|
if (isMonthComplete) {
|
||||||
pdfButton.style.display = '';
|
pdfButton.style.display = '';
|
||||||
if (pdfButtonMobile) pdfButtonMobile.style.display = '';
|
if (pdfButtonMobile) pdfButtonMobile.style.display = '';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user