Expand description
Generic model-admin — a ModelViewSet-style CRUD admin for
arbitrary #[derive(Model)] types, rendered inside the CMS admin
chrome.
The framework’s own ListView/ViewSet can’t inject the CMS’s
async, DB-backed add_chrome, so they can’t back a chrome’d admin
screen. This is a CMS-native path: a host registers a model with
register_model_admin!, which captures the model’s
rustango::core::ModelSchema + a type-erased “list rows
as JSON” thunk, and the admin serves a chrome’d index at
/cms-admin/model/<slug> driven by the model’s list_display.
It ships the registry + the read-only, paged index. Create / edit /
delete (generic forms from FieldSchema) + filter / search / order
are not implemented yet.
Structs§
- Model
Admin - One registered model admin.
Functions§
- find
- The model admin registered under
slug, if any. - list_
columns - The index columns as
(field_name, header_label)pairs. Uses the model’sadmin(list_display = …)when set; otherwise falls back to thedisplayfield, else the first few scalar fields — so a model with no admin hints still renders something useful. - registered
- Every registered model admin, sorted by slug.
- row_
cell - Render one row’s value for column
colas a display string. Strings pass through; null / missing → empty; everything else → its compact JSON (numbers, bools, nested objects).
Type Aliases§
- List
Rows Fn - Type-erased “fetch one page of the model’s rows as JSON” — the index
data source. Called with
(pool, limit, offset); returns that window in primary-key order plus the total row count. Built byregister_model_admin!from the concrete model’sobjects()(a derive-generated inherent method, so it can’t be reached generically — hence the thunk).