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
-
#card_fields ⇒ Object
readonly
Returns the value of attribute card_fields.
-
#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_fields: nil, show_turbo_frame: 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, #BuildAvatar, #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_fields: nil, show_turbo_frame: nil) ⇒ Card
Returns a new instance of Card.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/plutonium/ui/grid/card.rb', line 13 def initialize(record, resource_definition:, resource_fields: nil, card_fields: nil, show_turbo_frame: nil) @record = record @resource_definition = resource_definition @resource_fields = resource_fields @card_fields = card_fields # Overrides the show link's turbo-frame target. Defaults to the show # action's own frame (nil → normal navigation). The kanban board sets # "_top" so a card click escapes its column's lazy turbo-frame instead # of loading the show page inside the column. @show_turbo_frame = show_turbo_frame end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit
Instance Attribute Details
#card_fields ⇒ Object (readonly)
Returns the value of attribute card_fields.
11 12 13 |
# File 'lib/plutonium/ui/grid/card.rb', line 11 def card_fields @card_fields end |
#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
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/plutonium/ui/grid/card.rb', line 25 def view_template article( class: card_class, data: {controller: "row-click", action: "click->row-click#click auxclick->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 |