drop to 15 records per page
This commit is contained in:
parent
50e9a9de3f
commit
2df603a074
@ -52,7 +52,7 @@ This project implements a fully-featured data table with **filtering, sorting, a
|
|||||||
- ✅ **Status Filter**: Dropdown (All, Resolved, Unresolved)
|
- ✅ **Status Filter**: Dropdown (All, Resolved, Unresolved)
|
||||||
- ✅ **Assignment Filter**: Dropdown (All, Mine, Assigned, Unassigned)
|
- ✅ **Assignment Filter**: Dropdown (All, Mine, Assigned, Unassigned)
|
||||||
- ✅ **Sorting**: All columns with ascending/descending indicators
|
- ✅ **Sorting**: All columns with ascending/descending indicators
|
||||||
- ✅ **Pagination**: 25 records per page with full navigation
|
- ✅ **Pagination**: 15 records per page with full navigation
|
||||||
- ✅ **URL State**: All filters/sorting/pagination in URL (bookmarkable/shareable)
|
- ✅ **URL State**: All filters/sorting/pagination in URL (bookmarkable/shareable)
|
||||||
- ✅ **Progressive Enhancement**: Works with and without JavaScript
|
- ✅ **Progressive Enhancement**: Works with and without JavaScript
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ All state is in the URL for bookmarking/sharing:
|
|||||||
|
|
||||||
### Default Behavior
|
### Default Behavior
|
||||||
- Sort: `inserted_at DESC` (newest first)
|
- Sort: `inserted_at DESC` (newest first)
|
||||||
- Per page: 25 records
|
- Per page: 15 records
|
||||||
- Current user: ID 1 (for demo purposes)
|
- Current user: ID 1 (for demo purposes)
|
||||||
|
|
||||||
## Why Elixir/Phoenix?
|
## Why Elixir/Phoenix?
|
||||||
|
|||||||
@ -6,7 +6,7 @@ defmodule ActionRequestsDemo.ActionRequests.ActionRequest do
|
|||||||
Flop.Schema,
|
Flop.Schema,
|
||||||
filterable: [:patient_name, :status, :assigned_user_id],
|
filterable: [:patient_name, :status, :assigned_user_id],
|
||||||
sortable: [:patient_name, :status, :inserted_at, :delivery_scheduled_at],
|
sortable: [:patient_name, :status, :inserted_at, :delivery_scheduled_at],
|
||||||
default_limit: 25
|
default_limit: 15
|
||||||
}
|
}
|
||||||
|
|
||||||
@primary_key {:id, :binary_id, autogenerate: true}
|
@primary_key {:id, :binary_id, autogenerate: true}
|
||||||
|
|||||||
@ -19,12 +19,52 @@ defmodule ActionRequestsDemo.Release do
|
|||||||
`priv/repo/seeds.exs` file, which uses `ActionRequestsDemo.Repo`.
|
`priv/repo/seeds.exs` file, which uses `ActionRequestsDemo.Repo`.
|
||||||
"""
|
"""
|
||||||
def seed do
|
def seed do
|
||||||
# Ensure Faker is started in this eval process so Faker.Person.name/0 works
|
ensure_app_started(ActionRequestsDemo.Repo)
|
||||||
{:ok, _} = Application.ensure_all_started(:faker)
|
ensure_app_started(:faker)
|
||||||
|
|
||||||
seeds_path = Application.app_dir(@app, "priv/repo/seeds.exs")
|
seeds_path = Application.app_dir(@app, "priv/repo/seeds.exs")
|
||||||
Code.require_file(seeds_path)
|
Code.require_file(seeds_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp ensure_app_started(app_or_repo) do
|
||||||
|
case Application.ensure_all_started(app_or_repo) do
|
||||||
|
{:ok, _} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
|
{:error, {:already_started, _pid}} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
|
{:error, {:not_started, _}} ->
|
||||||
|
start_repo(app_or_repo)
|
||||||
|
|
||||||
|
{:error, reason} ->
|
||||||
|
raise "Could not start #{inspect(app_or_repo)}: #{inspect(reason)}"
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
UndefinedFunctionError ->
|
||||||
|
start_repo(app_or_repo)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp start_repo(repo) when is_atom(repo) do
|
||||||
|
case repo.start_link() do
|
||||||
|
{:ok, _pid} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
|
{:error, {:already_started, _pid}} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
|
other ->
|
||||||
|
raise "Could not start #{inspect(repo)}: #{inspect(other)}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp start_repo(app) do
|
||||||
|
case Application.ensure_all_started(app) do
|
||||||
|
{:ok, _} -> :ok
|
||||||
|
{:error, {:already_started, _}} -> :ok
|
||||||
|
other -> raise "Could not start #{inspect(app)}: #{inspect(other)}"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -75,14 +75,14 @@ defmodule ActionRequestsDemoWeb.ActionRequestsLiveTest do
|
|||||||
test "pagination displays correct records per page", %{conn: conn} do
|
test "pagination displays correct records per page", %{conn: conn} do
|
||||||
{:ok, view, _html} = live(conn, "/")
|
{:ok, view, _html} = live(conn, "/")
|
||||||
# Default ordering is inserted_at: :desc, so page 1 shows Patient 30..6
|
# Default ordering is inserted_at: :desc, so page 1 shows Patient 30..6
|
||||||
for i <- 30..6//-1 do
|
for i <- 30..16//-1 do
|
||||||
assert has_element?(view, "td", "Patient #{i}")
|
assert has_element?(view, "td", "Patient #{i}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Page 2 should show Patient 5..1
|
# Page 2 should show Patient 5..1
|
||||||
render_click(element(view, "a", "Next"))
|
render_click(element(view, "a", "Next"))
|
||||||
|
|
||||||
for i <- 5..1//-1 do
|
for i <- 15..1//-1 do
|
||||||
assert has_element?(view, "td", "Patient #{i}")
|
assert has_element?(view, "td", "Patient #{i}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -167,17 +167,17 @@ defmodule ActionRequestsDemoWeb.ActionRequestsLiveTest do
|
|||||||
|
|
||||||
test "pagination metadata displays correctly", %{conn: conn} do
|
test "pagination metadata displays correctly", %{conn: conn} do
|
||||||
{:ok, view, _html} = live(conn, "/")
|
{:ok, view, _html} = live(conn, "/")
|
||||||
# Page 1 of 2, showing 25 of 30 records
|
# Page 1 of 2, showing 15 of 30 records
|
||||||
assert has_element?(view, "div", "Page 1 of 2")
|
assert has_element?(view, "div", "Page 1 of 2")
|
||||||
assert has_element?(view, "div", "showing 25 of 30 records")
|
assert has_element?(view, "div", "showing 15 of 30 records")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "pagination metadata updates after navigating", %{conn: conn} do
|
test "pagination metadata updates after navigating", %{conn: conn} do
|
||||||
{:ok, view, _html} = live(conn, "/")
|
{:ok, view, _html} = live(conn, "/")
|
||||||
render_click(element(view, "a", "Next"))
|
render_click(element(view, "a", "Next"))
|
||||||
# Page 2 of 2, showing 5 of 30 records
|
# Page 2 of 2, showing 15 of 30 records
|
||||||
assert has_element?(view, "div", "Page 2 of 2")
|
assert has_element?(view, "div", "Page 2 of 2")
|
||||||
assert has_element?(view, "div", "showing 5 of 30 records")
|
assert has_element?(view, "div", "showing 15 of 30 records")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "pagination metadata updates with filters", %{conn: conn} do
|
test "pagination metadata updates with filters", %{conn: conn} do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user