Class: EasyAdmin::Fields::BaseComponent
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- EasyAdmin::Fields::BaseComponent
- Includes:
- ActionView::Helpers::DateHelper, ActionView::Helpers::NumberHelper, ActionView::Helpers::TextHelper, ActionView::Helpers::UrlHelper, DashboardsHelper, EasyAdmin::FieldsHelper
- Defined in:
- app/components/easy_admin/fields/base_component.rb
Direct Known Subclasses
Form::BooleanComponent, Form::DateComponent, Form::DatetimeComponent, Form::EmailComponent, Form::FileComponent, Form::HasManyComponent, Form::JsonComponent, Form::NumberComponent, Form::SelectComponent, Form::TextComponent, Form::TextareaComponent, Index::BelongsToComponent, Index::BooleanComponent, Index::DateComponent, Index::DatetimeComponent, Index::EmailComponent, Index::JsonComponent, Index::NumberComponent, Index::SelectComponent, Index::TextComponent, Show::BelongsToComponent, Show::BooleanComponent, Show::DateComponent, Show::DatetimeComponent, Show::EmailComponent, Show::FileComponent, Show::HasManyComponent, Show::JsonComponent, Show::NumberComponent, Show::SelectComponent, Show::TextComponent, Show::TextareaComponent
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#easy_admin_url_helpers ⇒ Object
Direct access to EasyAdmin URL helpers.
-
#helpers ⇒ Object
Add method to access all Rails helpers if needed.
-
#initialize(field:, value: nil, record: nil, form: nil, **options) ⇒ BaseComponent
constructor
A new instance of BaseComponent.
-
#rails_url_helpers ⇒ Object
Direct access to Rails URL helpers.
- #view_template ⇒ Object
Methods included from EasyAdmin::FieldsHelper
#field_component, #render_field
Methods included from DashboardsHelper
#delta_badge_classes, #metric_value_classes, #render_card, #sparkline_color, #sparkline_points, #trend_direction, #trend_icon, #trend_indicator_classes
Constructor Details
#initialize(field:, value: nil, record: nil, form: nil, **options) ⇒ BaseComponent
Returns a new instance of BaseComponent.
38 39 40 41 42 43 44 |
# File 'app/components/easy_admin/fields/base_component.rb', line 38 def initialize(field:, value: nil, record: nil, form: nil, **) @field = field @value = value @record = record @form = form @options = end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
36 37 38 |
# File 'app/components/easy_admin/fields/base_component.rb', line 36 def field @field end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
36 37 38 |
# File 'app/components/easy_admin/fields/base_component.rb', line 36 def form @form end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
36 37 38 |
# File 'app/components/easy_admin/fields/base_component.rb', line 36 def record @record end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
36 37 38 |
# File 'app/components/easy_admin/fields/base_component.rb', line 36 def value @value end |
Instance Method Details
#easy_admin_url_helpers ⇒ Object
Direct access to EasyAdmin URL helpers
27 28 29 |
# File 'app/components/easy_admin/fields/base_component.rb', line 27 def easy_admin_url_helpers @easy_admin_url_helpers ||= EasyAdmin::Engine.routes.url_helpers end |
#helpers ⇒ Object
Add method to access all Rails helpers if needed
18 19 20 21 22 23 24 |
# File 'app/components/easy_admin/fields/base_component.rb', line 18 def helpers @helpers ||= Class.new do include ActionView::Helpers include Rails.application.routes.url_helpers include EasyAdmin::Engine.routes.url_helpers end.new end |
#rails_url_helpers ⇒ Object
Direct access to Rails URL helpers
32 33 34 |
# File 'app/components/easy_admin/fields/base_component.rb', line 32 def rails_url_helpers @rails_url_helpers ||= Rails.application.routes.url_helpers end |
#view_template ⇒ Object
46 47 48 |
# File 'app/components/easy_admin/fields/base_component.rb', line 46 def view_template # Override this in subclasses end |