Skip to main content

RegisteredResource

Struct RegisteredResource 

Source
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

Source

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.

Source

pub fn resource(&self) -> &RuntimeResource

The definition that was registered.

Source

pub fn slug(&self) -> &str

The slug, as the panel’s routes match it.

Source

pub fn title(&self) -> &str

The heading and navigation label.

Source

pub fn singular(&self) -> &str

The name of one record.

Source

pub fn navigation_label(&self) -> &str

The label of the navigation entry: the navigation label, or the title.

Source

pub fn navigation_group(&self) -> Option<&str>

The navigation group the resource is listed under, if any.

Source

pub fn navigation_sort(&self) -> Option<i32>

The resource’s place in the navigation, if set.

Source

pub fn navigation_parent_item(&self) -> Option<&str>

The navigation entry the resource is listed under, if any.

Source

pub fn navigation_icon(&self) -> Option<&str>

The name of the navigation entry’s icon, if set.

Source

pub fn navigation_create_item(&self) -> Option<&str>

The label of the navigation entry’s create link, or None when it lists none.

Source

pub fn fields(&self) -> &[FieldDef]

The form fields, in display order.

Source

pub fn columns(&self) -> &[ColumnDef]

The list columns, in display order.

Source

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_value returns. The structured kinds hold JSON text.
  • number: an integer. Decimal: a number.
  • checkbox: true or false; 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.

Source

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::has is 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.
Source

pub fn conditions(&self) -> &FieldConditions

The conditions that show or hide the form’s fields.

Source

pub fn form_layout(&self) -> &FormLayout

The layout of the create and edit forms.

Source

pub fn tabs(&self) -> &[Tab]

The tabs of the list page, in display order.

Source

pub fn default_active_tab(&self) -> Option<&str>

The key of the tab shown when the list has no tab parameter, if set.

Source

pub fn column_badges(&self) -> &ColumnBadges

The list columns shown as coloured badges.

Whether each tab’s count is for the current search.

Source

pub fn hide_empty_tabs(&self) -> bool

Whether a tab whose count is 0 is left out.

Source

pub fn row_actions(&self) -> &[RowAction]

The actions on each row of the list, in display order.

Source

pub fn hide_default_delete_when(&self) -> Option<&ListFilter>

The records whose built-in Delete button is hidden, if set.

Source

pub fn repeaters(&self) -> &Repeaters

The settings of the form’s repeaters and flexible content fields.

Source

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.

Source

pub fn access_ability(&self) -> Option<&str>

The ability every action needs besides its own, if any (RuntimeResource::access_ability).

Source

pub fn required_abilities(&self, action: ResourceAction) -> Vec<String>

Every ability action needs: the access ability, if any, and the action’s own.

Source

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.

Source

pub fn redirect_after_create(&self) -> RedirectAfter

Where a successful create goes: the redirect_after_create, or the list.

Source

pub fn redirect_after_update(&self) -> RedirectAfter

Where a successful update goes: the redirect_after_update, or the list.

Source

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.

Source

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).

Source

