//! Generated by `rustio-admin startapp {{name}}`. Customise freely.
use rustio_admin::{DateTime, ModelAdmin, RustioAdmin, Utc};
// `#[derive(RustioAdmin)]` generates the admin metadata AND the
// `impl Model` ORM glue (COLUMNS, row decoder, insert binder) from these
// fields — no hand-written code to keep in sync. `#[rustio(table =
// "…")]` pins the SQL table to the one this app's migration creates.
#[derive(RustioAdmin)]
#[rustio(table = "{{table}}")]
pub struct {{Singular}} {
pub id: i64,
pub name: String,
pub created_at: DateTime<Utc>,
}
// The `ModelAdmin` impl below customises the admin list / form
// surface for `{{Singular}}`. Every method has a sensible default;
// these starter overrides exist so the generated project's first
// list page already feels production-shaped (searchable, filterable,
// sortable). Remove anything you don't need.
impl ModelAdmin for {{Singular}} {
/// Columns shown in the list-page table. Order matters.
/// Defaults to `&["id"]` when not overridden.
fn list_display() -> &'static [&'static str] {
&["id", "name", "created_at"]
}
/// Columns whose `=` value is filterable via `?filter_<col>=<v>`
/// chips above the list page. Strings, enums, and small-cardinality
/// columns make the most sense here.
fn list_filter() -> &'static [&'static str] {
// Example: filter the list by a status enum.
// &["status"]
&[]
}
/// Columns that the list-page `?q=...` search box matches with
/// `ILIKE`. Text + email columns are the usual candidates.
fn search_fields() -> &'static [&'static str] {
&["name"]
}
/// Default sort order. Prefix with `-` for descending.
fn ordering() -> &'static [&'static str] {
&["-created_at"]
}
// Rows per list page before pagination kicks in. Default is 50.
//
// fn list_per_page() -> usize { 50 }
// Bulk-action surface. Each returned `BulkAction` becomes a
// button in the list-page "Actions" dropdown; the framework
// wires the two-step confirm flow at
// `POST /admin/{{table}}/bulk/<slug>`.
//
// fn bulk_actions() -> &'static [BulkAction] {
// &[BulkAction { slug: "archive", label: "Archive selected" }]
// }
}