Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/RoleSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export function RoleSwitcher() {

return (
<div className="role-switch no-print">
<button className={`btn ${viewAs ? '' : 'secondary '}sm`} style={{ width: '100%' }} onClick={() => setOpen(!open)} aria-expanded={open} aria-haspopup="menu">
{viewAs ? `Viewing as ${ROLE_VIEWS[viewAs.role].label}` : 'View as role…'}
<button className={`btn ${viewAs ? '' : 'secondary '}sm`} style={{ width: '100%' }} onClick={() => setOpen(!open)} aria-expanded={open} aria-haspopup="menu" title={viewAs ? `Viewing as ${describeView(db, viewAs)}` : 'See SignMeUp as each user type'}>
{viewAs ? `Viewing as ${ROLE_VIEWS[viewAs.role].short}` : 'View as role…'}
</button>
{open && <>
<div className="role-scrim" onClick={() => setOpen(false)} />
Expand Down
13 changes: 7 additions & 6 deletions src/lib/viewAs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { fullName } from './names.js';
*/
export interface ViewAs { role: Role; studentId?: string; facultyId?: string; }

export const ROLE_VIEWS: Record<Role, { label: string; jobTitle: string; access: Subsystem[]; summary: string }> = {
student: { label: 'Student', jobTitle: 'Student', access: STUDENT_ACCESS, summary: 'Own record, registration, own outline, faculty & courses' },
faculty: { label: 'Faculty', jobTitle: 'Faculty', access: ['FCI', 'GRADE'], summary: 'Grades for courses they teach, faculty & courses' },
advisor: { label: 'Major advisor', jobTitle: 'Major advisor', access: ['ER', 'REG', 'MAJOR', 'FCI'], summary: 'Student records and approved outlines' },
registrar: { label: 'Department user / registrar', jobTitle: 'Registrar staff', access: ['ER', 'REG', 'MAJOR', 'FCI', 'GRADE'], summary: 'Records, outlines, grade updates, catalog' },
admin: { label: 'System administrator', jobTitle: 'System administrator', access: ALL_ACCESS, summary: 'Everything, including authorized users' },
/** `short` fits the sidebar button; `label` is used in the menu and the banner. */
export const ROLE_VIEWS: Record<Role, { label: string; short: string; jobTitle: string; access: Subsystem[]; summary: string }> = {
student: { label: 'Student', short: 'Student', jobTitle: 'Student', access: STUDENT_ACCESS, summary: 'Own record, registration, own outline, faculty & courses' },
faculty: { label: 'Faculty', short: 'Faculty', jobTitle: 'Faculty', access: ['FCI', 'GRADE'], summary: 'Grades for courses they teach, faculty & courses' },
advisor: { label: 'Major advisor', short: 'Advisor', jobTitle: 'Major advisor', access: ['ER', 'REG', 'MAJOR', 'FCI'], summary: 'Student records and approved outlines' },
registrar: { label: 'Department user / registrar', short: 'Registrar', jobTitle: 'Registrar staff', access: ['ER', 'REG', 'MAJOR', 'FCI', 'GRADE'], summary: 'Records, outlines, grade updates, catalog' },
admin: { label: 'System administrator', short: 'Administrator', jobTitle: 'System administrator', access: ALL_ACCESS, summary: 'Everything, including authorized users' },
};

export const ROLE_ORDER: Role[] = ['student', 'faculty', 'advisor', 'registrar', 'admin'];
Expand Down
7 changes: 4 additions & 3 deletions src/screens/StudentRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ function EditPanel({ db, student, only, onClose, onSave }: {
{text('middleName', false, 'Optional')}
{text('lastName', true, 'e.g. Okafor-Reyes')}
{text('phone', true, '(310) 555-0142')}
{text('address', true, 'Street, city, state ZIP')}
<div className="field"><label className="label" htmlFor="st-address">{LABELS.address} <span className="req">*</span></label>
<textarea id="st-address" className={cls('address')} rows={2} value={draft.address ?? ''} disabled={!can('address')} placeholder="Street, city, state ZIP" onChange={(e) => set('address', e.target.value)} /></div>
<div className="field"><label className="label" htmlFor="st-dob">{LABELS.dateOfBirth} <span className="req">*</span></label>
<input id="st-dob" type="date" className={cls('dateOfBirth')} value={draft.dateOfBirth} disabled={!can('dateOfBirth')} onChange={(e) => set('dateOfBirth', e.target.value)} /></div>
<div className="field"><label className="label" htmlFor="st-major">{LABELS.majorId} <span className="req">*</span></label>
Expand Down Expand Up @@ -264,8 +265,8 @@ function HistoryPanel({ db, kind, initial, isNew, onClose, onSave }: {
<input id="h-id" className={cls('courseId')} value={draft.courseId} list={transfer ? undefined : 'history-catalog'} placeholder={transfer ? 'e.g. MATH 21' : 'e.g. CS 101'} onChange={(e) => pickCatalog(e.target.value)} />
{!transfer && <datalist id="history-catalog">{db.courses.map((c) => <option key={c.id} value={c.id}>{c.title}</option>)}</datalist>}</div>
<div className="field"><label className="label" htmlFor="h-title">Course title <span className="req">*</span></label><input id="h-title" className={cls('title')} value={draft.title} onChange={(e) => set('title', e.target.value)} /></div>
<div style={{ display: 'grid', gridTemplateColumns: '1.4fr 1fr 1fr', gap: 12 }}>
<div className="field"><label className="label" htmlFor="h-term">Semester <span className="req">*</span></label><input id="h-term" list="vl-semesters" data-list="semesters" title="Press F4 or Alt+↓ for the list of values" className={cls('term')} value={draft.term} placeholder="Fall 2025" onChange={(e) => set('term', e.target.value)} /></div>
<div className="field"><label className="label" htmlFor="h-term">Semester <span className="req">*</span></label><input id="h-term" list="vl-semesters" data-list="semesters" title="Press F4 or Alt+↓ for the list of values" className={cls('term')} value={draft.term} placeholder="Fall 2025" onChange={(e) => set('term', e.target.value)} /></div>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12 }}>
<div className="field"><label className="label" htmlFor="h-units">Units <span className="req">*</span></label><input id="h-units" type="number" min={0} max={12} step={1} className={cls('units')} value={Number.isNaN(draft.units) ? '' : draft.units} onChange={(e) => set('units', e.target.value === '' ? NaN : Number(e.target.value))} /></div>
<div className="field"><label className="label" htmlFor="h-grade">Grade <span className="req">*</span></label>
<select id="h-grade" className={cls('grade')} value={draft.grade} onChange={(e) => set('grade', e.target.value)}><option value="">—</option>{completionGrades(db).map((g) => <option key={g} value={g}>{g}</option>)}</select></div>
Expand Down
Loading