Class: EasyAdmin::Resources::TableRowComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/easy_admin/resources/table_row_component.rb

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 DashboardsHelper

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

Constructor Details

#initialize(record:, resource_class:) ⇒ TableRowComponent

Returns a new instance of TableRowComponent.



4
5
6
7
# File 'app/components/easy_admin/resources/table_row_component.rb', line 4

def initialize(record:, resource_class:)
  @record = record
  @resource_class = resource_class
end

Instance Method Details

#view_templateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/components/easy_admin/resources/table_row_component.rb', line 9

def view_template
  tr(
    id: helpers.dom_id(@record),
    class: "group hover:bg-gray-100 transition-colors duration-150",
    data: {
      controller: "context-menu",
      action: "contextmenu->context-menu#showMenu",
      context_menu_record_id_value: @record.id,
      context_menu_resource_name_value: @resource_class.route_key
    }
  ) do
    # Checkbox cell for batch actions
    if @resource_class.batch_actions_enabled
      td(class: "relative w-16 sm:w-12 px-3 sm:px-6 py-4") do
        div(class: "absolute left-2 sm:left-4 top-1/2 -mt-3") do
          render_ios_checkbox(
            target: "checkbox",
            action: "change->batch-selection#toggleItem",
            value: @record.id
          )
        end
      end
    end
    
    @resource_class.index_fields.each_with_index do |field_config, index|
      render EasyAdmin::Resources::TableCellComponent.new(
        record: @record,
        field_config: field_config,
        resource_class: @resource_class,
        mobile_hide: index > 2
      )
    end
    
    render_actions_cell
  end
end