Skip to main content

Module prelude

Module prelude 

Source
Expand description

The items a resource module names most: use tablo::prelude::*;.

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.
t
A message spelled in the request’s locale: t!(cx, "id", name = value, ..) is text!("id", name = value, ..).localize(cx), for what takes a String, such as a Notification’s title.
text
A Text message with its arguments: text!("id", name = value, ..) is Text::message("id").arg("name", value)...

Structs§

Abilities
A policy that answers each Ability from the check declared for it, and denies every ability it declares none for.
ActionDef
What an Action declares besides its name, input and body: where its button renders, how it reads on each record, and which records it runs on. Every setting has a default, so ActionDef::new alone is a button on each row, page header and the bulk bar, labelled after the action’s NAME, that runs on every record the policy allows.
Allow
Allows every ability.
Area
A part of a panel under {prefix}/{slug} with a sidebar of its own: a settings area, an account area. Registered with Panel::area.
Auth
The panel’s authentication configuration (ADR-0013).
BooleanColumn
A column of a bool field rendered as an icon.
Brand
Branding for the panel’s shell: the sidebar header, the login card, and the topbar below md, where the sidebar folds into a sheet.
Chart
A chart for a Widget’s body: a heading, labels along the bottom, such as months, and one Series of values per thing it measures. chart draws it.
ChoiceField
A choice field: Field::choice, or a record form’s choice control (F is the form).
ColorColumn
A column of a String field holding a CSS color, rendered as a swatch beside the value.
ComputedColumn
A display-only column rendering any text from the row, with no query predicate.
CountColumn
A column counting the records of a Deferred has_many field that a source S shows, a many-to-many #[has_many(via = ..)] one included.
Currency
How a money column spells its amounts: the symbol, where it goes, the decimals, and whether the field stores minor units.
CustomField
A field an app’s Control renders: Field::custom and Field::toggle, or a record form’s toggle (F is the form).
DateColumn
A column of a date field, rendered as a calendar day.
DateFilter
Date filter matching a date or time field by calendar day, or by a range of days; see FilterDate for the types.
Deny
Allows nothing: the default policy.
Detail
The declaration of a detail page: Columns, the same ones a Table lists, arranged in Section, Group, Grid and Tabs blocks.
EmbeddedColumn
A column of an EmbeddedForm value.
Environment
The deployment a panel runs in, such as staging: every page of the panel, its sign-in pages included, carries a stripe and a badge in its color, and its browser tab title starts with its name.
Field
One form field binding a lens to the control editing it, offering only that control’s modifiers so a modifier on the wrong control does not compile.
FieldAccess
Who may view one field of a model’s records, and who may change it, which ResourceDef::field_access declares: every resource the panel mounts over the model obeys the rule.
FieldErrors
A refused submission, keyed by the form whose fields it names.
FileColumn
A column of a String field holding an uploaded file’s path, rendered as a link to the file.
FileField
A file field: Field::file, or a record form’s file control (F is the form).
FormValues
What a form holds, one FormValue per key: a submission its schema read, or a stored record as its record form spells it.
GlobalSearch
How a resource’s records show in its panel’s global search, as ResourceDef::global_search declares it: the details listed under each result’s title.
Grid
A block of cols columns, clamped to 1..12, laying out a form’s fields or a detail page’s columns.
Group
An unlabelled block grouping a form’s fields or a detail page’s columns.
HeaderActionDef
What a HeaderAction declares besides its name, input and body: how its button reads, whether it asks first, and who it runs for beyond the policy or the page’s access. Every setting has a default, so HeaderActionDef::new alone is a gray button labelled after the action’s NAME.
HeaderActions
The HeaderActions a page or a resource declares, in button order.
IconColumn
A column of one field shown as an icon in its color, its label read to a screen reader and shown when the pointer rests on it.
ImageColumn
A column of a String field holding an uploaded image’s path, rendered as a thumbnail.
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.
ListTab
One tab a table offers above its rows: a preset predicate the reader picks with ?tab=<key>, beside the search and the filters it combines with.
Look
The theme and the sidebar frame one request wears over its Brand’s, which the function passed to Brand::look answers for every page the panel renders, sign-in included: a visitor’s own pick, read from a cookie the app writes.
NavigationItem
A sidebar entry: a resource’s, from its ResourceDef, or a Page’s.
NoForm
The record form of a resource with no create or edit page.
NumberFilter
Number filter matching a number field exactly, or between two bounds; see FilterNumber for the types.
Outcome
What an Action or a HeaderAction asks of the response once its write commits: which notification it flashes and where it lands.
PageDef
What a Page declares: its slug, sidebar entry, title, access, header actions and widgets.
PageFilter
A value a page offers above its widgets and keeps in its query string, which its widgets read through page_filters: the period a dashboard’s figures cover, or the store they count.
PageFilters
The values the request holds for its page’s filters, which a widget reads: page_filters returns it.
Panel
An admin panel: resources and pages under one prefix, framed by one shell and gated by one Auth. Its pages carry a robots tag that asks search engines to neither index them nor follow their links.
Places
Where an Action’s button renders: ActionDef::places.
Posted
An edit submission: the parsed form, and the fields the submission named.
PresenceFilter
Presence filter matching an Option field by whether it holds a value: f.<name>=set or f.<name>=empty.
PublicLink
A record’s public page, linked from its detail and edit pages.
QueryFilter
A filter offering named predicates, such as an embedded-enum variant or any query the app names. Several values match a record any of their predicates selects, which multiple lets the control choose. A filter whose predicates read a field field_access hides from the user does not show to them: the panel reads the fields off the predicates.
ReadOnly
Allows listing and viewing, and nothing else: no export, and no create, update, delete or custom action.
Reads
The fields of M a Column or a Filter reads, by the root field each path starts at: what field_access hides it by.
RecordPageDef
What a RecordPage declares: its slug, label, icon and access. Every setting has a default.
RecordTable
A few of a resource’s records as a table for a Widget’s body, under the resource’s own columns: the newest posts, the orders awaiting review. record_table loads and renders it.
Relation
One relation of a parent resource’s records.
RelationColumn
A column showing the record of a Deferred belongs_to or has_one field as text, or the records of a has_many one (list), which declares the field’s include so every page that renders it loads them.
RepeaterColumn
A column of a list of FormInput items.
ResourceDef
What a Resource declares, from its names, policy and tenancy to its pages and actions.
RichTextColumn
A column of a String field holding a rich text field’s HTML. A detail page shows the formatted HTML; a table cell shows its text, cut to excerpt characters; an export holds the text.
RichTextField
A rich text field: Field::rich_text, or a record form’s text control made one with TextField::rich_text (F is the form).
RowLink
A link among a row’s actions, such as a product’s storefront page: unlike an Action, it posts nothing and runs no policy check, so it suits only a page the user may already open.
Schema
Composes fields and layout blocks and resolves every field once into one list.
Section
A titled block holding a form’s fields (schema) or a detail page’s columns (columns, which detail declares).
SelectColumn
A column of an Options field rendered as a select that saves the record when it changes.
SelectFilter
Select filter matching a field exactly: a String, any FormScalar such as an Options enum, or a foreign key to a relationship’s rows. Several values match a record holding any of them, which multiple lets the control choose.
Series
One thing a Chart measures: a label for its legend and a value per label of the chart.
Sort
A column and a direction to sort a table by: parsed from ?sort=<column>&dir=asc|desc, or declared as the table’s default.
Stat
One figure of a stats row: what it counts, the value, and optionally a line under it, an icon, a link, a trend and a sparkline.
Step
One step of a Wizard block: a titled trigger and the fields it shows.
Submits
The buttons of an action’s input dialog and input page beside the action’s own, each running the same action with one checkbox of the input checked.
Summary
A figure a list shows under its rows: how many records it selects under the reader’s tab, search and filters, across every page, or how many of those a predicate selects.
Tab
One tab of a Tabs block: a titled trigger and the fields or columns it shows.
Table
Table description of a Resource’s list view declaring columns and how they map to queries.
Tabs
A block showing one Tab at a time, each holding a form’s fields (Tab::schema) or a detail page’s columns (Tab::columns).
Tenancy
How a resource’s rows belong to a tenant.
TenantId
One tenant’s id, and the field type of a resource’s tenant column.
TernaryFilter
Ternary filter matching a bool field.
Text
A word a panel renders: plain text, or a message the request’s Locale spells.
TextColumn
A column of one field, rendered as text and bound through a Lens for sorting and search.
TextField
A text field: Field::text, or a record form’s text control (F is the form).
TextFilter
Text filter matching a String or Option<String> field by a term the user types, the way a TextMatch names.
TextInputColumn
A column of one field rendered as a text input that saves the record on Enter.
Toggle
Renders a bool field as a checkbox preceded by a hidden false.
ToggleColumn
A column of a bool field rendered as a switch that saves the record when it flips.
WidgetDef
What a Widget declares: how many columns of the grid it spans, and who sees it.
Wizard
A block walking a form’s fields one Step at a time, with a button to the next step and one back.

