Class: PhlexKit::DataTableRowCheckbox

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/phlex_kit/data_table/data_table_row_checkbox.rb

Overview

Per-row selection checkbox (a PhlexKit::Checkbox submitting ids[]). See data_table.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(value:, name: "ids[]", label: nil, **attrs) ⇒ DataTableRowCheckbox

Returns a new instance of DataTableRowCheckbox.



5
6
7
8
9
10
# File 'app/components/phlex_kit/data_table/data_table_row_checkbox.rb', line 5

def initialize(value:, name: "ids[]", label: nil, **attrs)
  @value = value
  @name = name
  @label = label
  @attrs = attrs
end

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/components/phlex_kit/data_table/data_table_row_checkbox.rb', line 12

def view_template
  render Checkbox.new(**mix({
    name: @name,
    value: @value,
    aria: { label: @label || "Select row #{@value}" },
    data: {
      phlex_kit__data_table_target: "rowCheckbox",
      action: "change->phlex-kit--data-table#toggleRow"
    }
  }, @attrs))
end