Class: IronAdmin::Resources::BulkActionsComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/iron_admin/resources/bulk_actions_component.rb

Overview

Renders the bulk actions dropdown for selected records.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actions:, resource_class:) ⇒ BulkActionsComponent

Returns a new instance of BulkActionsComponent.

Parameters:

  • actions (Array<Hash>)

    Bulk actions

  • resource_class (Class)

    The resource



15
16
17
18
# File 'app/components/iron_admin/resources/bulk_actions_component.rb', line 15

def initialize(actions:, resource_class:)
  @actions = actions
  @resource_class = resource_class
end

Instance Attribute Details

#actionsArray<Hash> (readonly)

Returns Defined bulk actions.

Returns:

  • (Array<Hash>)

    Defined bulk actions



8
9
10
# File 'app/components/iron_admin/resources/bulk_actions_component.rb', line 8

def actions
  @actions
end

#resource_classClass (readonly)

Returns The resource class.

Returns:

  • (Class)

    The resource class



11
12
13
# File 'app/components/iron_admin/resources/bulk_actions_component.rb', line 11

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 bulk action.

Parameters:

  • action (Hash)

    Bulk action configuration

Returns:

  • (String)

    URL for executing the bulk action



29
30
31
# File 'app/components/iron_admin/resources/bulk_actions_component.rb', line 29

def action_url(action)
  helpers.iron_admin.resource_bulk_action_path(resource_class.resource_name, 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.

Returns:

  • (Boolean)

    Whether to render the component



35
36
37
# File 'app/components/iron_admin/resources/bulk_actions_component.rb', line 35

def render?
  actions.any?
end

#themeIronAdmin::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.

Returns:



22
23
24
# File 'app/components/iron_admin/resources/bulk_actions_component.rb', line 22

def theme
  IronAdmin.configuration.theme
end