Class: RubyCms::Admin::BulkActionTable::BulkActionTableCheckboxCell

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

Overview

Checkbox cell component Renders checkbox in table row for bulk selection

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(item_id:, controller_name: "ruby-cms--bulk-action-table") ⇒ BulkActionTableCheckboxCell

Returns a new instance of BulkActionTableCheckboxCell.



12
13
14
15
16
17
18
19
# File 'app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_checkbox_cell.rb', line 12

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

Instance Method Details

#view_templateObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/components/ruby_cms/admin/bulk_action_table/bulk_action_table_checkbox_cell.rb', line 21

def view_template
  td(class: "w-10 px-4 py-3",
     data: { action: "click->#{@controller_name}#stopPropagation" }) do
    div(class: "inline-flex items-center justify-center") do
      input(
        type: "checkbox",
        role: "checkbox",
        value: @item_id,
        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": "itemCheckbox",
          item_id: @item_id,
          action: "change->#{@controller_name}#updateSelection"
        },
        aria_label: "Select row"
      )
    end
  end
end