Class: TinyAdmin::Views::Components::FieldValue
- Inherits:
-
BasicComponent
- Object
- Phlex::HTML
- BasicComponent
- TinyAdmin::Views::Components::FieldValue
- Defined in:
- lib/tiny_admin/views/components/field_value.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(field, value, record:) ⇒ FieldValue
constructor
A new instance of FieldValue.
- #view_template ⇒ Object
Methods inherited from BasicComponent
Constructor Details
#initialize(field, value, record:) ⇒ FieldValue
Returns a new instance of FieldValue.
9 10 11 12 13 |
# File 'lib/tiny_admin/views/components/field_value.rb', line 9 def initialize(field, value, record:) @field = field @value = value @record = record end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
7 8 9 |
# File 'lib/tiny_admin/views/components/field_value.rb', line 7 def field @field end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
7 8 9 |
# File 'lib/tiny_admin/views/components/field_value.rb', line 7 def record @record end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/tiny_admin/views/components/field_value.rb', line 7 def value @value end |
Instance Method Details
#view_template ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tiny_admin/views/components/field_value.rb', line 15 def view_template translated_value = field.translate_value(value) value_class = field.[:options]&.include?('value_class') ? "value-#{value}" : nil if field.[:link_to] a(href: TinyAdmin.route_for(field.[:link_to], reference: translated_value)) { span(class: value_class) { field.apply_call_option(record) || translated_value } } else span(class: value_class) { translated_value } end end |