diff --git a/README.md b/README.md
index 8a9d576..5b16a3d 100755
--- a/README.md
+++ b/README.md
@@ -53,7 +53,7 @@ docker run -d --name cpas-tracker -p 3001:3001 -v cpas-data:/data cpas-tracker
- **At-risk badge**: flags employees within 2 points of the next tier escalation
- Search/filter by name, department, or supervisor
- Click any employee name to open their full profile modal
-- **๐ Audit Log** button โ filterable, paginated view of all system write actions
+- **๐ Audit Log** button โ filterable, paginated view of all system write actions
### Violation Form
- Select existing employee or enter new employee by name
@@ -68,12 +68,14 @@ docker run -d --name cpas-tracker -p 3001:3001 -v cpas-data:/data cpas-tracker
### Employee Profile Modal
- Full violation history with resolution status and **amendment count badge** per record
-- **โ Edit Employee** button โ update name, department, or supervisor inline
+- **โ Edit Employee** button โ update name, department, supervisor, or notes inline
- **Merge Duplicate** tab โ reassign all violations from a duplicate record and delete it
- **Amend** button per active violation โ edit non-scoring fields (location, notes, witness, etc.) with a full field-level diff history
- Negate / restore individual violations (soft delete with resolution type + notes)
- Hard delete option for data entry errors
- PDF download for any historical violation record
+- **Notes & Flags** โ free-text notes (e.g. "on PIP", "union member") with quick-add tag buttons; visible in the profile modal without affecting scoring
+- **Point Expiration Timeline** โ shows when each active violation rolls off the 90-day window, with a progress bar, days-remaining countdown, and projected tier-drop indicators
### Audit Log
- Append-only log of every write action: employee created/edited/merged, violation logged/amended/negated/restored/deleted
@@ -85,6 +87,11 @@ docker run -d --name cpas-tracker -p 3001:3001 -v cpas-data:/data cpas-tracker
- Point values, violation type, and incident date are immutable
- Every change is stored as a field-level diff (old โ new value) with timestamp and actor
+### In-App Documentation
+- **? Docs** button in the navbar opens a slide-in admin reference panel
+- Covers feature map, CPAS tier system, workflow guidance, and roadmap
+- No external link required; always reflects current deployed version
+
### CPAS Tier System
| Points | Tier | Label |
@@ -112,21 +119,23 @@ Scores are computed over a **rolling 90-day window** (negated violations exclude
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/health` | Health check |
-| GET | `/api/employees` | List all employees |
+| GET | `/api/employees` | List all employees (includes `notes`) |
| POST | `/api/employees` | Create or upsert employee |
-| PATCH | `/api/employees/:id` | Edit employee name, department, or supervisor |
-| POST | `/api/employees/:id/merge` | Merge duplicate employee into target; reassigns all violations |
+| PATCH | `/api/employees/:id` | Edit name, department, supervisor, or notes |
+| POST | `/api/employees/:id/merge` | Merge duplicate employee; reassigns all violations |
| GET | `/api/employees/:id/score` | Get active CPAS score for employee |
+| GET | `/api/employees/:id/expiration` | Active violation roll-off timeline with days remaining |
+| PATCH | `/api/employees/:id/notes` | Save employee notes only (shorthand) |
| GET | `/api/dashboard` | All employees with active points + violation counts |
| POST | `/api/violations` | Log a new violation |
-| GET | `/api/violations/employee/:id` | Get violation history for employee (with resolutions + amendment counts) |
+| GET | `/api/violations/employee/:id` | Violation history with resolutions + amendment counts |
| PATCH | `/api/violations/:id/negate` | Negate a violation (soft delete + resolution record) |
| PATCH | `/api/violations/:id/restore` | Restore a negated violation |
| PATCH | `/api/violations/:id/amend` | Amend non-scoring fields with field-level diff logging |
| GET | `/api/violations/:id/amendments` | Get amendment history for a violation |
| DELETE | `/api/violations/:id` | Hard delete a violation |
| GET | `/api/violations/:id/pdf` | Download violation PDF |
-| GET | `/api/audit` | Paginated audit log (filterable by entity_type, entity_id) |
+| GET | `/api/audit` | Paginated audit log (filterable by `entity_type`, `entity_id`) |
---
@@ -134,16 +143,16 @@ Scores are computed over a **rolling 90-day window** (negated violations exclude
```
cpas/
-โโโ Dockerfile # Multi-stage: builds React + runs Express w/ Chromium
+โโโ Dockerfile # Multi-stage: builds React + runs Express w/ Chromium
โโโ .dockerignore
-โโโ package.json # Backend (Express) deps
-โโโ server.js # API + static file server
+โโโ package.json # Backend (Express) deps
+โโโ server.js # API + static file server
โโโ db/
-โ โโโ schema.sql # Tables + 90-day active score view
-โ โโโ database.js # SQLite connection (better-sqlite3) + auto-migrations
+โ โโโ schema.sql # Tables + 90-day active score view
+โ โโโ database.js # SQLite connection (better-sqlite3) + auto-migrations
โโโ pdf/
-โ โโโ generator.js # Puppeteer PDF generation
-โโโ client/ # React frontend (Vite)
+โ โโโ generator.js # Puppeteer PDF generation
+โโโ client/ # React frontend (Vite)
โโโ package.json
โโโ vite.config.js
โโโ index.html
@@ -151,20 +160,23 @@ cpas/
โโโ main.jsx
โโโ App.jsx
โโโ data/
- โ โโโ violations.js # All CPAS violation definitions + groups
+ โ โโโ violations.js # All CPAS violation definitions + groups
โโโ hooks/
- โ โโโ useEmployeeIntelligence.js # Score + history hook
+ โ โโโ useEmployeeIntelligence.js # Score + history hook
โโโ components/
- โโโ CpasBadge.jsx # Tier badge + color logic
- โโโ TierWarning.jsx # Pre-submit tier crossing alert
- โโโ Dashboard.jsx # Company-wide leaderboard + audit log trigger
- โโโ ViolationForm.jsx # Violation entry form
- โโโ EmployeeModal.jsx # Employee profile + history modal
- โโโ EditEmployeeModal.jsx # Employee edit + merge duplicate
- โโโ AmendViolationModal.jsx # Non-scoring field amendment + diff history
- โโโ AuditLog.jsx # Filterable audit log panel
- โโโ NegateModal.jsx # Negate/resolve violation dialog
- โโโ ViolationHistory.jsx # Violation list component
+ โโโ CpasBadge.jsx # Tier badge + color logic
+ โโโ TierWarning.jsx # Pre-submit tier crossing alert
+ โโโ Dashboard.jsx # Company-wide leaderboard + audit log trigger
+ โโโ ViolationForm.jsx # Violation entry form
+ โโโ EmployeeModal.jsx # Employee profile + history modal
+ โโโ EditEmployeeModal.jsx # Employee edit + merge duplicate
+ โโโ AmendViolationModal.jsx # Non-scoring field amendment + diff history
+ โโโ AuditLog.jsx # Filterable audit log panel
+ โโโ NegateModal.jsx # Negate/resolve violation dialog
+ โโโ ViolationHistory.jsx # Violation list component
+ โโโ ExpirationTimeline.jsx # Per-violation 90-day roll-off countdown
+ โโโ EmployeeNotes.jsx # Inline notes editor with quick-add HR tags
+ โโโ ReadmeModal.jsx # In-app admin documentation panel
```
---
@@ -173,7 +185,7 @@ cpas/
Six tables + one view:
-- **`employees`** โ id, name, department, supervisor
+- **`employees`** โ id, name, department, supervisor, **notes**
- **`violations`** โ full incident record including `prior_active_points` snapshot at time of logging
- **`violation_resolutions`** โ resolution type, details, resolved_by (linked to violations)
- **`violation_amendments`** โ field-level diff log for violation edits; one row per changed field per amendment
@@ -182,6 +194,20 @@ Six tables + one view:
---
+## Amendable Fields
+
+Point values, violation type, and incident date are **immutable** after submission. The following fields can be amended:
+
+| Field | Notes |
+|-------|-------|
+| `incident_time` | Time of day the incident occurred |
+| `location` | Where the incident took place |
+| `details` | Narrative description |
+| `submitted_by` | Supervisor who submitted |
+| `witness_name` | Witness on record |
+
+---
+
## Roadmap
### โ
Completed
@@ -204,18 +230,13 @@ Six tables + one view:
| 5 | Employee edit / merge | Update employee name/dept/supervisor; merge duplicate records without losing history |
| 5 | Violation amendment | Edit non-scoring fields with field-level audit trail |
| 5 | Audit log | Append-only log of all system writes; filterable panel in the dashboard |
+| 6 | Employee notes / flags | Free-text notes on employee record with quick-add HR tags; does not affect scoring |
+| 6 | Point expiration timeline | Per-violation roll-off countdown with tier-drop projections |
+| 6 | In-app documentation | Admin usage guide and feature map accessible from the navbar |
---
-### ๐ In Progress
-
-#### Reporting & Visibility
-- **Expiration timeline** โ per-employee view showing which active violations roll off the 90-day window and when; lets supervisors anticipate tier drops before they happen
-- **Employee notes / flags** โ free-text notes attached to an employee record (e.g. "on PIP", "union member") visible in the profile modal without affecting scoring
-
----
-
-### ๐ก Proposed
+### ๐ Proposed
#### Reporting & Analytics
- **Violation trends chart** โ line/bar chart of violations per day/week/month, filterable by department or supervisor; useful for identifying systemic patterns vs. individual incidents
diff --git a/client/src/components/ReadmeModal.jsx b/client/src/components/ReadmeModal.jsx
index e2c4588..edadd0a 100644
--- a/client/src/components/ReadmeModal.jsx
+++ b/client/src/components/ReadmeModal.jsx
@@ -1,286 +1,145 @@
import React, { useEffect, useRef } from 'react';
// โโโ Minimal Markdown โ HTML renderer โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
-// Handles: headings, bold, inline-code, fenced code blocks, tables, hr,
-// unordered lists, ordered lists, and paragraphs.
function mdToHtml(md) {
- const lines = md.split('\n');
- const out = [];
- let i = 0;
- let inUl = false;
- let inOl = false;
- let inTable = false;
- let tableHead = false;
+ const lines = md.split('\n');
+ const out = [];
+ let i = 0, inUl = false, inOl = false, inTable = false;
- const closeOpenLists = () => {
- if (inUl) { out.push(''); inUl = false; }
- if (inOl) { out.push(''); inOl = false; }
- if (inTable) { out.push(''); inTable = false; tableHead = false; }
+ const close = () => {
+ if (inUl) { out.push(''); inUl = false; }
+ if (inOl) { out.push(''); inOl = false; }
+ if (inTable) { out.push(''); inTable = false; }
};
- const inline = (s) =>
- s
- .replace(/&/g, '&')
- .replace(//g, '>')
- .replace(/\*\*(.+?)\*\*/g, '$1')
- .replace(/`([^`]+)`/g, '$1');
+ const inline = s =>
+ s.replace(/&/g,'&').replace(//g,'>')
+ .replace(/\*\*(.+?)\*\*/g,'$1')
+ .replace(/`([^`]+)`/g,'$1');
while (i < lines.length) {
const line = lines[i];
- // Fenced code block
if (line.startsWith('```')) {
- closeOpenLists();
- const lang = line.slice(3).trim();
- const codeLines = [];
+ close();
i++;
- while (i < lines.length && !lines[i].startsWith('```')) {
- codeLines.push(lines[i].replace(/&/g,'&').replace(//g,'>'));
- i++;
- }
- out.push(`
${codeLines.join('\n')}`);
- i++;
- continue;
+ while (i < lines.length && !lines[i].startsWith('```')) i++;
+ i++; continue;
+ }
+ if (/^---+$/.test(line.trim())) { close(); out.push('| ${inline(c)} | `)); out.push('
|---|
| ${inline(c)} | `)); out.push('