feat: custom violation types — persist, manage, and use in violation form #46

Merged
jason merged 1 commits from claude/musing-bell into master 2026-03-18 16:25:53 -05:00
Owner

Adds a full CRUD system for user-defined violation types stored in a new
violation_types table. Custom types appear in the violation dropdown alongside
hardcoded types, grouped by category, with ✦ marker and a green Custom badge.

  • db/database.js: auto-migration adds violation_types table on startup
  • server.js: GET/POST/PUT/DELETE /api/violation-types; type_key auto-generated
    as custom_; DELETE blocked if any violations reference the type
  • ViolationTypeModal.jsx: create/edit modal with name, category (datalist
    autocomplete from existing categories), handbook chapter reference,
    description/reference text, fixed vs sliding point toggle, context field
    checkboxes; delete with usage guard
  • ViolationForm.jsx: fetches custom types on mount; merges into dropdown via
    mergedGroups memo; resolveViolation() checks hardcoded then custom; '+ Add
    Type' button above dropdown; 'Edit Type' button appears when a custom type is
    selected; newly created type auto-selects; all audit calls flow through
    existing audit() helper

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

Adds a full CRUD system for user-defined violation types stored in a new violation_types table. Custom types appear in the violation dropdown alongside hardcoded types, grouped by category, with ✦ marker and a green Custom badge. - db/database.js: auto-migration adds violation_types table on startup - server.js: GET/POST/PUT/DELETE /api/violation-types; type_key auto-generated as custom_<slug>; DELETE blocked if any violations reference the type - ViolationTypeModal.jsx: create/edit modal with name, category (datalist autocomplete from existing categories), handbook chapter reference, description/reference text, fixed vs sliding point toggle, context field checkboxes; delete with usage guard - ViolationForm.jsx: fetches custom types on mount; merges into dropdown via mergedGroups memo; resolveViolation() checks hardcoded then custom; '+ Add Type' button above dropdown; 'Edit Type' button appears when a custom type is selected; newly created type auto-selects; all audit calls flow through existing audit() helper Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jason added 1 commit 2026-03-18 16:25:47 -05:00
Adds a full CRUD system for user-defined violation types stored in a new
violation_types table. Custom types appear in the violation dropdown alongside
hardcoded types, grouped by category, with ✦ marker and a green Custom badge.

- db/database.js: auto-migration adds violation_types table on startup
- server.js: GET/POST/PUT/DELETE /api/violation-types; type_key auto-generated
  as custom_<slug>; DELETE blocked if any violations reference the type
- ViolationTypeModal.jsx: create/edit modal with name, category (datalist
  autocomplete from existing categories), handbook chapter reference,
  description/reference text, fixed vs sliding point toggle, context field
  checkboxes; delete with usage guard
- ViolationForm.jsx: fetches custom types on mount; merges into dropdown via
  mergedGroups memo; resolveViolation() checks hardcoded then custom; '+ Add
  Type' button above dropdown; 'Edit Type' button appears when a custom type is
  selected; newly created type auto-selects; all audit calls flow through
  existing audit() helper

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jason merged commit 3a0934bdc6 into master 2026-03-18 16:25:53 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jason/cpas#46