refactor: improve groups LiveView based on code review feedback
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon 2026-01-28 10:33:27 +01:00
parent 3eb4cde0b7
commit ddc8335cc0
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
8 changed files with 109 additions and 104 deletions

View file

@ -255,9 +255,9 @@ lib/
**Route:** `/groups` - Groups management index page
**Features:**
- List all groups in table
- Create new group button
- Edit group (inline or modal)
- List all groups in table (sorted by name via database query)
- Create new group button (navigates to `/groups/new`)
- Edit group via separate form page (`/groups/:slug/edit`)
- Delete group with confirmation modal
- Show member count per group
@ -268,11 +268,13 @@ lib/
- Actions (Edit, Delete)
**Delete Confirmation Modal:**
- Warning: "X members are in this group"
- Warning: "X members are in this group" (with proper pluralization)
- Confirmation: "All member-group associations will be permanently deleted"
- Input field: Enter group name to confirm
- Input field: Enter group name to confirm (with `phx-debounce="200"` for better UX)
- Delete button disabled until name matches
- Modal remains open on name mismatch (allows user to correct input)
- Cancel button
- Server-side authorization check in delete event handler (security best practice)
### Member Overview Integration
@ -312,11 +314,26 @@ lib/
- Display group name and description
- List all members in group
- Link to member detail pages
- Edit group button
- Delete group button (with confirmation)
- Edit group button (navigates to `/groups/:slug/edit`)
- Delete group button (with confirmation modal)
**Note:** Uses slug for routing to provide URL-friendly, readable group URLs (e.g., `/groups/board-members`).
### Group Form Pages
**Create Form:** `/groups/new`
- Separate LiveView page for creating new groups
- Form with name and description fields
- Slug is auto-generated and not editable
- Redirects to `/groups` on success
**Edit Form:** `/groups/:slug/edit`
- Separate LiveView page for editing existing groups
- Form pre-populated with current group data
- Slug is immutable (not displayed in form)
- Redirects to `/groups/:slug` on success
- `mount/3` performs authorization check, `handle_params/3` loads group once
### Accessibility (A11y) Considerations
**Requirements:**
@ -473,6 +490,7 @@ lib/
- Paginate member list for large groups (>50 members)
- Load member count via calculation (not separate query)
- Use `Ash.Query.load` for member details when displaying
- Sorting performed at database level (`Ash.Query.sort(:name)`) for efficiency
### Search Performance