Skip to main content

Crate tablo_core

Crate tablo_core 

Source
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 navigation::NavTarget;
pub use navigation::NavigationItem;
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::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 Db glue: how Tablo code reaches the pooled Toasty database.
detail
A resource’s detail page: the Detail declaration, its columns arranged in layout blocks.
extend
The traits that add a new kind of building block to a declaration: a Column a table lists and a detail page shows, a Filter a table offers, a Control a Field::custom field renders, an OptionSource a relationship choice loads its options from, a TypedValue a text field parses, a FilterDate a DateFilter matches by day, and a FilterKey a SelectFilter matches. Includes, FilterInput, FilterValue, ControlFuture and ControlInput are 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: NavigationItem and the NavTarget it points with.
notification
Transient user-visible message produced by an Action’s result and rendered in the Panel shell; 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 Toasty Model to its admin UI.
schema
Unified Schema primitive — fields and layout blocks that compose via view!.
table
A resource’s list view: the Table builder 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 String column and the app’s Uploader decides what path the record stores.

Macros§

lens
Build a Lens from a model and a field, or a chain of embedded fields.
relation
Build a RelationLens from a model and one of its relation fields.

Structs§

DeclarationError
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.
MountError
Why RouterBuilderPanelExt::panel refused a panel: every declaration mistake it found.
PageDef
What a Page declares: its slug, sidebar entry, access and header actions.

Enums§

ActionInputFault
Why an action’s input cannot be served: DeclarationErrorKind::ActionInput.
DeclarationErrorKind
What is wrong with a declaration.
ManyToManyFault
Why a many-to-many field or relation cannot link records: DeclarationErrorKind::ManyToMany.
SegmentFault
Why a path segment cannot be a literal URL segment.
SignUpFault
Why a panel’s sign-up page cannot be served: DeclarationErrorKind::SignUp.
Site
The part of a declaration a DeclarationError is 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 P the request may run, for its page_actions:

Derive Macros§

ActionInput
Derives ActionInput for the typed value an Action asks for before it runs.
EmbeddedForm
Derives EmbeddedForm for an embedded struct or enum.
ModelColumns
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.
ModelForm
Derive a model’s RecordForm struct from the model: the fields a person fills, named and typed as the model declares them.
Options
Derive Options for a unit-variant enum: the (value, label) list a choice field, a select filter and a column share, and the FormScalar that posts a variant as its value and reads it as its label.
RecordForm
Derive RecordForm for the typed value a resource’s form writes.
RepeaterItem
Derives RepeaterItem for one item of a repeater: an embedded struct a #[document] list stores.