2.2 KiB
2.2 KiB
PLAN: Attendance View Mode & Next-Day Overlap
Objective
Enhance the Attendance Calendar grid to open existing records in "View Mode" for visual confirmation before modifying, and guarantee that next-day overlapping shifts (e.g., 03:30 PM to 12:30 AM) are properly calculated.
Proposed Changes
Component Modification
[MODIFY] resources/js/pages/hr/attendance-records/calendar.tsx
- Goal: Transform the direct-to-edit behavior into a "View to Edit" multi-step flow.
- Ensure that clicking on a cell containing an existing attendance record invokes
setFormMode('view')instead of'edit'. - Pass a custom action prop or handle state updates to display an "Edit" button when the modal is in read-only mode, which toggles the
formModeto'edit'.
[MODIFY] resources/js/components/CrudFormModal.tsx
- Goal: Expose an
onEdithook to the modal's Footer. - Update the generic modal UI to conditionally render an "Edit" button if an
onEditcallback is provided alongsidemode === 'view'.
Next-Day Overlap Confirmation
- Status: Natively Supported in the backend core logic.
- The
AttendanceRecord@calculateTotalHours()method specifically contains:// Handle next day clock out (night shifts) if ($clockOut->lt($clockIn)) { $clockOut->addDay(); } - Because we just relaxed the rigid HTML frontend time validations, you can directly input "03:30 PM" as Clock In and "12:30 AM" as Clock Out. The system will inherently calculate this as 9 total hours spanned across two physical days. No further back-end logic changes are required to force overlap capabilities!
Verification Plan
Manual Verification
- Click on an active attendance entry and confirm the modal securely displays details as Read-Only.
- Click the subsequent "Edit" button and confirm the time fields unlock.
- Input a night shift test (03:30 PM to 12:30 AM) -> save -> verify database properly tracks a full shift period without negative minutes.
Agent Action Required
- Review the drafted approach above.
- Simply respond with an approval (or direct me) and I will execute the component refactoring to implement the
view-then-editmodal logic!