Class: Plutonium::UI::Table::Components::SelectionDataCell

Inherits:
Phlexi::Table::HTML
  • Object
show all
Defined in:
lib/plutonium/ui/table/components/selection_column.rb

Overview

Data cell checkbox for individual row selection

Instance Method Summary collapse

Constructor Details

#initialize(value, allowed_actions) ⇒ SelectionDataCell

Returns a new instance of SelectionDataCell.



75
76
77
78
# File 'lib/plutonium/ui/table/components/selection_column.rb', line 75

def initialize(value, allowed_actions)
  @value = value
  @allowed_actions = allowed_actions
end

Instance Method Details

#view_templateObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/plutonium/ui/table/components/selection_column.rb', line 80

def view_template
  if @allowed_actions.empty?
    # Show X when no actions available for this record
    span(
      class: "inline-flex items-center justify-center size-4 text-[var(--pu-text-subtle)]",
      title: "No bulk actions available"
    ) { "" }
  else
    input(
      type: :checkbox,
      value: @value,
      class: themed(:selection_checkbox),
      data: {
        bulk_actions_target: "checkbox",
        action: "bulk-actions#toggle",
        allowed_actions: @allowed_actions.join(",")
      }
    )
  end
end