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.



66
67
68
69
# File 'lib/plutonium/ui/table/components/selection_column.rb', line 66

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

Instance Method Details

#view_templateObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/plutonium/ui/table/components/selection_column.rb', line 71

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