Class: IronAdmin::Dashboards::RecentTableComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Dashboards::RecentTableComponent
- Includes:
- ApplicationHelper, FieldDisplayHelper, ThemeHelper
- Defined in:
- app/components/iron_admin/dashboards/recent_table_component.rb
Overview
Renders a table of recent records on the dashboard.
Constant Summary
Constants included from ApplicationHelper
ApplicationHelper::DISPLAY_METHODS, ApplicationHelper::FIELD_DISPLAY_METHODS, ApplicationHelper::INDEX_COMPACT_TYPES, ApplicationHelper::INDEX_TRUNCATION_LENGTH, ApplicationHelper::TRUNCATABLE_TYPES
Instance Method Summary collapse
-
#display_value(record, field) ⇒ String?
private
Formatted field value for display.
-
#fields ⇒ Array<IronAdmin::Field>
private
First 4 fields from the resource.
-
#initialize(resource_name:, records:) ⇒ RecentTableComponent
constructor
A new instance of RecentTableComponent.
-
#label ⇒ String
private
Humanized and pluralized resource label.
Methods included from ThemeHelper
#cp_badge_count, #cp_body_text, #cp_btn_danger, #cp_btn_filter_apply, #cp_btn_ghost, #cp_btn_primary, #cp_btn_primary_lg, #cp_btn_secondary, #cp_card, #cp_checkbox_class, #cp_file_input_class, #cp_filter_input_class, #cp_focus, #cp_heading, #cp_input_class, #cp_label_text, #cp_link, #cp_link_muted, #cp_muted_text, #cp_navbar_search_class, #cp_scope_active, #cp_scope_inactive, #cp_search_class, #cp_select_class, #cp_sidebar_bg, #cp_sidebar_group_label, #cp_sidebar_link, #cp_sidebar_title, #cp_table_border, #cp_table_header_bg, #cp_table_row_hover, #cp_textarea_class, #t
Methods included from ApplicationHelper
#association_resource_for, #display_field_value, #display_index_field_value, #display_record_label, #filter_options_for, #normalize_filter_options
Constructor Details
#initialize(resource_name:, records:) ⇒ RecentTableComponent
Returns a new instance of RecentTableComponent.
13 14 15 16 |
# File 'app/components/iron_admin/dashboards/recent_table_component.rb', line 13 def initialize(resource_name:, records:) @resource_name = resource_name @records = records end |
Instance Method Details
#display_value(record, field) ⇒ 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 Formatted field value for display.
35 36 37 |
# File 'app/components/iron_admin/dashboards/recent_table_component.rb', line 35 def display_value(record, field) display_index_field_value(record, field) end |
#fields ⇒ Array<IronAdmin::Field>
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 First 4 fields from the resource.
26 27 28 29 30 31 |
# File 'app/components/iron_admin/dashboards/recent_table_component.rb', line 26 def fields resource_class = IronAdmin::ResourceRegistry.find(@resource_name.to_s.pluralize) return [] unless resource_class resource_class.resolved_fields.first(4) end |
#label ⇒ 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 Humanized and pluralized resource label.
20 21 22 |
# File 'app/components/iron_admin/dashboards/recent_table_component.rb', line 20 def label @resource_name.to_s.humanize.pluralize end |