pub fn read_only_notice(&self, form: &FormContext<'_>) -> Option<String>

The line the form of a read-only record shows, if any.

Source

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.

Source

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
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<FieldDef>: Freeze, PhantomData<ColumnDef>: Freeze, *const ArcInner<dyn RuntimeData> is !null: Freeze, PhantomData<ArcInner<dyn RuntimeData>>: Freeze, PhantomData<(String, Arc<dyn Fn(&FormContext<'_>) -> bool + Sync + Send>)>: Freeze, *const LeafNode<String, SetValZST> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, SetValZST)>>: Freeze, PhantomData<(String, String)>: Freeze, PhantomData<Component>: Freeze, PhantomData<Tab>: Freeze, *const LeafNode<String, Badge> is !null: Freeze, PhantomData<Box<(String, Badge)>>: Freeze, PhantomData<RowAction>: Freeze, PhantomData<FilterCondition>: Freeze, *const LeafNode<String, RepeaterSettings> is !null: Freeze, PhantomData<Box<(String, RepeaterSettings)>>: Freeze, *const ArcInner<dyn Fn(&FormContext<'_>) -> bool + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&FormContext<'_>) -> bool + Sync + Send>>: Freeze, *const ArcInner<dyn Fn(&FormContext<'_>) -> Option<String> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&FormContext<'_>) -> Option<String> + Sync + Send>>: Freeze, *const LeafNode<ResourceAction, String> is !null: Freeze, PhantomData<Box<(ResourceAction, String)>>: Freeze,

§

impl Move for RegisteredResource

§

impl Send for RegisteredResource
where RawVecInner: Send, Arc<dyn RuntimeData>: Send, RawTable<(String, Arc<dyn Fn(&FormContext<'_>) -> bool + Sync + Send>)>: Send, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Send, BoxRaw<(String, SetValZST)>: Send, RawTable<(String, String)>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, NodeRef<Owned, String, Badge, LeafOrInternal>: Send, BoxRaw<(String, Badge)>: Send, Arc<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send>: Send, Arc<dyn Fn(&Map<String, Value>) -> bool + Sync + Send>: Send, NodeRef<Owned, String, RepeaterSettings, LeafOrInternal>: Send, BoxRaw<(String, RepeaterSettings)>: Send, Arc<dyn Fn(&FormContext<'_>) -> bool + Sync + Send>: Send, Arc<dyn Fn(&FormContext<'_>) -> Option<String> + Sync + Send>: Send, NodeRef<Owned, ResourceAction, String, LeafOrInternal>: Send, BoxRaw<(ResourceAction, String)>: Send,

§

impl Sync for RegisteredResource
where RawVecInner: Sync, Arc<dyn RuntimeData>: Sync, RawTable<(String, Arc<dyn Fn(&FormContext<'_>) -> bool + Sync + Send>)>: Sync, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Sync, BoxRaw<(String, SetValZST)>: Sync, RawTable<(String, String)>: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, NodeRef<Owned, String, Badge, LeafOrInternal>: Sync, BoxRaw<(String, Badge)>: Sync, Arc<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send>: Sync, Arc<dyn Fn(&Map<String, Value>) -> bool + Sync + Send>: Sync, NodeRef<Owned, String, RepeaterSettings, LeafOrInternal>: Sync, BoxRaw<(String, RepeaterSettings)>: Sync, Arc<dyn Fn(&FormContext<'_>) -> bool + Sync + Send>: Sync, Arc<dyn Fn(&FormContext<'_>) -> Option<String> + Sync + Send>: Sync, NodeRef<Owned, ResourceAction, String, LeafOrInternal>: Sync, BoxRaw<(ResourceAction, String)>: Sync,

§

impl Unpin for RegisteredResource
where *const u8 is !null: Unpin, Arc<dyn RuntimeData>: Unpin, Arc<dyn Fn(&FormContext<'_>) -> bool + Sync + Send>: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, *const LeafNode<String, Badge> is !null: Unpin, Box<(String, Badge)>: Unpin, Arc<dyn for<'a> Fn(&'a Database, &'a ActingUser, i64, &'a Map<String, Value>) -> Pin<Box<dyn Future<Output = Result<Result<(), String>, Error>> + Send + 'a>> + Sync + Send>: Unpin, Arc<dyn Fn(&Map<String, Value>) -> bool + Sync + Send>: Unpin, *const LeafNode<String, RepeaterSettings> is !null: Unpin, Box<(String, RepeaterSettings)>: Unpin, Arc<dyn Fn(&FormContext<'_>) -> Option<String> + Sync + Send>: Unpin, *const LeafNode<ResourceAction, String> is !null: Unpin, Box<(ResourceAction, String)>: Unpin,

§

impl UnsafeUnpin for RegisteredResource

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more