Add stage 4: frontend lists view + enforce 100-list cap
API: GET /api/lists is now ordered alphabetically (COLLATE NOCASE) by title with no other option, and TodoListController rejects a create past 100 lists per owner with 409. New TodoListRepository::countForOwner. Frontend: HomeView replaces the placeholder with the user's lists (rendered in API order) and a create form (title + optional description). New Pinia lists store fetches and creates, re-fetching after a create so the new list sorts into place; it is reset on logout. Form disables and explains at 100 lists; create errors surface inline. Neutral .badge with a .badge--warn variant; dropped the unused .facts styles. Tests: alphabetical ordering and the 100-list cap. Suite: 17 passing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,16 +28,29 @@ final class TodoListRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* Every list owned by the user, always sorted alphabetically by title
|
||||
* (case-insensitive). There is deliberately no other ordering option.
|
||||
*
|
||||
* @return TodoListRow[]
|
||||
*/
|
||||
public function allForOwner(int $ownerId): array
|
||||
{
|
||||
$stmt = $this->pdo->prepare(self::SELECT . ' WHERE l.owner_id = :owner ORDER BY l.created_at DESC, l.id DESC');
|
||||
$stmt = $this->pdo->prepare(
|
||||
self::SELECT . ' WHERE l.owner_id = :owner ORDER BY l.title COLLATE NOCASE ASC, l.id ASC'
|
||||
);
|
||||
$stmt->execute(['owner' => $ownerId]);
|
||||
|
||||
return array_map($this->cast(...), $stmt->fetchAll());
|
||||
}
|
||||
|
||||
public function countForOwner(int $ownerId): int
|
||||
{
|
||||
$stmt = $this->pdo->prepare('SELECT COUNT(*) FROM todo_lists WHERE owner_id = :owner');
|
||||
$stmt->execute(['owner' => $ownerId]);
|
||||
|
||||
return (int) $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TodoListRow|null
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user