${dayCounter}`;
if (dayEvts.some((e) => e.type === "PEP_SICK"))
content += `
🤒`;
const dayLeaves = this.leaves.filter((l) => l.leave_date === iso);
@@ -1357,6 +1360,66 @@ document.addEventListener("DOMContentLoaded", () => {
this.currentMonth.setMonth(this.currentMonth.getMonth() + 1);
this.renderMonthCalendar();
});
+ // --- BOUTON AUJOURD'HUI ---
+ document.getElementById("fc-today-btn")?.addEventListener("click", () => {
+ this.currentMonth = new Date();
+ this.currentMonth.setDate(1); // Force au 1er du mois pour éviter les bugs de fins de mois
+ this.renderMonthCalendar();
+ });
+
+ // --- GESTION DU SWIPE MENSUEL (MOBILE) ---
+ if (this.monthCalendar) {
+ let touchStartX = 0;
+ let touchStartY = 0;
+
+ // On écoute le début du toucher
+ this.monthCalendar.addEventListener(
+ "touchstart",
+ (e) => {
+ touchStartX = e.changedTouches[0].screenX;
+ touchStartY = e.changedTouches[0].screenY;
+ },
+ { passive: true },
+ );
+
+ // On écoute la fin du toucher
+ this.monthCalendar.addEventListener(
+ "touchend",
+ (e) => {
+ const touchEndX = e.changedTouches[0].screenX;
+ const touchEndY = e.changedTouches[0].screenY;
+
+ const deltaX = touchEndX - touchStartX;
+ const deltaY = touchEndY - touchStartY;
+
+ // Détection d'un swipe horizontal (on exclut les swipes verticaux de défilement)
+ // Seuil de 50px pour éviter les déclenchements par erreur
+ if (Math.abs(deltaX) > Math.abs(deltaY) && Math.abs(deltaX) > 50) {
+ const numMonths =
+ this.viewMode === "2months"
+ ? 2
+ : this.viewMode === "3months"
+ ? 3
+ : 1;
+
+ if (deltaX < 0) {
+ // Swipe vers la GAUCHE = Aller dans le FUTUR (Mois suivants)
+ this.currentMonth.setMonth(
+ this.currentMonth.getMonth() + numMonths,
+ );
+ } else {
+ // Swipe vers la DROITE = Revenir dans le PASSÉ (Mois précédents)
+ this.currentMonth.setMonth(
+ this.currentMonth.getMonth() - numMonths,
+ );
+ }
+
+ this.renderMonthCalendar(); // Rafraîchit l'UI
+ }
+ },
+ { passive: true },
+ );
+ }
document
.getElementById("fc-prev-school-year")
?.addEventListener("click", () => this.changeSchoolYear(-1));
@@ -1466,16 +1529,43 @@ document.addEventListener("DOMContentLoaded", () => {
this._currentBulkInfo = { dates };
+ // --- 🔍 DÉTECTION DES ÉVÉNEMENTS & CONGÉS EXISTANTS ---
+ const activeEvents = new Set();
+ this.events.forEach((e) => {
+ if (dates.includes(e.date)) activeEvents.add(e.type);
+ });
+
+ const activeLeaves = { 2: new Set(), 3: new Set() };
+ this.leaves.forEach((l) => {
+ if (dates.includes(l.leave_date)) {
+ if (activeLeaves[l.person_id])
+ activeLeaves[l.person_id].add(l.leave_type);
+ }
+ });
+
+ // Petites fonctions utilitaires pour gérer l'UI du bouton
+ const getBtnClass = (type, personId = null) => {
+ let isActive = personId
+ ? activeLeaves[personId] && activeLeaves[personId].has(type)
+ : activeEvents.has(type);
+ return isActive ? "fc-menu-btn--active" : "";
+ };
+ const getBtnIcon = (type, personId = null) => {
+ let isActive = personId
+ ? activeLeaves[personId] && activeLeaves[personId].has(type)
+ : activeEvents.has(type);
+ return isActive ? "✓ " : "";
+ };
+
// Gestion de la date affichée (Singulier/Pluriel)
const dateLabel =
dates.length > 1
? `${dates.length} ${tr("fc_unit_days")}`
: new Date(dates[0]).toLocaleDateString(window.I18N_LANG || "fr-FR");
- // Icône SVG Poubelle (Uniformisée)
+ // Icône SVG Poubelle
const trashSvg = `
`;
- // Fonction utilitaire interne pour les en-têtes de section avec suppression
const buildHeader = (title, action, cat) => `
`;
- // 1. En-tête du menu (Date ou nombre de jours)
let html = ``;
- // 2. Section Carole (Congés)
+ // 2. Section Carole
html += ``;
- // 3. Section Garde (Centre / Avis)
+ // 3. Section Garde
html += ``;
- // 4. Section Pep (Maladie)
+ // 4. Section Pep
html += ``;
- // 5. Section Enfants (Alex & Laia)
+ // 5. Section Enfants
html += `