# Phase 3B — Single-Cell Quick Schedule Assignment **Status:** IMPLEMENTED ## Objective Implement a lightweight, inline scheduling interface for single-employee, single-date assignments. The feature drastically reduces the clicks needed to schedule an employee by replacing the heavy full-screen modal with a context-aware popover for empty days, while safely delegating complex edits (like recurring schedules) to the advanced tool. ## Files Modified 1. `frontend/src/components/schedule-manager/schedule-manager-components/components/QuickSchedulePopover.jsx` (NEW) 2. `frontend/src/components/schedule-manager/schedule-manager-components/components/ScheduleGrid.jsx` (MODIFIED - Passed `cellState` to `onCellClick`) 3. `frontend/src/components/schedule-manager/schedule-manager-components/LayouSMDashboard.jsx` (MODIFIED - Replaced `PopoverEditor`, added capability-aware handlers) ## Quick Assignment UX - Clicking an `UNSCHEDULED` cell opens the lightweight `QuickSchedulePopover` anchored right next to the cell. - The popover lists available `workTimes` as clean radio options. - Clicking the action button performs an inline assignment/proposal and gracefully closes the popover while the grid refreshes. ## Permission Behavior - **Direct Scheduling:** The popover inspects the `userPermissions` capability store for the `schedules.manage` capability. If true, the action button reads `Assign` and fires `upsertEmployeeShift`. - **Proposal (Submit Change):** If the user lacks direct management capabilities, the action button reads `Submit Change` and routes through the `create_submission` API to generate a pending request. - **View-only:** The UI natively disables the action button if no capabilities or shifts are selected. ## Final Schedule Change - Quick Assignment is restricted for existing (`FINAL`) schedules. Since a cell may represent one instance of a recurring schedule block, allowing a quick one-day mutation could corrupt or detach the recurring chain. - Clicking an existing schedule shows the current shift details but offers only an `Open Advanced Assignment` button, routing the user safely to the full `AssignScheduleModal`. ## Proposed Schedule Change - Clicking an empty cell and submitting a change instantly renders a `PENDING` dashed yellow block in the grid after refresh. - Clicking a `PENDING` block displays a clean comparison: `Current: None/Shift` vs `Proposed: New Shift`. ## Pending Cell Interaction - The popover for a `PENDING` cell includes a `Review Request` button. - Clicking this closes the popover and automatically slides open the `Pending Approval Drawer`, focusing contextually on the submission. ## Leave Handling - Clicking an `LEAVE` cell opens a read-only popover detailing the leave type and the underlying shift (if one exists). The action button is replaced with a simple `Close` button to protect the approved leave. ## Conflict Handling - If `upsertEmployeeShift` returns an error (e.g., overlapping shift), the popover catches it and triggers a SweetAlert modal displaying the human-readable conflict error and providing an `Open Advanced Assignment` fallback to resolve the conflict. ## Historical / Recurring Safety - **Historical:** Clicking any date prior to "Today" opens a blocked UI state stating: "Historical Schedule. Editing past schedules requires Schedule Correction." - **Recurring:** Protected by the aforementioned restriction on editing `FINAL` schedules inline. ## Status Filter Resolution - The Status filter dropdown in the dashboard toolbar has been temporarily commented out. Deep row-culling logic (e.g., filtering out employees based on a mix of pending/leave statuses dynamically across a sliding date window) requires complex algorithmic changes that risk breaking grid performance. It will be addressed in a future phase. ## API & Database Changes - **API:** NONE. Reused `upsertEmployeeShift` and `create_submission`. - **Database:** NONE. ## Known Limitations - The system still cannot distinguish a true Rest Day from an unassigned schedule. - The Status filter is visually hidden until algorithmic support is built. ## Phase 3C Readiness **READY**. The single-cell interaction is extremely fast, fully permission-aware, and data-safe. We are ready to tackle the full Assignment Wizard for bulk and recurring patterns.