Skip to main content

ColumnBadges

Struct ColumnBadges 

Source
pub struct ColumnBadges { /* private fields */ }
Expand description

The list columns that show their value as a coloured badge, by column key, as Filament’s TextColumn::make($key)->badge()->color(fn (string $state) => ...). A column that is not listed shows its value as plain text.

A badge can also show inside another column’s cell, after its text, instead of in a column of its own (badge_inside), such as a post’s status beside its title; and only on some tabs of the list (badge_on_tabs). The panel decides both when it renders the page, so the page needs no script for them.

Implementations§

Source§

impl ColumnBadges

Source

pub fn new() -> Self

No badge columns.

Source

pub fn badge(self, column: impl Into<String>) -> Self

Shows the column column as a badge in the primary colour, as Filament’s ->badge() with no color().

Source

pub fn badge_color( self, column: impl Into<String>, color: impl Fn(&str) -> BadgeColor + Send + Sync + 'static, ) -> Self

Shows the column column as a badge whose colour color picks from the cell’s state, as Filament’s ->badge()->color(fn (string $state): string => match ($state) { ... }). The state is the stored value as text, such as "draft", before a select’s or a lookup’s label replaces it for display.

Source

pub fn badge_inside( self, column: impl Into<String>, target: impl Into<String>, ) -> Self

Shows the badge of the column column inside the cell of the column target, after its text, and not as a column of its own: the list has no column for column, even when the resource lists it. column need not be a list column: its value is read from the row. It is a badge in the primary colour unless badge_color gives it a colour.

Source

pub fn badge_on_tabs<S: Into<String>>( self, column: impl Into<String>, tabs: impl IntoIterator<Item = S>, ) -> Self

Shows the badge of the column column only on the list’s tabs tabs, by key, as a Filament column’s visible() that reads the active tab. On another tab, or on a list with no tab active, the badge is not rendered: a badge column is left out of the table, heading and all, and a badge inside another cell is left out of the cell.

Source

pub fn is_empty(&self) -> bool

Whether no column is a badge.

Source

pub fn is_badge(&self, column: &str) -> bool

Whether the column column is a badge.

Source

pub fn color(&self, column: &str, state: &str) -> Option<BadgeColor>

The colour of the badge of the column column for state, or None when the column is not a badge.

Source

pub fn inside_of(&self, column: &str) -> Option<&str>

The column whose cell shows the badge of column, if it shows inside another cell.

Source

pub fn inside(&self, target: &str) -> Vec<&str>

The badge columns shown inside the cell of target, in key order.

Source

pub fn shows_on(&self, column: &str, tab: Option<&str>) -> bool

Whether the badge of column shows when the tab tab is active (None for none): a badge without badge_on_tabs shows on every tab. A column that is not a badge shows.

Trait Implementations§

Source§

impl Clone for ColumnBadges

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ColumnBadges

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ColumnBadges

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for ColumnBadges

§

impl !UnwindSafe for ColumnBadges

§

impl Forget for ColumnBadges

§

impl Freeze for ColumnBadges
where *const LeafNode<String, Badge> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Badge)>>: Freeze,

§

impl Move for ColumnBadges

§

impl Send for ColumnBadges
where NodeRef<Owned, String, Badge, LeafOrInternal>: Send, BoxRaw<(String, Badge)>: Send,

§

impl Sync for ColumnBadges
where NodeRef<Owned, String, Badge, LeafOrInternal>: Sync, BoxRaw<(String, Badge)>: Sync,

§

impl Unpin for ColumnBadges
where *const LeafNode<String, Badge> is !null: Unpin, Box<(String, Badge)>: Unpin,

§

impl UnsafeUnpin for ColumnBadges
where *const LeafNode<String, Badge> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, Badge)>>: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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