Initial commit: Phoenix LiveView demo for interactive data tables with filtering, sorting, pagination, URL state, and progressive enhancement
Implements a fully-featured action requests table in a single LiveView module using Flop, Ecto, and SQLite. Includes:
- Fuzzy search, status/assignment filters, column sorting, 25-per-page pagination
- Real-time updates, bookmarkable URLs via `handle_params/3`
- JS-disabled fallback with GET forms (no duplicate logic)
- 1,000,000 seeded records, Tailwind + DaisyUI styling, light/dark themes
- Comprehensive README with comparisons to Django+React/Rails+React stacks
- 31 tests covering all scenarios
Tech: Phoenix 1.8+, LiveView, Flop, Ecto, SQLite, Elixir 1.15+
2025-11-16 10:24:06 +00:00
|
|
|
defmodule ActionRequestsDemo.ActionRequests.ActionRequest do
|
|
|
|
|
use Ecto.Schema
|
|
|
|
|
import Ecto.Changeset
|
|
|
|
|
|
|
|
|
|
@derive {
|
|
|
|
|
Flop.Schema,
|
|
|
|
|
filterable: [:patient_name, :status, :assigned_user_id],
|
|
|
|
|
sortable: [:patient_name, :status, :inserted_at, :delivery_scheduled_at],
|
2025-11-17 14:37:33 +00:00
|
|
|
default_limit: 15
|
Initial commit: Phoenix LiveView demo for interactive data tables with filtering, sorting, pagination, URL state, and progressive enhancement
Implements a fully-featured action requests table in a single LiveView module using Flop, Ecto, and SQLite. Includes:
- Fuzzy search, status/assignment filters, column sorting, 25-per-page pagination
- Real-time updates, bookmarkable URLs via `handle_params/3`
- JS-disabled fallback with GET forms (no duplicate logic)
- 1,000,000 seeded records, Tailwind + DaisyUI styling, light/dark themes
- Comprehensive README with comparisons to Django+React/Rails+React stacks
- 31 tests covering all scenarios
Tech: Phoenix 1.8+, LiveView, Flop, Ecto, SQLite, Elixir 1.15+
2025-11-16 10:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@primary_key {:id, :binary_id, autogenerate: true}
|
|
|
|
|
@foreign_key_type :binary_id
|
|
|
|
|
schema "action_requests" do
|
|
|
|
|
field :patient_name, :string
|
|
|
|
|
field :status, :string
|
|
|
|
|
field :assigned_user_id, :integer
|
|
|
|
|
field :delivery_scheduled_at, :naive_datetime
|
|
|
|
|
|
|
|
|
|
timestamps(type: :utc_datetime)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@doc false
|
|
|
|
|
def changeset(action_request, attrs) do
|
|
|
|
|
action_request
|
|
|
|
|
|> cast(attrs, [:patient_name, :status, :assigned_user_id, :delivery_scheduled_at])
|
|
|
|
|
|> validate_required([:patient_name, :status])
|
|
|
|
|
end
|
|
|
|
|
end
|