From d988becfba67268c7724165888980f69fffc1818 Mon Sep 17 00:00:00 2001 From: louispaulb Date: Thu, 23 Jul 2026 11:55:30 -0400 Subject: [PATCH] =?UTF-8?q?feat(planif):=20pr=C3=A9r=C3=A9glage=20Jour=20p?= =?UTF-8?q?r=C3=A9-rempli=20avec=20la=20fen=C3=AAtre=20USUELLE=20du=20tech?= =?UTF-8?q?=20(P8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le préréglage « Jour » n'est plus le générique 8–16 : par défaut = la fenêtre la plus probable du tech (la plus fréquente de son patron hebdo weekly_schedule, sinon de ses quarts réguliers déjà assignés), ex. Houssam → 8–18. Toujours surchargeable via ✎ (perso enregistré prioritaire). Co-Authored-By: Claude Opus 4.8 --- apps/ops/src/pages/PlanificationPage.vue | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/ops/src/pages/PlanificationPage.vue b/apps/ops/src/pages/PlanificationPage.vue index ae6a285..d90c7e0 100644 --- a/apps/ops/src/pages/PlanificationPage.vue +++ b/apps/ops/src/pages/PlanificationPage.vue @@ -2175,8 +2175,28 @@ const hiddenCount = computed(() => techs.value.filter(t => isHidden(t.id)).lengt // personnalisés depuis le menu de cellule (ex. Philip 7:30→17:30) → réutilisés à chaque clic « Jour »/« Soir ». const LS_SHIFT_PRESETS = 'roster-shift-presets-v1' const techShiftPresets = ref({}) // { [techId]: { day:{start,end}, eve:{start,end} } } -function presetDayFor (techId) { const p = techId && techShiftPresets.value[techId]; return (p && p.day) || { start: 8, end: 16 } } +// Préréglage Jour = perso enregistré, SINON la fenêtre USUELLE du tech (« gabarit le plus probable »), SINON 8–16. +function presetDayFor (techId) { const p = techId && techShiftPresets.value[techId]; return (p && p.day) || usualWindowFor(techId) || { start: 8, end: 16 } } function presetEveFor (techId) { const p = techId && techShiftPresets.value[techId]; return (p && p.eve) || { start: 16, end: 20 } } +// Fenêtre USUELLE d'un tech : la plus fréquente de son patron hebdo (weekly_schedule), sinon de ses quarts réguliers +// déjà assignés (hors garde). Pré-remplit le préréglage Jour (ex. Houssam 8–18) → l'utilisateur n'a plus à ressaisir. +function usualWindowFor (techId) { + if (!techId) return null + const counts = {} + const add = (s, e) => { if (s && e) { const k = String(s).slice(0, 5) + '-' + String(e).slice(0, 5); counts[k] = (counts[k] || 0) + 1 } } + const t = (techs.value || []).find(x => x.id === techId) + const ws = t && t.weekly_schedule + if (ws && typeof ws === 'object') { + for (const k of Object.keys(ws)) { const day = ws[k]; if (Array.isArray(day)) day.forEach(w => w && add(w.start, w.end)); else if (day && day.start && day.end) add(day.start, day.end) } + } + if (!Object.keys(counts).length) { // repli : quarts réguliers (hors garde) déjà assignés au tech + for (const a of (assignments.value || [])) { if (a.tech !== techId) continue; const tp = tplByName.value[a.shift]; if (!tp || tp.on_call) continue; add(tp.start_time, tp.end_time) } + } + const best = Object.keys(counts).sort((x, y) => counts[y] - counts[x])[0] + if (!best) return null + const [s, e] = best.split('-'); const sd = hToNum(s); const ed = hToNum(e) + return (sd != null && ed != null && ed > sd) ? { start: sd, end: ed } : null +} function onSetPreset (techId, { kind, start, end } = {}) { if (!techId || start == null || end == null) return const cur = { ...(techShiftPresets.value[techId] || {}) }