Class: Avo::TableRowOptions
- Inherits:
-
Object
- Object
- Avo::TableRowOptions
- Defined in:
- lib/avo/table_row_options.rb
Overview
Resolves and merges user-provided <tr> options from ‘self.table_view = { row_options: … }` against the attributes Avo’s TableRowComponent sets by default.
Public API:
Avo::TableRowOptions.merge(
avo_attributes: { id:, class:, data: },
user_options: resource.class.table_view&.dig(:row_options),
record:, resource:, view:
)
See docs/brainstorms/2026-05-04-resource-table-view-row-options-requirements.md and docs/plans/2026-05-05-001-feat-table-view-row-options-plan.md.
Constant Summary collapse
- RESERVED_DATA_KEYS =
Data attribute keys Avo owns and reserves on <tr>. User attempts to set these (other than the token-list keys below) are dropped with a warning.
%i[ index component_name resource_name record_id resource_id visit_path reorder_target ].freeze
- TOKEN_LIST_DATA_KEYS =
Data attribute keys whose values are space-separated Stimulus token lists. User-provided tokens are concatenated with Avo’s, never replaced.
%i[controller action].freeze
- DENIED_KEYS =
Top-level HTML attributes users may not set on <tr>. Avo owns id; role/aria-selected break <table> semantics or Avo’s selection state; the rest are behavior-injection vectors.
%i[id role tabindex contenteditable draggable].freeze
- SUPPORTED_KEYS_HINT =
"class, data, style, title, aria-* (except aria-selected), " \ "and other passthrough HTML attributes".freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(avo_attributes:, user_options:, record:, resource:, view:) ⇒ TableRowOptions
constructor
A new instance of TableRowOptions.
- #merge ⇒ Object
Constructor Details
#initialize(avo_attributes:, user_options:, record:, resource:, view:) ⇒ TableRowOptions
Returns a new instance of TableRowOptions.
48 49 50 51 52 53 54 |
# File 'lib/avo/table_row_options.rb', line 48 def initialize(avo_attributes:, user_options:, record:, resource:, view:) @avo_attributes = avo_attributes @user_options = @record = record @resource = resource @view = view end |
Class Method Details
.merge(avo_attributes:, user_options:, record:, resource:, view:) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/avo/table_row_options.rb', line 38 def self.merge(avo_attributes:, user_options:, record:, resource:, view:) new( avo_attributes: avo_attributes, user_options: , record: record, resource: resource, view: view ).merge end |