Class: Plutonium::UI::Grid::Card
- Inherits:
-
Component::Base
- Object
- Component::Base
- Plutonium::UI::Grid::Card
- Defined in:
- lib/plutonium/ui/grid/card.rb
Overview
Renders a single record as a card built from semantic slots (image / header / subheader / body / meta / footer) declared via ‘grid_fields` on the resource definition. Each slot is optional; `header` falls back to `record.to_label` when undeclared.
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#resource_definition ⇒ Object
readonly
Returns the value of attribute resource_definition.
-
#resource_fields ⇒ Object
readonly
Returns the value of attribute resource_fields.
Instance Method Summary collapse
-
#initialize(record, resource_definition:, resource_fields: nil) ⇒ Card
constructor
A new instance of Card.
- #view_template ⇒ Object
Methods included from Component::Behaviour
Methods included from Component::Tokens
Methods included from Component::Kit
#BuildActionButton, #BuildActionsDropdown, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?
Constructor Details
#initialize(record, resource_definition:, resource_fields: nil) ⇒ Card
Returns a new instance of Card.
13 14 15 16 17 |
# File 'lib/plutonium/ui/grid/card.rb', line 13 def initialize(record, resource_definition:, resource_fields: nil) @record = record @resource_definition = resource_definition @resource_fields = resource_fields end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
11 12 13 |
# File 'lib/plutonium/ui/grid/card.rb', line 11 def record @record end |
#resource_definition ⇒ Object (readonly)
Returns the value of attribute resource_definition.
11 12 13 |
# File 'lib/plutonium/ui/grid/card.rb', line 11 def resource_definition @resource_definition end |
#resource_fields ⇒ Object (readonly)
Returns the value of attribute resource_fields.
11 12 13 |
# File 'lib/plutonium/ui/grid/card.rb', line 11 def resource_fields @resource_fields end |
Instance Method Details
#view_template ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/plutonium/ui/grid/card.rb', line 19 def view_template article( class: card_class, data: {controller: "row-click", action: "click->row-click#click"} ) do render_show_link if can_show? render_actions_dropdown case resource_definition.defined_grid_layout when :media then render_media_layout else render_compact_layout end end end |