Expand description
Tablo: a server-rendered admin toolkit on Topcoat and Toasty.
A Panel serves one Resource per Toasty model. A resource names the model, whose
ModelColumns give its default table and detail page, and the record
form its create and edit submissions parse into, which ModelForm derives
from the model or RecordForm from a struct of its own. It declares the
rest as one ResourceDef value: its Policy, which denies by default, and any Table,
Schema or Detail that replaces or extends the defaults.
The app mounts the panel on its own Topcoat router with RouterBuilderPanelExt::panel, which
builds each def once, binds it to the database schema and checks it first; one router mounts any
number of panels at distinct prefixes.
#[derive(Debug, Clone, toasty::Model, tablo_core::ModelColumns, tablo_core::ModelForm)]
pub struct Book {
#[key]
#[auto]
pub id: uuid::Uuid,
pub title: String,
}
pub struct BookResource;
impl Resource for BookResource {
type Model = Book;
type Form = BookForm;
fn declare() -> ResourceDef<Self> {
ResourceDef::new().policy(Allow)
}
}
let router = Router::builder()
.discover()
.app_context(db)
.panel(Panel::new("admin").resource::<BookResource>())?
.build();The user guide walks through a complete panel and each
part of it. ResourceDef lists everything a resource declares, Resource the hooks it
overrides, and Panel every builder call.
Re-exports§
pub use auth::Auth;pub use auth::Authenticator;pub use auth::LoginThrottle;pub use auth::PanelUser;pub use auth::PasswordAuth;pub use auth::Registrar;pub use auth::SignUp;pub use auth::membership;pub use detail::Detail;pub use detail::IntoDetail;pub use form::FieldError;pub use form::FieldErrorKind;pub use form::FieldErrors;pub use form::FormField;pub use form::FormScalar;pub use form::FormValue;pub use form::FormValues;pub use form::NoForm;pub use form::Posted;pub use form::RecordForm;pub use notification::Notification;pub use notification::NotificationStatus;pub use panel::Brand;pub use panel::Panel;pub use panel::PanelHandle;pub use panel::RouterBuilderPanelExt;pub use panel::can_list;pub use panel::can_open;pub use panel::url;pub use policy::Ability;pub use policy::Allow;pub use policy::Deny;pub use policy::Policy;pub use policy::ReadOnly;pub use policy::when;pub use resource::Action;pub use resource::ActionInput;pub use resource::Committed;pub use resource::ForeignKey;pub use resource::HeaderAction;pub use resource::HeaderActions;pub use resource::Mutation;pub use resource::Places;pub use resource::PublicLink;pub use resource::Relation;pub use resource::Resource;pub use resource::ResourceDef;pub use resource::can;pub use resource::scoped_query;pub use resource::write_create;pub use resource::write_update;pub use schema::ChoiceField;pub use schema::CustomField;pub use schema::EmbeddedForm;pub use schema::Field;pub use schema::FieldResolver;pub use schema::FileField;pub use schema::Grid;pub use schema::Group;pub use schema::IntoFormValue;pub use schema::IntoOptions;pub use schema::IntoSchema;pub use schema::Options;pub use schema::RepeaterField;pub use schema::RepeaterItem;pub use schema::Schema;pub use schema::Section;pub use schema::Source;pub use schema::TextField;pub use schema::Toggle;pub use schema::Watched;pub use table::BooleanColumn;pub use table::ColumnWidth;pub use table::ComputedColumn;pub use table::CountColumn;pub use table::Cursor;pub use table::DateColumn;pub use table::DateFilter;pub use table::DateValue;pub use table::EmbeddedColumn;pub use table::FileColumn;pub use table::FilterValue;pub use table::IntoColumns;pub use table::IntoFilters;pub use table::ModelColumns;pub use table::QueryFilter;pub use table::RelationColumn;pub use table::RelationLens;pub use table::RepeaterColumn;pub use table::SelectFilter;pub use table::Sort;pub use table::Table;pub use table::TablePage;pub use table::TableState;pub use table::TernaryFilter;pub use table::TextColumn;pub use table::ToOneRelation;pub use table::WiredTable;pub use table::contains_expr;pub use tenancy::Membership;pub use tenancy::Tenancy;pub use tenancy::Tenant;pub use tenancy::TenantColumn;pub use tenancy::TenantId;pub use tenancy::require_tenant;pub use tenancy::tenant_id;pub use upload::DirUploader;pub use upload::Uploader;
Modules§
- auth
- Authenticates panel users and gates panel routes.
- csrf
- CSRF protection via double-submit cookie.
- db
- The
Dbglue: how Tablo code reaches the pooled Toasty database. - detail
- A resource’s detail page: the
Detaildeclaration, its columns arranged in layout blocks. - extend
- The traits that add a new kind of building block to a declaration: a
Columna table lists and a detail page shows, aFiltera table offers, aControlaField::customfield renders, anOptionSourcea relationship choice loads its options from, aTypedValuea text field parses, aFilterDateaDateFiltermatches by day, and aFilterKeyaSelectFiltermatches.Includes,FilterInput,FilterValue,ControlFutureandControlInputare what their methods take and return. - form
- Record forms: the typed value a form submission parses into, and the write that stores it.
- navigation
- Sidebar navigation:
NavigationItemand theNavTargetit points with. - notification
- Transient user-visible message produced by an
Action’s result and rendered in thePanelshell; stored as a JSON flash cookie with hardened attributes that Topcoat flushes on error responses too (topcoat#408). - panel
Panel— resources and pages under one prefix, which an app mounts into its router.- policy
- Authorizes resource abilities, denying by default.
- resource
Resource— maps one ToastyModelto its admin UI.- schema
- Unified Schema primitive — fields and layout blocks that compose via
view!. - table
- A resource’s list view: the
Tablebuilder and its columns and filters, the URL state a list reads, query planning (filter_expr/search_expr/order_bys_for), and the page a table loads. - tenancy
- Scopes resources to the request tenant.
- upload
- Names where uploaded bytes go: a file field binds a
Stringcolumn and the app’sUploaderdecides what path the record stores.
Macros§
- lens
- Build a
Lensfrom a model and a field, or a chain of embedded fields. - relation
- Build a
RelationLensfrom a model and one of its relation fields.
Structs§
- Declaration
Error - One declaration mistake: who declares it, where, and what is wrong.
- Lens
- A model field’s typed path, which queries filter and sort on, paired with the function that reads the field off a loaded record.
- Mount
Error - Why
RouterBuilderPanelExt::panelrefused a panel: every declaration mistake it found. - PageDef
- What a
Pagedeclares: its slug, sidebar entry, access and header actions.
Enums§
- Action
Input Fault - Why an action’s input cannot be served:
DeclarationErrorKind::ActionInput. - Declaration
Error Kind - What is wrong with a declaration.
- Many
ToMany Fault - Why a many-to-many field or relation cannot link records:
DeclarationErrorKind::ManyToMany. - Segment
Fault - Why a path segment cannot be a literal URL segment.
- Sign
UpFault - Why a panel’s sign-up page cannot be served:
DeclarationErrorKind::SignUp. - Site
- The part of a declaration a
DeclarationErroris in.
Traits§
- Page
- A panel page that is not a resource, mounted at
{prefix}/{slug}with a sidebar entry; the panel owns the route and entry while the page owns its markup.
Functions§
- header_
action_ buttons - The header buttons of the page
Pthe request may run, for itspage_actions:
Derive Macros§
- Action
Input - Derives
ActionInputfor the typed value anActionasks for before it runs. - Embedded
Form - Derives
EmbeddedFormfor an embedded struct or enum. - Model
Columns - Derive a model’s
ModelColumns: the table a resource lists it in and the detail page it shows it on, when the resource declares neither. - Model
Form - Derive a model’s
RecordFormstruct from the model: the fields a person fills, named and typed as the model declares them. - Options
- Derive
Optionsfor a unit-variant enum: the(value, label)list a choice field, a select filter and a column share, and theFormScalarthat posts a variant as its value and reads it as its label. - Record
Form - Derive
RecordFormfor the typed value a resource’s form writes. - Repeater
Item - Derives
RepeaterItemfor one item of a repeater: an embedded struct a#[document]list stores.