Class: EasyAdmin::Dashboards::BaseCardComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/easy_admin/dashboards/base_card_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#easy_admin_url_helpers, #helpers, #rails_url_helpers

Methods included from Permissions::Component

#current_user_can?, #current_user_has_role?, #if_can, #if_has_role, #permission_attrs, #permission_button, #permission_case, #permission_classes, #permission_field, #permission_link, #unless_can, #unless_has_role

Methods included from FieldsHelper

#field_component, #render_field

Methods included from EasyAdmin::DashboardsHelper

#delta_badge_classes, #metric_value_classes, #render_card, #sparkline_color, #sparkline_points, #trend_direction, #trend_icon, #trend_indicator_classes

Constructor Details

#initialize(card:, dashboard_class:, data: nil, request_params: nil) ⇒ BaseCardComponent

Returns a new instance of BaseCardComponent.



6
7
8
9
10
11
# File 'app/components/easy_admin/dashboards/base_card_component.rb', line 6

def initialize(card:, dashboard_class:, data: nil, request_params: nil)
  @card = card
  @dashboard_class = dashboard_class
  @data = data
  @request_params = request_params || ActionController::Parameters.new.permit!
end

Instance Attribute Details

#cardObject (readonly)

Returns the value of attribute card.



4
5
6
# File 'app/components/easy_admin/dashboards/base_card_component.rb', line 4

def card
  @card
end

#dashboard_classObject (readonly)

Returns the value of attribute dashboard_class.



4
5
6
# File 'app/components/easy_admin/dashboards/base_card_component.rb', line 4

def dashboard_class
  @dashboard_class
end

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'app/components/easy_admin/dashboards/base_card_component.rb', line 4

def data
  @data
end

#request_paramsObject (readonly)

Returns the value of attribute request_params.



4
5
6
# File 'app/components/easy_admin/dashboards/base_card_component.rb', line 4

def request_params
  @request_params
end

Instance Method Details

#view_templateObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/components/easy_admin/dashboards/base_card_component.rb', line 13

def view_template
  div(
    class: card_classes,
    role: "region",
    "aria-labelledby": card_title_id
  ) do
    render_card_header
    render_card_body
    render_card_footer if card[:footer]
  end
end