Class: Avo::ActionsComponent

Inherits:
BaseComponent show all
Includes:
ApplicationHelper
Defined in:
app/components/avo/actions_component.rb

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods included from ApplicationHelper

#a_button, #a_link, #button_classes, #card_classes, #chart_color, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #resource_grid, #resource_show_path, #resource_table

Methods inherited from BaseComponent

#has_with_trial

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#after_initializeObject



35
36
37
38
39
40
41
42
43
44
# File 'app/components/avo/actions_component.rb', line 35

def after_initialize
  filter_actions unless @custom_list

  # Hydrate each action action with the record when rendering a list on row controls
  if @as_row_control
    @actions.each do |action|
      action.hydrate(resource: @resource, record: @resource.record) if action.respond_to?(:hydrate)
    end
  end
end

#filter_actionsObject



50
51
52
53
54
55
56
57
58
59
60
# File 'app/components/avo/actions_component.rb', line 50

def filter_actions
  @actions = @actions.dup

  if @exclude.any?
    @actions.reject! { |action| @exclude.include?(action.class) }
  end

  if @include.any?
    @actions.select! { |action| @include.include?(action.class) }
  end
end

#render?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/components/avo/actions_component.rb', line 46

def render?
  @actions.present?
end