Enums§

Ability
One thing a policy is asked to allow; record abilities are asked once per loaded row, and a record that cannot be viewed cannot be written by guessing its key.
ActionLayout
Where a table puts a row’s actions: its custom actions, View, Edit and Delete.
Alignment
Where a column’s header and cells align their content.
Change
What one write of a resource changed: the mutation and the rows it wrote.
Color
A semantic color for a badge, a status dot or a cell’s text.
ColumnWidth
How a Column takes the table’s width.
FontWeight
How heavy a column’s text renders.
Pagination
How a table pages through its rows.
Radius
How round a Brand’s controls, cards and badges are, over its theme’s.
ResourcePage
A record page a resource serves beside its list, unless without_page turns it off.
SidebarFrame
How the sidebar sits beside the page, which a Brand picks with Brand::sidebar over its Theme’s.
TextMatch
How a TextFilter matches its term, which the f.<name>.op part names.
Theme
One of the looks Tablo ships, which a Brand picks with Brand::theme: its palette in both color schemes, its type, corners and shadows, and the SidebarFrame it suggests. Every theme speaks the same grammar (captions over the sidebar’s groups and the tables’ columns, the current page notched in the primary color, the title ruled off from the page, ruled head bands), each in a voice of its own.
Tool
One button of a rich text field’s toolbar. A tool is also a grant: the field keeps only the elements and attributes its tools produce, so a tool left off the toolbar cannot be typed, is dropped from a paste, and is removed from a forged post.
Trend
Which way a Stat’s figure moved, shown as an arrow before its detail line.
WriteError
Why a record fn or an action’s run wrote nothing: a refusal the page shows, or a failure.

