Class: PhlexKit::DataTableSelectAllCheckbox

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

Overview

Header checkbox selecting every DataTableRowCheckbox on the page (the controller sets indeterminate for partial selections). See data_table.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(label: "Select all", **attrs) ⇒ DataTableSelectAllCheckbox

Returns a new instance of DataTableSelectAllCheckbox.



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

def initialize(label: "Select all", **attrs)
  @label = label
  @attrs = attrs
end

Instance Method Details

#view_templateObject



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

def view_template
  base = {
    data: {
      phlex_kit__data_table_target: "selectAll",
      action: "change->phlex-kit--data-table#toggleAll"
    }
  }
  # label: kwarg (mirrors DataTableRowCheckbox); default only when the
  # caller didn't supply their own accessible name — `mix` fuses.
  base[:aria] = { label: @label } unless aria_labelled?
  render Checkbox.new(**mix(base, @attrs))
end