diff --git a/assets/css/style.css b/assets/css/style.css index 66626e5..82402d6 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -559,6 +559,16 @@ input[type="number"] { width: 100%; } +.fc-month-title { + font-weight: 600; + font-size: 15px; + color: #243b53; + margin-bottom: 12px; + text-align: center; + padding-bottom: 8px; + border-bottom: 1px solid #d9e2ec; +} + /* === VUE ANNÉE === */ .fc-year-container { display: grid; diff --git a/assets/js/family-calendar.js b/assets/js/family-calendar.js index cb7c105..0dabd3e 100644 --- a/assets/js/family-calendar.js +++ b/assets/js/family-calendar.js @@ -18,7 +18,14 @@ document.addEventListener("DOMContentLoaded", () => { this.monthSelectionMenu = document.getElementById( "fc-month-selectionMenu" ); + // Initialiser avec septembre (mois 8, car 0-indexé) pour l'année scolaire this.currentMonth = new Date(); + const currentMonthIndex = this.currentMonth.getMonth(); + // Si on est avant septembre, on affiche l'année scolaire précédente + if (currentMonthIndex < 8) { + this.currentMonth.setFullYear(this.currentMonth.getFullYear() - 1); + } + this.currentMonth.setMonth(8); // Septembre this.currentMonth.setDate(1); // Premier jour du mois this.viewMode = "1month"; // "1month", "2months", "year" @@ -829,17 +836,38 @@ document.addEventListener("DOMContentLoaded", () => { navigateMonth(direction) { if (this.viewMode === "year") { + // Navigation par année scolaire (septembre à août) this.currentMonth.setFullYear( this.currentMonth.getFullYear() + direction ); } else if (this.viewMode === "2months") { this.currentMonth.setMonth(this.currentMonth.getMonth() + direction); + // S'assurer qu'on reste dans une année scolaire valide + this.adjustToSchoolYear(); } else { this.currentMonth.setMonth(this.currentMonth.getMonth() + direction); + // S'assurer qu'on reste dans une année scolaire valide + this.adjustToSchoolYear(); } this.renderMonthCalendar(); } + adjustToSchoolYear() { + const month = this.currentMonth.getMonth(); + const year = this.currentMonth.getFullYear(); + // Si on dépasse août (mois 7), on passe à septembre de l'année suivante + if (month > 7) { + this.currentMonth.setFullYear(year + 1); + this.currentMonth.setMonth(8); // Septembre + } + // Si on est avant septembre (mois 8), on reste dans l'année scolaire + // mais on pourrait vouloir revenir à septembre de l'année en cours + if (month < 8) { + // On garde l'année mais on pourrait vouloir ajuster + // Pour l'instant, on laisse comme ça car ça peut être août de l'année scolaire + } + } + renderMonthCalendar() { if (!this.monthCalendar) return; @@ -848,17 +876,29 @@ document.addEventListener("DOMContentLoaded", () => { if (monthTitle) { const year = this.currentMonth.getFullYear(); if (this.viewMode === "year") { - monthTitle.textContent = year; + // Afficher l'année scolaire (ex: 2025-2026) + monthTitle.textContent = `${year}-${year + 1}`; } else if (this.viewMode === "2months") { const month = this.currentMonth.getMonth(); const monthName = getMonthNameFr(month); const nextMonth = new Date(year, month + 1, 1); const nextMonthName = getMonthNameFr(nextMonth.getMonth()); - monthTitle.textContent = `${monthName} - ${nextMonthName} ${year}`; + // Ajuster l'année si on passe de décembre à janvier + const displayYear = month >= 8 ? year : year + 1; + monthTitle.textContent = `${monthName} - ${nextMonthName} ${displayYear}`; } else { const month = this.currentMonth.getMonth(); const monthName = getMonthNameFr(month); - monthTitle.textContent = `${monthName} ${year}`; + // Afficher l'année scolaire si on est après août + if (month >= 8) { + monthTitle.textContent = `${monthName} ${year} (${year}-${ + year + 1 + })`; + } else { + monthTitle.textContent = `${monthName} ${year} (${ + year - 1 + }-${year})`; + } } } @@ -886,14 +926,18 @@ document.addEventListener("DOMContentLoaded", () => { const nextMonthIndex = nextMonth > 11 ? 0 : nextMonth; let html = '
| '; dayCount++; } - // Jours du mois actuel + // Jours du mois actuel (uniquement lundi à vendredi) for (let day = 1; day <= daysInMonth; day++) { - if (dayCount % 7 === 0 && day > 1) { + const date = new Date(year, month, day); + const dayOfWeek = date.getDay(); // 0 = Dimanche, 1 = Lundi, ..., 6 = Samedi + + // Ignorer les samedi (6) et dimanche (0) + if (dayOfWeek === 0 || dayOfWeek === 6) { + continue; + } + + // Nouvelle ligne chaque lundi (quand dayCount est un multiple de 5) + if (dayCount > 0 && dayCount % 5 === 0) { html += " | |
| ${day} | `; dayCount++; } - // Jours du mois suivant (pour compléter la dernière ligne) - const remainingDays = 7 - (dayCount % 7); - if (remainingDays < 7) { + // Jours du mois suivant (pour compléter la dernière ligne) - seulement jusqu'à vendredi + const remainingDays = 5 - (dayCount % 5); + if (remainingDays < 5 && remainingDays > 0) { for (let i = 0; i < remainingDays; i++) { html += ''; } |