Auto-commit for deploy to production - 2025-12-09 13:57:42
This commit is contained in:
@@ -129,17 +129,16 @@ function generateWeeks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const weeks = generateWeeks();
|
const weeks = generateWeeks();
|
||||||
|
const events = []; // tous les evenements (vacances, off Carole, centre, etc.)
|
||||||
|
|
||||||
// === 3. Événements & vacances scolaires ===
|
// === 3. Vacances scolaires (API gouv) ===
|
||||||
|
|
||||||
const events = []; // on pourra y ajouter OFF_CAROLE, CENTRE, etc. plus tard
|
|
||||||
|
|
||||||
async function fetchSchoolHolidays(anneeScolaire, zoneLabel) {
|
async function fetchSchoolHolidays(anneeScolaire, zoneLabel) {
|
||||||
const baseUrl =
|
const baseUrl =
|
||||||
"https://data.education.gouv.fr/api/explore/v2.1/catalog/datasets/fr-en-calendrier-scolaire/records";
|
"https://data.education.gouv.fr/api/explore/v2.1/catalog/datasets/fr-en-calendrier-scolaire/records";
|
||||||
|
|
||||||
// On filtre uniquement sur l'année scolaire et la zone
|
// Filtre: année scolaire + zone C, pas de filtre population (dataset est incohérent sur ce champ)
|
||||||
const where = `annee_scolaire='${anneeScolaire}' AND zones LIKE '%${zoneLabel}%' AND population in ('Élèves', '-')`;
|
const where = `annee_scolaire='${anneeScolaire}' AND zones LIKE '%${zoneLabel}%'`;
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
where,
|
where,
|
||||||
@@ -160,37 +159,35 @@ async function fetchSchoolHolidays(anneeScolaire, zoneLabel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajoute les vacances scolaires comme événements de type VACANCES_SCOLAIRES
|
* Regroupe les records par période (start_date, end_date, description),
|
||||||
* ET remplit le tableau recap.
|
* remplit le tableau recap, et crée les événements VACANCES_SCOLAIRES.
|
||||||
*/
|
*/
|
||||||
function addSchoolHolidayEventsFromRecords(records, events) {
|
function addSchoolHolidayEventsFromRecords(records, events) {
|
||||||
const tbody = document.querySelector("#schoolHolidaysTable tbody");
|
const tbody = document.querySelector("#schoolHolidaysTable tbody");
|
||||||
if (tbody) tbody.innerHTML = "";
|
if (tbody) tbody.innerHTML = "";
|
||||||
|
|
||||||
// 1) Normaliser et regrouper par periode (start_date, end_date, description)
|
// 1) Regrouper par (start_date, end_date, description)
|
||||||
const groups = new Map();
|
const groups = new Map();
|
||||||
|
|
||||||
records.forEach((record) => {
|
records.forEach((record) => {
|
||||||
const startIso = record.start_date; // ISO string
|
const startIso = record.start_date;
|
||||||
const endIso = record.end_date;
|
const endIso = record.end_date;
|
||||||
const desc = record.description || "";
|
const desc = record.description || "";
|
||||||
const zones = record.zones || "";
|
const zones = record.zones || "";
|
||||||
|
|
||||||
const key = `${startIso}|${endIso}|${desc}`;
|
const key = `${startIso}|${endIso}|${desc}`;
|
||||||
|
|
||||||
const existing = groups.get(key);
|
if (!groups.has(key)) {
|
||||||
if (!existing) {
|
|
||||||
groups.set(key, {
|
groups.set(key, {
|
||||||
startIso,
|
startIso,
|
||||||
endIso,
|
endIso,
|
||||||
description: desc,
|
description: desc,
|
||||||
zones, // pour Zone C, ça suffira
|
zones,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// on ignore les académies (location) pour le tableau recap
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2) Construire le tableau recap avec un seul record par groupe
|
// 2) Tableau récap (une ligne par période, dates telles que fournies par l'API)
|
||||||
if (tbody) {
|
if (tbody) {
|
||||||
Array.from(groups.values())
|
Array.from(groups.values())
|
||||||
.sort((a, b) => new Date(a.startIso) - new Date(b.startIso))
|
.sort((a, b) => new Date(a.startIso) - new Date(b.startIso))
|
||||||
@@ -212,28 +209,31 @@ function addSchoolHolidayEventsFromRecords(records, events) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3) Créer les événements jour par jour (VACANCES_SCOLAIRES)
|
// 3) Créer les événements jour par jour (VACANCES_SCOLAIRES)
|
||||||
|
// end = date de reprise => on s'arrête la veille (current < end)
|
||||||
groups.forEach((g) => {
|
groups.forEach((g) => {
|
||||||
const start = new Date(g.startIso);
|
const start = new Date(g.startIso);
|
||||||
const end = new Date(g.endIso);
|
const end = new Date(g.endIso);
|
||||||
|
|
||||||
let current = new Date(start);
|
let current = new Date(start);
|
||||||
// end = date de reprise -> on s'arrête la veille
|
|
||||||
while (current < end) {
|
while (current < end) {
|
||||||
const year = current.getFullYear();
|
const year = current.getFullYear();
|
||||||
const month = String(current.getMonth() + 1).padStart(2, "0");
|
const month = String(current.getMonth() + 1).padStart(2, "0");
|
||||||
const day = String(current.getDate()).padStart(2, "0");
|
const day = String(current.getDate()).padStart(2, "0");
|
||||||
const isoDate = `${year}-${month}-${day}`;
|
const isoDate = `${year}-${month}-${day}`;
|
||||||
|
|
||||||
events.push({
|
events.push({
|
||||||
date: isoDate,
|
date: isoDate,
|
||||||
type: "VACANCES_SCOLAIRES",
|
type: "VACANCES_SCOLAIRES",
|
||||||
duration: 1,
|
duration: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
current.setDate(current.getDate() + 1);
|
current.setDate(current.getDate() + 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marque les jours & semaines de vacances scolaires dans weeks.
|
* Marque les jours et les semaines de vacances scolaires dans weeks.
|
||||||
*/
|
*/
|
||||||
function markSchoolHolidayDaysAndWeeks(weeks, events) {
|
function markSchoolHolidayDaysAndWeeks(weeks, events) {
|
||||||
// reset
|
// reset
|
||||||
@@ -285,7 +285,7 @@ function computeMonthSpans(weeks) {
|
|||||||
|
|
||||||
const monthSpans = computeMonthSpans(weeks);
|
const monthSpans = computeMonthSpans(weeks);
|
||||||
|
|
||||||
// === 5. Rendu du tableau ===
|
// === 5. Rendu du tableau principal ===
|
||||||
|
|
||||||
function renderTable() {
|
function renderTable() {
|
||||||
const planningBody = document.getElementById("planningBody");
|
const planningBody = document.getElementById("planningBody");
|
||||||
@@ -374,7 +374,7 @@ function renderTable() {
|
|||||||
updateSummary();
|
updateSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
// === 6. Résumé (toujours 0 utilisés pour l'instant) ===
|
// === 6. Résumé (pour l'instant, 0 utilisés) ===
|
||||||
|
|
||||||
function updateSummary() {
|
function updateSummary() {
|
||||||
const summaryDiv = document.getElementById("summaryText");
|
const summaryDiv = document.getElementById("summaryText");
|
||||||
@@ -469,7 +469,7 @@ async function initFamilyCalendar() {
|
|||||||
showOnlySchoolHoliday.addEventListener("change", renderTable);
|
showOnlySchoolHoliday.addEventListener("change", renderTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Charger vacances scolaires 2025-2026, Zone C
|
// Charger les vacances scolaires 2025-2026, Zone C
|
||||||
const holidaysRecords = await fetchSchoolHolidays("2025-2026", "Zone C");
|
const holidaysRecords = await fetchSchoolHolidays("2025-2026", "Zone C");
|
||||||
addSchoolHolidayEventsFromRecords(holidaysRecords, events);
|
addSchoolHolidayEventsFromRecords(holidaysRecords, events);
|
||||||
markSchoolHolidayDaysAndWeeks(weeks, events);
|
markSchoolHolidayDaysAndWeeks(weeks, events);
|
||||||
|
|||||||
Reference in New Issue
Block a user