pub struct RegisteredResource { /* private fields */ }Expand description
A runtime resource as the registry holds it: the definition, ready for the panel.
Implementations§
Source§impl RegisteredResource
impl RegisteredResource
Sourcepub fn new(resource: RuntimeResource) -> Result<Self, RuntimeError>
pub fn new(resource: RuntimeResource) -> Result<Self, RuntimeError>
Checks resource as register_runtime does, without adding it to the registry: its
slug and its field names. The panel uses it for a resource defined by data that is part
of the panel from its start (Ignite::runtime_resource), such as the Users screen.
Sourcepub fn resource(&self) -> &RuntimeResource
pub fn resource(&self) -> &RuntimeResource
The definition that was registered.
The label of the navigation entry: the navigation label, or the title.
The navigation group the resource is listed under, if any.
The resource’s place in the navigation, if set.
The navigation entry the resource is listed under, if any.
The name of the navigation entry’s icon, if set.
The label of the navigation entry’s create link, or None when it lists none.
Sourcepub fn validate(&self, form: &FormInput) -> Result<Row, FieldErrors>
pub fn validate(&self, form: &FormInput) -> Result<Row, FieldErrors>
Turns the submitted form into a Row for a create, or returns one message per
field. It runs the same checks as a static resource, with the same messages:
required fields (Field::check_required), whole
numbers, decimals, dates, date-times and select choices. The row holds one key per
field:
- text, textarea, select, lookup: a string. A required value is trimmed.
- email, URL, radio, color, image, file, link, wysiwyg, post object, checkbox list,
relationship,
taxonomy, user, repeater, group, flexible content, gallery, clone: the text
Field::check_valuereturns. The structured kinds hold JSON text. - number: an integer. Decimal: a number.
- checkbox:
trueorfalse; a checkbox is never blank. - date:
"YYYY-MM-DD". Date-time:"YYYY-MM-DD HH:MM:SS". - password: the hash of the password (
hash_password). - a blank field that is not required:
null.
Each error in FieldErrors is keyed by the field’s name, an owned String.
A lookup, post object, relationship, taxonomy or user value is checked against
RuntimeData::options by the panel, which can read the database, and so is a media
id against the registered MediaLibrary.
Sourcepub fn validate_update(&self, form: &FormInput) -> Result<Row, FieldErrors>
pub fn validate_update(&self, form: &FormInput) -> Result<Row, FieldErrors>
Turns the submitted form into a Row for an update. It is
validate, except that:
- a blank password is not an error: the row leaves its key out, so the stored password is kept;
- an optional field the form did not send at all (
FormInput::hasis false) is left out of the row, so its stored value is kept; - an optional field sent blank is
null, so clearing it on the edit form clears the stored value, as#[derive(IgniteResource)]does since 0.3.0; - a checkbox the form did not send is
false, because an unticked HTML checkbox sends nothing.
Sourcepub fn conditions(&self) -> &FieldConditions
pub fn conditions(&self) -> &FieldConditions
The conditions that show or hide the form’s fields.
Sourcepub fn form_layout(&self) -> &FormLayout
pub fn form_layout(&self) -> &FormLayout
The layout of the create and edit forms.
Sourcepub fn default_active_tab(&self) -> Option<&str>
pub fn default_active_tab(&self) -> Option<&str>
The key of the tab shown when the list has no tab parameter, if set.
Sourcepub fn column_badges(&self) -> &ColumnBadges
pub fn column_badges(&self) -> &ColumnBadges
The list columns shown as coloured badges.
Sourcepub fn tab_counts_follow_search(&self) -> bool
pub fn tab_counts_follow_search(&self) -> bool
Whether each tab’s count is for the current search.
Sourcepub fn hide_empty_tabs(&self) -> bool
pub fn hide_empty_tabs(&self) -> bool
Whether a tab whose count is 0 is left out.
Sourcepub fn row_actions(&self) -> &[RowAction]
pub fn row_actions(&self) -> &[RowAction]
The actions on each row of the list, in display order.
Sourcepub fn hide_default_delete_when(&self) -> Option<&ListFilter>
pub fn hide_default_delete_when(&self) -> Option<&ListFilter>
The records whose built-in Delete button is hidden, if set.
Sourcepub fn repeaters(&self) -> &Repeaters
pub fn repeaters(&self) -> &Repeaters
The settings of the form’s repeaters and flexible content fields.
Sourcepub fn ability_for(&self, action: ResourceAction) -> String
pub fn ability_for(&self, action: ResourceAction) -> String
The ability action on the resource needs: the one RuntimeResource::ability
names, or <slug>.<action>, such as books.update.
Sourcepub fn access_ability(&self) -> Option<&str>
pub fn access_ability(&self) -> Option<&str>
The ability every action needs besides its own, if any
(RuntimeResource::access_ability).
Sourcepub fn required_abilities(&self, action: ResourceAction) -> Vec<String>
pub fn required_abilities(&self, action: ResourceAction) -> Vec<String>
Every ability action needs: the access ability, if any, and the action’s own.
Sourcepub fn ability_names(&self) -> Vec<String>
pub fn ability_names(&self) -> Vec<String>
Every ability the resource’s actions need, without repeats, in action order: the permissions the panel registers for it.
Sourcepub fn record_route_key_name(&self) -> &str
pub fn record_route_key_name(&self) -> &str
The row key that addresses a record in the panel’s URLs: the
record_route_key_name, or id.
Sourcepub fn is_read_only(&self, form: &FormContext<'_>) -> bool
pub fn is_read_only(&self, form: &FormContext<'_>) -> bool
Whether the record of the edit form form is read-only for its user
(RuntimeResource::read_only_when).
Sourcepub fn read_only_notice(&self, form: &FormContext<'_>) -> Option<String>
pub fn read_only_notice(&self, form: &FormContext<'_>) -> Option<String>
The line the form of a read-only record shows, if any.
Sourcepub fn validate_shown(
&self,
form: &FormInput,
hidden: &BTreeSet<String>,
) -> Result<Row, FieldErrors>
pub fn validate_shown( &self, form: &FormInput, hidden: &BTreeSet<String>, ) -> Result<Row, FieldErrors>
validate for a form whose fields hidden are hidden (see
FieldConditions::hidden_fields): they are not checked, a required one included, and
the row has no key for them, so the source writes nothing for them. The panel calls it.
Sourcepub fn validate_update_shown(
&self,
form: &FormInput,
hidden: &BTreeSet<String>,
) -> Result<Row, FieldErrors>
pub fn validate_update_shown( &self, form: &FormInput, hidden: &BTreeSet<String>, ) -> Result<Row, FieldErrors>
validate_update for a form whose fields hidden are hidden:
the row has no key for them, so their stored values are kept, whatever the form sent.
Auto Trait Implementations§
impl !RefUnwindSafe for RegisteredResource
impl !UnwindSafe for RegisteredResource
impl Forget for RegisteredResource
impl Freeze for RegisteredResource
impl Move for RegisteredResource
impl Send for RegisteredResource
impl Sync for RegisteredResource
impl Unpin for RegisteredResource
impl UnsafeUnpin for RegisteredResource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more