Class: Avo::Fields::HasBaseField
- Defined in:
- lib/avo/fields/has_base_field.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#display ⇒ Object
Returns the value of attribute display.
Attributes inherited from BaseField
#action, #as_avatar, #as_description, #as_label, #block, #computable, #computed, #computed_value, #default, #format_using, #help, #id, #model, #null_values, #nullable, #panel_name, #readonly, #required, #sortable, #updatable, #user, #view, #visible
Attributes included from FieldExtensions::VisibleInDifferentViews
#show_on_edit, #show_on_index, #show_on_new, #show_on_show
Instance Method Summary collapse
- #frame_url ⇒ Object
-
#initialize(id, **args, &block) ⇒ HasBaseField
constructor
A new instance of HasBaseField.
- #resource ⇒ Object
- #target_resource ⇒ Object
- #turbo_frame ⇒ Object
Methods inherited from BaseField
#component_for_view, #custom?, #database_id, #fill_field, #has_own_panel?, #hydrate, #model_errors, #name, #placeholder, #resolve_attribute, #to_permitted_param, #translation_key, #type, #value, #view_component_name, #visible?
Methods included from FieldExtensions::HasFieldName
Methods included from FieldExtensions::VisibleInDifferentViews
#except_on, #hide_on, #only_on, #show_on
Constructor Details
#initialize(id, **args, &block) ⇒ HasBaseField
Returns a new instance of HasBaseField.
6 7 8 9 10 |
# File 'lib/avo/fields/has_base_field.rb', line 6 def initialize(id, **args, &block) super(id, **args, &block) @display = args[:display].present? ? args[:display] : :show end |
Instance Attribute Details
#display ⇒ Object
Returns the value of attribute display.
4 5 6 |
# File 'lib/avo/fields/has_base_field.rb', line 4 def display @display end |
Instance Method Details
#frame_url ⇒ Object
20 21 22 |
# File 'lib/avo/fields/has_base_field.rb', line 20 def frame_url "#{@resource.record_path}/#{id}?turbo_frame=#{turbo_frame}" end |
#resource ⇒ Object
12 13 14 |
# File 'lib/avo/fields/has_base_field.rb', line 12 def resource Avo::App.get_resource_by_model_name @model.class end |
#target_resource ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/avo/fields/has_base_field.rb', line 24 def target_resource if @model._reflections[id.to_s].klass.present? Avo::App.get_resource_by_model_name @model._reflections[id.to_s].klass.to_s elsif @model._reflections[id.to_s].[:class_name].present? Avo::App.get_resource_by_model_name @model._reflections[id.to_s].[:class_name] else Avo::App.get_resource_by_name id.to_s end end |
#turbo_frame ⇒ Object
16 17 18 |
# File 'lib/avo/fields/has_base_field.rb', line 16 def turbo_frame "#{self.class.name.demodulize.to_s.underscore}_#{display}_#{id}" end |