Class: IronAdmin::Resources::ActionsComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Resources::ActionsComponent
- Defined in:
- app/components/iron_admin/resources/actions_component.rb
Overview
Renders the actions dropdown for a single record.
Instance Attribute Summary collapse
-
#actions ⇒ Array<Hash>
readonly
Defined actions.
-
#record ⇒ ActiveRecord::Base
readonly
The record.
-
#resource_class ⇒ Class
readonly
The resource class.
Instance Method Summary collapse
-
#action_url(action) ⇒ String
private
URL for executing the action.
-
#initialize(actions:, record:, resource_class:) ⇒ ActionsComponent
constructor
A new instance of ActionsComponent.
-
#render? ⇒ Boolean
private
Whether to render the component.
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
Constructor Details
#initialize(actions:, record:, resource_class:) ⇒ ActionsComponent
Returns a new instance of ActionsComponent.
20 21 22 23 24 |
# File 'app/components/iron_admin/resources/actions_component.rb', line 20 def initialize(actions:, record:, resource_class:) @actions = actions @record = record @resource_class = resource_class end |
Instance Attribute Details
#actions ⇒ Array<Hash> (readonly)
Returns Defined actions.
9 10 11 |
# File 'app/components/iron_admin/resources/actions_component.rb', line 9 def actions @actions end |
#record ⇒ ActiveRecord::Base (readonly)
Returns The record.
12 13 14 |
# File 'app/components/iron_admin/resources/actions_component.rb', line 12 def record @record end |
#resource_class ⇒ Class (readonly)
Returns The resource class.
15 16 17 |
# File 'app/components/iron_admin/resources/actions_component.rb', line 15 def resource_class @resource_class end |
Instance Method Details
#action_url(action) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns URL for executing the action.
35 36 37 |
# File 'app/components/iron_admin/resources/actions_component.rb', line 35 def action_url(action) helpers.iron_admin.resource_action_path(resource_class.resource_name, record, action[:name]) end |
#render? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Whether to render the component.
41 42 43 |
# File 'app/components/iron_admin/resources/actions_component.rb', line 41 def render? actions.any? end |
#theme ⇒ IronAdmin::Configuration::Theme
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Theme configuration.
28 29 30 |
# File 'app/components/iron_admin/resources/actions_component.rb', line 28 def theme IronAdmin.configuration.theme end |