Class: Avo::EmptyStateComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/avo/empty_state_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(message: nil, resource_name: nil, related_name: nil, view_type: :table, add_background: false) ⇒ EmptyStateComponent

Returns a new instance of EmptyStateComponent.



4
5
6
7
8
9
10
# File 'app/components/avo/empty_state_component.rb', line 4

def initialize(message: nil, resource_name: nil, related_name: nil, view_type: :table, add_background: false)
  @message = message
  @view_type = view_type
  @related_name = related_name
  @resource_name = resource_name
  @add_background = add_background
end

Instance Method Details

#messageObject



12
13
14
15
16
17
# File 'app/components/avo/empty_state_component.rb', line 12

def message
  return @message if @message.present?

  translation_tag = @related_name.present? ? 'avo.no_related_item_found' : 'avo.no_item_found'
  helpers.t translation_tag, item: @resource_name
end

#view_type_svgObject



19
20
21
22
23
# File 'app/components/avo/empty_state_component.rb', line 19

def view_type_svg
  return "grid-empty-state" if @view_type.to_sym == :grid

  "table-empty-state"
end