Class: SdrViewComponents::Tables::RowComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Tables::RowComponent
- Defined in:
- app/components/sdr_view_components/tables/row_component.rb
Overview
Component for rendering a table row.
Instance Attribute Summary collapse
-
#first_value ⇒ Object
readonly
Returns the value of attribute first_value.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#row_options ⇒ Object
readonly
Returns the value of attribute row_options.
-
#tooltip ⇒ Object
readonly
Returns the value of attribute tooltip.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #empty_cell? ⇒ Boolean
-
#initialize(label: nil, first_value: nil, values: [], value: nil, tooltip: nil, **row_options) ⇒ RowComponent
constructor
rubocop:disable Metrics/ParameterLists.
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(label: nil, first_value: nil, values: [], value: nil, tooltip: nil, **row_options) ⇒ RowComponent
rubocop:disable Metrics/ParameterLists
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/sdr_view_components/tables/row_component.rb', line 10 def initialize(label: nil, first_value: nil, values: [], value: nil, tooltip: nil, **) # rubocop:disable Metrics/ParameterLists # Provide either label or first_value but not both; these are rendered in the first column # label renders with <th> (bold), first_value is a normal <td> @label = label @first_value = first_value # Provide either value, values or cells (e.g. for content files). @values = Array(value).presence || values @tooltip = tooltip @row_options = raise ArgumentError if label.present? && first_value.present? super() end |
Instance Attribute Details
#first_value ⇒ Object (readonly)
Returns the value of attribute first_value.
25 26 27 |
# File 'app/components/sdr_view_components/tables/row_component.rb', line 25 def first_value @first_value end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
25 26 27 |
# File 'app/components/sdr_view_components/tables/row_component.rb', line 25 def label @label end |
#row_options ⇒ Object (readonly)
Returns the value of attribute row_options.
25 26 27 |
# File 'app/components/sdr_view_components/tables/row_component.rb', line 25 def @row_options end |
#tooltip ⇒ Object (readonly)
Returns the value of attribute tooltip.
25 26 27 |
# File 'app/components/sdr_view_components/tables/row_component.rb', line 25 def tooltip @tooltip end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
25 26 27 |
# File 'app/components/sdr_view_components/tables/row_component.rb', line 25 def values @values end |
Instance Method Details
#empty_cell? ⇒ Boolean
27 28 29 |
# File 'app/components/sdr_view_components/tables/row_component.rb', line 27 def empty_cell? label.present? && values.empty? && !cells? end |