Roster web application
The Roster web application is a Vue client for viewing and managing employee shift assignments by month. It brings employee context, holidays, leave, and shifts into one calendar view, then sends create, update, delete, and move actions to the HRMS service. It is served at /hr/roster and complements the wider roster scheduling area.
Application shell
The application shell starts the Vue client, connects it to Frappe UI resources, and places the page inside the HRMS web session. roster/…/main.ts is the client entry point. It loads the shared style, registers the router and resource plug-in, exposes the shared button component, and mounts App.vue at the page root. The HTML entry page provides the mount points and the CSRF token that the HRMS session uses for requests (roster/index.html• L1-17).
App.vue keeps the shell small. It renders the route selected by the browser, so the page-level view owns the roster experience rather than the shell (roster/…/App.vue• L1-5). The web page is backed by the HRMS route and builds into the HRMS public asset path (hrms/hooks.py• L85, roster/vite.config.js• L19-21).
References: roster/…/main.ts• L1-17 roster/…/App.vue• L1-5 roster/index.html• L1-17 hrms/hooks.py• L85
Navigation and session access
The router provides the client entry route under the /hr/roster browser base. The current route opens the home view, which is the main roster workspace (roster/…/router.ts• L1-16). The home view first asks HRMS for the signed-in user. It shows the roster only after that user is available and sends an unauthenticated user to the login page with a return path (roster/…/Home.vue• L1-29).
The navigation bar connects the workspace to the rest of HRMS. It identifies the Roster page, shows the user's name or image, and offers links to the account page, Desk, and logout. Logout errors appear as a user-facing error message rather than being hidden (roster/…/NavBar.vue• L1-59).
References: roster/…/router.ts• L1-16 roster/…/Home.vue• L1-29 roster/…/NavBar.vue• L1-59
Roster workspace
The home view combines the navigation bar, the month workspace, and toast messages. This makes the month view the main place where a user reviews staffing coverage and changes assignments (roster/…/Home.vue• L1-29). The workspace keeps the selected month and filter state together, then passes that state to the header and calendar table (roster/…/MonthView.vue• L35-48, roster/…/MonthView.vue• L61-131).
The available view menu links to related HRMS pages for shift types, locations, assignments, and schedules. The create menu opens the shift assignment dialog from the same workspace, so users can move from review to scheduling without leaving the roster page (roster/…/MonthView.vue• L7-32, roster/…/MonthView.vue• L86-95).
References: roster/…/Home.vue• L1-29 roster/…/MonthView.vue• L1-58 roster/…/MonthView.vue• L86-95
Month view
The month view presents employees as rows and calendar days as columns. It starts from the current month, lets the user move one month at a time, and requires a company selection before it displays the employee grid (roster/…/MonthView.vue• L35-49). The header now limits visible filters to record types the user can list. It loads the default company and permitted filter types first, then loads options for each allowed filter. Department options depend on the selected company (roster/…/MonthViewHeader.vue• L35-41, roster/…/MonthViewHeader.vue• L66-138).
The table combines three kinds of calendar information for each employee and date:
| Calendar information | User purpose |
|---|---|
| Holiday or weekly off | Shows dates when the employee is not expected to work. |
| Approved leave | Shows dates covered by leave. |
| Shift assignment | Shows the shift type, time, location, and active state. |
The client requests the selected month and filters as one event set. It maps date ranges to individual calendar cells and orders shifts by start time. This lets the table show overlapping schedule facts in the same employee-day context (roster/…/MonthViewTable.vue• L346-413, roster/…/MonthViewTable.vue• L437-511).
Users can search within the loaded employee list, open an assignment, add a shift to a cell, or drag a shift to another employee and date. A move can also replace a shift at the target cell. After a successful change, the table fetches the event set again so the display reflects the server state (roster/…/MonthViewTable.vue• L9-17, roster/…/MonthViewTable.vue• L31-99, roster/…/MonthViewTable.vue• L180-241, roster/…/MonthViewTable.vue• L416-435).
The month flow moves from context selection to read and then to an optional write action:
flowchart LR
A[Select company and filters] --> B[Load employees]
B --> C[Load month events]
C --> D[Render employee-day grid]
D --> E{User action}
E -->|Change month or filters| B
E -->|Add or edit assignment| F[Open assignment dialog]
E -->|Move or swap shift| G[Send shift move]
F --> H[Refresh month events]
G --> H
References: roster/…/MonthView.vue• L61-131 roster/…/MonthViewHeader.vue• L35-138 roster/…/MonthViewTable.vue• L1-99 roster/…/MonthViewTable.vue• L346-435 roster/…/MonthViewTable.vue• L437-511
Shift assignment dialog
The shift assignment dialog is the write surface for a single assignment or a repeated schedule. It supports a new assignment, an update to an existing assignment, deletion of one occurrence, deletion of consecutive shifts, and removal of a linked schedule assignment (roster/…/ShiftAssignmentDialog.vue• L1-137, roster/…/ShiftAssignmentDialog.vue• L223-287).
For a new assignment, the user selects an employee, shift type, dates, location, and status. The form can also describe a repeating schedule by weekday and frequency. The dialog fills read-only employee details after employee selection and loads existing schedule settings when an assignment is linked to a schedule (roster/…/ShiftAssignmentDialog.vue• L4-101, roster/…/ShiftAssignmentDialog.vue• L298-345, roster/…/ShiftAssignmentDialog.vue• L386-419).
The dialog chooses between a direct shift write and a schedule-based write. It emits an event after each successful write, and the parent uses that event to reload the month grid. This keeps the form and the calendar aligned without requiring a page reload (roster/…/ShiftAssignmentDialog.vue• L347-358, roster/…/ShiftAssignmentDialog.vue• L421-520, roster/…/MonthView.vue• L50-58).
References: roster/…/ShiftAssignmentDialog.vue• L1-137 roster/…/ShiftAssignmentDialog.vue• L223-358 roster/…/ShiftAssignmentDialog.vue• L362-520 roster/…/MonthView.vue• L50-58
Reusable input components
The roster client uses small shared components to keep navigation and record selection consistent. Link.vue provides a labeled, searchable link field for HRMS records such as employees, shift types, and locations. It debounces typed queries, loads matching records, and keeps the current value available even when a new filtered result set does not include it (roster/…/Link.vue• L18-19, roster/…/Link.vue• L62-98, roster/…/Link.vue• L100-132).
NavBar.vue and FrappeHRLogo.vue provide the shared identity and account controls for the page. The remaining visual controls come from Frappe UI, which supplies buttons, menus, dialogs, avatars, autocompletes, forms, and toasts (roster/…/NavBar.vue• L1-43, roster/…/FrappeHRLogo.vue• L1-29, roster/…/main.ts• L7-16).
References: roster/…/Link.vue• L1-132 roster/…/NavBar.vue• L1-59 roster/…/FrappeHRLogo.vue• L1-29 roster/…/main.ts• L7-16
UI utilities
The UI utilities provide two cross-cutting behaviors. The date helper adds the comparisons and time parsing needed to place events across a month. The toast helper gives success and error results a common visual form and removes HTML from error text before showing it (roster/…/dayjs.ts• L1-14, roster/…/index.ts• L1-28).
The navigation helper uses a full browser redirect for links that leave the Vue router, such as Desk, the account page, and login. Together, these helpers keep date rules, feedback, and cross-application navigation consistent across the roster views (roster/…/index.ts• L30-32).
References: roster/…/dayjs.ts• L1-14 roster/…/index.ts• L1-32
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the event shape or filter names must stay aligned between MonthViewTable.vue, MonthView.vue, and the HRMS roster API. The server rejects unknown filter fields.
- Changes to assignment creation or deletion must preserve the refresh event from ShiftAssignmentDialog.vue; otherwise the calendar can show stale assignments.
- Changes to the
/hr/rostermount path must stay aligned between the router base, the HRMS route, the login redirect, and the built asset path. - Changes to schedule frequency or repeat-day values must stay aligned between the dialog and the schedule-assignment service.
- Changes to filter permissions or option loading must stay aligned with
get_permitted_filter_doctypes; otherwise the header can show forbidden filters or raise permission errors. - Changes to the CSRF or session setup must preserve the token supplied by the HRMS web page before Frappe UI requests start.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| No company is selected | The employee grid stays hidden and the page asks the user to select a company. | Keep company selection as the gate for the month table. |
| A filter doctype is not permitted | The related filter must not load, because its option request can fail with a permission error. | Build visible filters from the permitted doctype list. |
| Current user lookup fails | The roster page redirects to login. | Preserve the return path to /hr/roster. |
| Event request fails | The month data cannot be trusted and an error toast is shown. | Keep the event reload and error path tied to the same resource. |
| A shift move targets the same shift | The server rejects the request. | Do not treat the source shift as a valid target. |
| A shift is broken outside its date range | The server rejects the change. | Use the assignment's start and end dates as the valid range. |
| A filter name is not allowed by the service | The event request fails with a permission error. | Keep client filter keys within the supported employee and shift sets. |
Key files
| File | Why to read it |
|---|---|
| roster/…/main.ts | Client entry point and Frappe UI resource setup. |
| roster/…/router.ts | Browser base and page route. |
| roster/…/Home.vue | Authenticated page composition and session gate. |
| roster/…/MonthView.vue | Main workspace state, filters, month selection, and action entry points. |
| roster/…/MonthViewHeader.vue | Month navigation, permission-aware filters, and dependent filter behavior. |
| roster/…/MonthViewTable.vue | Calendar display, event mapping, search, and drag actions. |
| roster/…/ShiftAssignmentDialog.vue | Assignment and repeated schedule write flows. |
| roster/…/Link.vue | Reusable HRMS record search field. |
| roster/…/index.ts | Shared feedback and cross-page navigation behavior. |
| hrms/…/roster.py | Server contract for month data and assignment actions used by the client. |