Class: Jav::Fields::ShowComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Jav::Fields::ShowComponent
- Includes:
- ResourcesHelper
- Defined in:
- app/components/jav/fields/show_component.rb
Direct Known Subclasses
AreaField::ShowComponent, BadgeField::ShowComponent, BelongsToField::ShowComponent, BooleanField::ShowComponent, BooleanGroupField::ShowComponent, CodeField::ShowComponent, CountryField::ShowComponent, DateField::ShowComponent, DateTimeField::ShowComponent, ExternalImageField::ShowComponent, FileField::ShowComponent, FilesField::ShowComponent, GravatarField::ShowComponent, HasManyField::ShowComponent, HasOneField::ShowComponent, HeadingField::ShowComponent, IdField::ShowComponent, KeyValueField::ShowComponent, LocationField::ShowComponent, MarkdownField::ShowComponent, NumberField::ShowComponent, ProgressBarField::ShowComponent, Jav::Fields::SelectField::ShowComponent, Jav::Fields::StatusField::ShowComponent, TagsField::ShowComponent, TextField::ShowComponent, TextareaField::ShowComponent, TimeField::ShowComponent, TrixField::ShowComponent
Instance Attribute Summary collapse
-
#compact ⇒ Object
readonly
Returns the value of attribute compact.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#stacked ⇒ Object
readonly
Returns the value of attribute stacked.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
- #disabled? ⇒ Boolean
- #field_wrapper_args ⇒ Object
-
#initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: nil) ⇒ ShowComponent
constructor
A new instance of ShowComponent.
- #stimulus_attributes ⇒ Object
- #wrapper_data ⇒ Object
Methods included from ResourcesHelper
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table
Constructor Details
#initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: nil) ⇒ ShowComponent
Returns a new instance of ShowComponent.
8 9 10 11 12 13 14 15 16 |
# File 'app/components/jav/fields/show_component.rb', line 8 def initialize(field: nil, resource: nil, index: 0, form: nil, compact: false, stacked: nil) super @compact = compact @field = field @index = index @resource = resource @stacked = stacked @view = :show end |
Instance Attribute Details
#compact ⇒ Object (readonly)
Returns the value of attribute compact.
6 7 8 |
# File 'app/components/jav/fields/show_component.rb', line 6 def compact @compact end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
6 7 8 |
# File 'app/components/jav/fields/show_component.rb', line 6 def field @field end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'app/components/jav/fields/show_component.rb', line 6 def index @index end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
6 7 8 |
# File 'app/components/jav/fields/show_component.rb', line 6 def resource @resource end |
#stacked ⇒ Object (readonly)
Returns the value of attribute stacked.
6 7 8 |
# File 'app/components/jav/fields/show_component.rb', line 6 def stacked @stacked end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
6 7 8 |
# File 'app/components/jav/fields/show_component.rb', line 6 def view @view end |
Instance Method Details
#disabled? ⇒ Boolean
50 51 52 |
# File 'app/components/jav/fields/show_component.rb', line 50 def disabled? field.is_readonly? || field.is_disabled? end |
#field_wrapper_args ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'app/components/jav/fields/show_component.rb', line 39 def field_wrapper_args { compact: compact, field: field, index: index, resource: resource, stacked: stacked, view: view } end |
#stimulus_attributes ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/jav/fields/show_component.rb', line 24 def stimulus_attributes attributes = {} if @resource.present? @resource.get_stimulus_controllers.split.each do |controller| attributes["#{controller}-target"] = "#{@field.id.to_s.underscore}_#{@field.type.to_s.underscore}_wrapper".camelize(:lower) end end wrapper_data_attributes = @field.get_html :data, view: view, element: :wrapper attributes.merge! wrapper_data_attributes if wrapper_data_attributes.present? attributes end |
#wrapper_data ⇒ Object
18 19 20 21 22 |
# File 'app/components/jav/fields/show_component.rb', line 18 def wrapper_data { **stimulus_attributes } end |