Class: RubyCms::Admin::BulkActionTable::BulkActionTableCheckboxHead

Inherits:
RubyCms::Admin::BaseComponent show all
Defined in:
app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_checkbox_head.rb

Overview

Checkbox header cell component Renders select-all checkbox in table header

Instance Method Summary collapse

Methods inherited from RubyCms::Admin::BaseComponent

#build_classes, #conditional_attributes, #controller, #form_authenticity_token, #helpers, #merge_data_attributes, #token_from_controller, #token_from_controller?, #token_from_helpers?

Constructor Details

#initialize(controller_name: "ruby-cms--bulk-action-table") ⇒ BulkActionTableCheckboxHead

Returns a new instance of BulkActionTableCheckboxHead.



11
12
13
14
# File 'app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_checkbox_head.rb', line 11

def initialize(controller_name: "ruby-cms--bulk-action-table")
  super()
  @controller_name = controller_name
end

Instance Method Details

#view_templateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_checkbox_head.rb', line 16

def view_template
  th(class: "w-10 px-4 py-3") do
    div(class: "inline-flex items-center justify-center") do
      input(
        type: "checkbox",
        role: "checkbox",
        class: "size-4 rounded border-border/80 text-primary focus:ring-primary/30 focus:ring-offset-0 cursor-pointer transition-colors",
        data: {
          "#{@controller_name}-target": "selectAllCheckbox",
          action: "change->#{@controller_name}#toggleSelectAll"
        },
        aria_label: "Select all"
      )
    end
  end
end