Traits§

Action
A mutation beyond create, update and delete: “publish”, “archive”, “resend the invite”.
DateValue
The field types a DateColumn spells as a calendar day: jiff::civil::Date, jiff::civil::DateTime, jiff::Timestamp (read in the request’s time_zone, as a DateFilter reads it) and an Option of any of them.
EmbeddedForm
Reads an embedded value from and writes it to FormValues, one key per leaf; derive it to generate the value’s schema.
FormInput
A typed value a form posts under its own keys, which no column binds: what an Action asks for before it runs, what a sign-up reads, one item of a repeater.
HeaderAction
A mutation that acts on no record, run from a button in a page’s header: “import posts”, “clear the cache”, “recompute the totals”.
IntoOptions
A choice’s static options as (value, label) pairs, in display order. A value listed alone is its own label; a label is a Text, so a message translates it.
Options
A closed set of values, each with its label.
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.
PanelModel
What a panel needs from a model a resource serves: its tenant columns, its version counter, how to copy a record without its relations, and the table and detail page it reads as when its resource declares none, which a ResourceDef without a table lists and without a detail shows.
Policy
Decides which Abilitys the current user has over a resource’s records.
RecordForm
The typed value a resource’s form submission parses into.
RecordPage
A page about one record of the resource R, served at {list}/{key}/{slug} and linked from the record’s navigation: the tab bar its detail page, edit page, record pages and relation tabs share. The panel loads the record and checks the request may open the page; the page renders its body.
Resource
Maps one Toasty Model to its admin UI.
RouterBuilderPanelExt
Mounts a Panel on a router the app owns.
Widget
One block of a page’s widget grid: a row of stats, a chart, a list of recent records.

Functions§

can
Whether the request may do ability on R as the context’s panel mounted it: what the ability’s button and route ask. false when the panel does not mount R. Does not check sign-in or tenant scope.
can_list
Whether the current request may open R’s list: the request’s panel mounts R, and sign-in, tenant scope, and Ability::ViewAny allow it.
can_open
Whether the current request may open the page P: the request’s panel mounts P, and sign-in and PageDef::access allow it, the checks the page’s GET makes.
can_view_field
Whether the current request may view R’s field: the request’s panel mounts R, and no ResourceDef::field_access rule over the model hides the field from it. The panel’s own pages mask a hidden field; a RecordPage shows one only after asking this.
filter_keys
The predicate selecting each of records by its primary key, so that an action writes the same change to all of them in one statement rather than one per record:
list_query
R’s records as its list shows them in this request: the scoped_query the list reads, narrowed by its tab, search and filters, unordered. A list_widget reading it shows figures that follow the list, and reruns with it as the reader searches, filters or switches tabs.
page_filters
The values the request holds for the filters of the page it renders: the registered Page whose URL its path names. A widget reads them to narrow what it shows. Outside such a page, as in a resource list’s widgets, it holds none.
scoped_query
The tenant-scoped base query.
tenant_id
The tenant the request acts for, if any.
when
Allows every ability while predicate holds for the request.

Derive Macros§

EmbeddedForm
Derives EmbeddedForm for an embedded struct or enum.
FormInput
Derives FormInput for a typed value a form posts under its own keys: what an Action asks for before it runs, what a sign-up reads, or one item of a repeater.
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.
PanelModel
Derive a model’s PanelModel: its tenant columns, its version counter, its copy without relations, and the table a resource lists it in and the detail page it shows it on when the resource declares neither.
RecordForm
Derive RecordForm for the typed value a resource’s form writes.