Class: Avo::AlertComponent

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

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods included from ApplicationHelper

#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #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, #rtl?, #text_direction, #ui, #wrap_in_modal

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table

Methods inherited from BaseComponent

#component_name, #hotkey_badge

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#iconObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/components/avo/alert_component.rb', line 11

def icon
  case variant
  when :danger
    "tabler/outline/circle-x"
  when :warning
    "tabler/outline/exclamation-circle"
  when :info
    "tabler/outline/info-circle"
  when :success
    "tabler/outline/circle-check"
  else
    "tabler/outline/circle"
  end
end

#is_empty?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/components/avo/alert_component.rb', line 53

def is_empty?
  @message.nil?
end

#is_error?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/components/avo/alert_component.rb', line 37

def is_error?
  normalized_type == :error || normalized_type == :alert
end

#is_info?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/components/avo/alert_component.rb', line 45

def is_info?
  normalized_type == :notice || normalized_type == :info
end

#is_success?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/components/avo/alert_component.rb', line 41

def is_success?
  normalized_type == :success
end

#is_warning?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'app/components/avo/alert_component.rb', line 49

def is_warning?
  normalized_type == :warning
end

#variantObject



26
27
28
29
30
31
32
33
34
35
# File 'app/components/avo/alert_component.rb', line 26

def variant
  @variant ||= begin
    return :danger if is_error?
    return :success if is_success?
    return :warning if is_warning?
    return :info if is_info?

    :default
  end
end