Class: IronAdmin::Resources::ShowFieldComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Resources::ShowFieldComponent
- Defined in:
- app/components/iron_admin/resources/show_field_component.rb
Overview
Renders a single field value on the show page.
Instance Attribute Summary collapse
-
#current_user ⇒ Object?
readonly
Current user.
-
#field ⇒ IronAdmin::Field
readonly
The field configuration.
-
#record ⇒ ActiveRecord::Base
readonly
The record.
Instance Method Summary collapse
-
#initialize(field:, record:, current_user: nil) ⇒ ShowFieldComponent
constructor
A new instance of ShowFieldComponent.
-
#label ⇒ String
private
Humanized field label.
- #render? ⇒ Boolean
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
-
#value ⇒ String?
private
Formatted field value.
Constructor Details
#initialize(field:, record:, current_user: nil) ⇒ ShowFieldComponent
Returns a new instance of ShowFieldComponent.
19 20 21 22 23 |
# File 'app/components/iron_admin/resources/show_field_component.rb', line 19 def initialize(field:, record:, current_user: nil) @field = field @record = record @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object? (readonly)
Returns Current user.
14 15 16 |
# File 'app/components/iron_admin/resources/show_field_component.rb', line 14 def current_user @current_user end |
#field ⇒ IronAdmin::Field (readonly)
Returns The field configuration.
8 9 10 |
# File 'app/components/iron_admin/resources/show_field_component.rb', line 8 def field @field end |
#record ⇒ ActiveRecord::Base (readonly)
Returns The record.
11 12 13 |
# File 'app/components/iron_admin/resources/show_field_component.rb', line 11 def record @record end |
Instance Method Details
#label ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Humanized field label.
39 40 41 |
# File 'app/components/iron_admin/resources/show_field_component.rb', line 39 def label field.name.to_s.humanize end |
#render? ⇒ Boolean
25 26 27 28 29 |
# File 'app/components/iron_admin/resources/show_field_component.rb', line 25 def render? return false if field.type == :hidden field.visible?(@current_user) end |
#theme ⇒ IronAdmin::Configuration::Theme
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Theme configuration.
33 34 35 |
# File 'app/components/iron_admin/resources/show_field_component.rb', line 33 def theme IronAdmin.configuration.theme end |
#value ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Formatted field value.
45 46 47 |
# File 'app/components/iron_admin/resources/show_field_component.rb', line 45 def value helpers.display_field_value(record, field) end |