Skip to content
How-to guides and worked examplesSee the guides →

Discreet Information API

Per-option reference for discreet_information. For task-oriented documentation and worked examples, see the Discreet Information guide.

The option is set on the resource class and accepts a single item or an array of items. Each item is a preconfigured symbol or a Hash of the custom item options below:

ruby
class Avo::Resources::Post < Avo::BaseResource
  self.discreet_information = [
    :timestamps,
    {
      # custom item options listed below
    }
  ]
end
  • Type: Symbol, Hash, or Array of Symbols/Hashes
  • Default: nil — nothing is rendered

Preconfigured items

:id

Displays the record's ID as a key-value pair labeled ID.

ruby
self.discreet_information = :id

:timestamps

Displays an icon next to the record title. Hovering over it reveals the record's created_at and updated_at timestamps in a tooltip.

ruby
self.discreet_information = :timestamps

If the record has neither a created_at nor an updated_at value, the item is omitted.

:created_at

Displays the record's created_at timestamp as a key-value pair. Omitted when the record has no created_at value.

ruby
self.discreet_information = :created_at

:updated_at

Displays the record's updated_at timestamp as a key-value pair. Omitted when the record has no updated_at value.

ruby
self.discreet_information = :updated_at

Custom item options

Every option below accepts a static value or a block. Blocks are evaluated in an ExecutionContext with access to record, resource, view, and the rest of the common objects.

as

The type of representation for the item.

ruby
self.discreet_information = {
  as: :badge,
  text: "Draft"
}
ValueBehavior
:textPlain text, with an optional leading icon (default)
:iconAn icon only; pair with icon and a title tooltip
:badgeA badge containing text, with an optional leading icon
:key_valueA key/value pair
  • Type: Symbol
  • Default: :text

text

The text displayed by :text and :badge items.

ruby
self.discreet_information = {
  as: :badge,
  text: -> { record.published_at ? "Published" : "Draft" }
}
  • Type: String or Proc
  • Default: nil

title

The body of the tooltip shown when hovering over the item.

ruby
self.discreet_information = {
  title: -> { "Product is #{record.published_at ? "published" : "draft"}" }
}

You may return HTML, but don't forget to sanitize the output:

ruby
self.discreet_information = {
  title: -> { sanitize("Product is <strong>#{record.published_at ? "published" : "draft"}</strong>", tags: %w[strong]) }
}
  • Type: String or Proc
  • Default: nil

icon

The icon displayed with the item.

ruby
self.discreet_information = {
  icon: "tabler/outline/bulb"
}
  • Type: String or Proc
  • Default: nil
  • Values: any Tabler, Heroicon, or Avo icon, e.g. tabler/outline/cube, heroicons/outline/cube, avo/cube — see the Icons documentation

url

Turns the item into a link pointing at this URL.

ruby
self.discreet_information = {
  icon: "tabler/outline/external-link",
  url: -> { main_app.post_path record }
}
  • Type: String or Proc
  • Default: nil — the item is not a link

target

The target attribute of the link. Only relevant together with url.

ruby
self.discreet_information = {
  url: -> { main_app.post_path record },
  target: :_blank
}
  • Type: Symbol or String
  • Default: nil
  • Values: :_blank, :_self, :_parent, :_top — forwarded verbatim to the link

data

Data attributes attached to the item's wrapper element — the link when url is set, a plain element otherwise.

ruby
self.discreet_information = {
  url: -> { main_app.post_path record },
  data: {turbo_frame: :some_frame}
}
  • Type: Hash or Proc
  • Default: nil

key

The key displayed by a :key_value item.

ruby
self.discreet_information = {
  as: :key_value,
  key: "Status:",
  value: -> { record.published_at ? "published" : "draft" }
}
  • Type: String or Proc
  • Default: nil

value

The value displayed by a :key_value item.

ruby
self.discreet_information = {
  as: :key_value,
  key: "Status:",
  value: -> { record.published_at ? "published" : "draft" }
}
  • Type: String or Proc
  • Default: nil

visible

Whether the item is rendered.

ruby
self.discreet_information = {
  as: :badge,
  text: "Draft",
  visible: -> { record.published_at.nil? }
}
  • Type: Boolean or Proc
  • Default: true — omitting the option renders the item