[FEATURE]: Role CRUD LiveViews #325

Closed
opened 2026-01-06 22:22:16 +01:00 by moritz · 0 comments
Owner

Description:

Create LiveView interface for administrators to manage roles. Only admins should be able to access this.

Tasks:

  1. Create lib/mv_web/live/role_live/ directory
  2. Implement index.ex - List all roles
  3. Implement show.ex - View role details
  4. Implement form.ex - Create/Edit role form component
  5. Add routes in router.ex under /admin scope
  6. Create table component showing: name, description, permission_set_name, is_system_role
  7. Add form validation for permission_set_name (dropdown with 4 options)
  8. Prevent deletion of system roles (UI + backend)
  9. Add flash messages for success/error
  10. Style with existing DaisyUI theme

Acceptance Criteria:

  • Index page lists all roles
  • Show page displays role details
  • Form allows creating new roles
  • Form allows editing non-system roles
  • permission_set_name is dropdown (not free text)
  • Cannot delete system roles (grayed out button + backend check)
  • All CRUD operations work
  • Routes are under /admin/roles

Test Strategy (TDD):

LiveView Mount Tests:

  • Index page mounts successfully
  • Index page loads all roles from database
  • Show page mounts with valid role ID
  • Show page returns 404 for invalid role ID

CRUD Operation Tests:

  • Create new role with valid data succeeds
  • Create new role with invalid permission_set_name shows error
  • Update role name succeeds
  • Update system role's permission_set_name succeeds
  • Delete non-system role succeeds
  • Delete system role fails with error message

UI Rendering Tests:

  • Index page shows table with role names
  • System roles have badge/indicator
  • Delete button disabled for system roles
  • Form dropdown shows all 4 permission sets
  • Flash messages appear after actions

Test File: test/mv_web/live/role_live_test.exs

**Description:** Create LiveView interface for administrators to manage roles. Only admins should be able to access this. **Tasks:** 1. Create `lib/mv_web/live/role_live/` directory 2. Implement `index.ex` - List all roles 3. Implement `show.ex` - View role details 4. Implement `form.ex` - Create/Edit role form component 5. Add routes in `router.ex` under `/admin` scope 6. Create table component showing: name, description, permission_set_name, is_system_role 7. Add form validation for `permission_set_name` (dropdown with 4 options) 8. Prevent deletion of system roles (UI + backend) 9. Add flash messages for success/error 10. Style with existing DaisyUI theme **Acceptance Criteria:** - [x] Index page lists all roles - [x] Show page displays role details - [x] Form allows creating new roles - [x] Form allows editing non-system roles - [x] `permission_set_name` is dropdown (not free text) - [x] Cannot delete system roles (grayed out button + backend check) - [x] All CRUD operations work - [x] Routes are under `/admin/roles` **Test Strategy (TDD):** **LiveView Mount Tests:** - Index page mounts successfully - Index page loads all roles from database - Show page mounts with valid role ID - Show page returns 404 for invalid role ID **CRUD Operation Tests:** - Create new role with valid data succeeds - Create new role with invalid `permission_set_name` shows error - Update role name succeeds - Update system role's `permission_set_name` succeeds - Delete non-system role succeeds - Delete system role fails with error message **UI Rendering Tests:** - Index page shows table with role names - System roles have badge/indicator - Delete button disabled for system roles - Form dropdown shows all 4 permission sets - Flash messages appear after actions **Test File:** `test/mv_web/live/role_live_test.exs`
moritz added the
M
label 2026-01-06 22:22:16 +01:00
moritz self-assigned this 2026-01-06 22:22:16 +01:00
moritz added this to the Sprint 10: 11.12-08.01 project 2026-01-06 22:22:16 +01:00
carla modified the project from Sprint 10: 11.12-08.01 to Sprint 11: 08.01-29.01 2026-01-08 12:47:51 +01:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: local-it/mitgliederverwaltung#325
No description provided.