Files
HRM-System/docs/PLAN-shift-fallback.md
2026-04-20 09:14:47 +08:00

2.0 KiB

Project Plan: Global Shift Fallback & Responsive Matrix

Problem Diagnosis

  1. Fallback Logic Broken: The matrix correctly parses overrides inside employee_daily_shifts, but defaults everything else to RD (Rest Day). If an employee has a default shift_id mapped directly on their internal profile, the engine ignores it.
  2. Responsiveness: Broad tables with 31 columns inevitably clash against CSS layouts if the overflow boundaries aren't properly constrained.

Proposed Changes

1. Shift Engine Backend Refactor (ShiftController.php)

  • Eager Loading: The User query will be updated to eagerly load employee.shift.
  • Inheritance Math: Inject logic into the mapping loop:
    • If a specific date exists securely inside employee_daily_shifts, USE IT.
    • If NOT, check if $user->employee->shift exists securely. USE IT.
    • If BOTH fail, gracefully fall back to RD (Rest Day).

2. Frontend React Component Constraint (calendar.tsx)

  • Enhance the structural UI table wrappers to use robust flexbox width boundaries (w-full overflow-hidden -> min-w-full inline-block or table-layout: fixed scrolling tricks).
  • Prevent the "sticky" left column container from accidentally swallowing internal scrollbars on mobile viewports.

Warning

Socratic Gate / Clarifying Questions

1. Weekend Rest Days: If an employee has a default shift_id (e.g., "Morning Shift"), should I apply this shift to ALL 7 DAYS of the week, or are there standard built-in Rest Days (like Saturday/Sunday) where it should forcibly fall back to RD instead?

2. Table Behavior: For responsiveness, do you want the rightward days to shrink to an absolute minimum standard width (e.g., 45px), providing a smooth scroll across the month? Or do you want them structurally bound inside their container?

Verification Checklist

  • The table perfectly scrolls horizontally on narrow laptops securely.
  • If Ana Regina has "Morning" set on her profile, standard days display M instead of RD.