feat(planif): préréglage Jour pré-rempli avec la fenêtre USUELLE du tech (P8)
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 <noreply@anthropic.com>
This commit is contained in:
parent
9e91ba6791
commit
d988becfba
|
|
@ -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] || {}) }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user