Class: Avo::Views::ResourceShowComponent
- Inherits:
-
ResourceComponent
- Object
- ResourceComponent
- Avo::Views::ResourceShowComponent
- Includes:
- ApplicationHelper, ResourcesHelper
- Defined in:
- app/components/avo/views/resource_show_component.rb
Instance Attribute Summary collapse
-
#fields_by_panel ⇒ Object
readonly
Returns the value of attribute fields_by_panel.
-
#has_as_belongs_to_many_panels ⇒ Object
readonly
Returns the value of attribute has_as_belongs_to_many_panels.
-
#has_many_panels ⇒ Object
readonly
Returns the value of attribute has_many_panels.
-
#has_one_panels ⇒ Object
readonly
Returns the value of attribute has_one_panels.
Instance Method Summary collapse
- #back_path ⇒ Object
- #can_detach? ⇒ Boolean
- #can_see_the_destroy_button? ⇒ Boolean
- #can_see_the_edit_button? ⇒ Boolean
- #destroy_path ⇒ Object
- #detach_path ⇒ Object
- #edit_path ⇒ Object
-
#initialize(resource: nil, reflection: nil, parent_model: nil) ⇒ ResourceShowComponent
constructor
A new instance of ResourceShowComponent.
Methods included from ApplicationHelper
#a_button, #a_link, #button_classes, #empty_state, #get_model_class, #input_classes, #render_license_warning, #render_license_warnings, #svg, #turbo_frame_wrap
Methods included from ResourcesHelper
#edit_field_wrapper, #filter_wrapper, #index_field_wrapper, #item_select_all_input, #item_selector_init, #item_selector_input, #resource_grid, #resource_table, #show_field_wrapper
Constructor Details
#initialize(resource: nil, reflection: nil, parent_model: nil) ⇒ ResourceShowComponent
Returns a new instance of ResourceShowComponent.
9 10 11 12 13 14 |
# File 'app/components/avo/views/resource_show_component.rb', line 9 def initialize(resource: nil, reflection: nil, parent_model: nil) @resource = resource @reflection = reflection split_panel_fields end |
Instance Attribute Details
#fields_by_panel ⇒ Object (readonly)
Returns the value of attribute fields_by_panel.
7 8 9 |
# File 'app/components/avo/views/resource_show_component.rb', line 7 def fields_by_panel @fields_by_panel end |
#has_as_belongs_to_many_panels ⇒ Object (readonly)
Returns the value of attribute has_as_belongs_to_many_panels.
7 8 9 |
# File 'app/components/avo/views/resource_show_component.rb', line 7 def has_as_belongs_to_many_panels @has_as_belongs_to_many_panels end |
#has_many_panels ⇒ Object (readonly)
Returns the value of attribute has_many_panels.
7 8 9 |
# File 'app/components/avo/views/resource_show_component.rb', line 7 def has_many_panels @has_many_panels end |
#has_one_panels ⇒ Object (readonly)
Returns the value of attribute has_one_panels.
7 8 9 |
# File 'app/components/avo/views/resource_show_component.rb', line 7 def has_one_panels @has_one_panels end |
Instance Method Details
#back_path ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/components/avo/views/resource_show_component.rb', line 16 def back_path if via_resource? helpers.resource_path(model: params[:via_resource_class].safe_constantize, resource: relation_resource, resource_id: params[:via_resource_id]) else helpers.resources_path(resource: @resource) end end |
#can_detach? ⇒ Boolean
45 46 47 |
# File 'app/components/avo/views/resource_show_component.rb', line 45 def can_detach? ("detach") end |
#can_see_the_destroy_button? ⇒ Boolean
53 54 55 |
# File 'app/components/avo/views/resource_show_component.rb', line 53 def @resource..(:destroy, raise_exception: false) end |
#can_see_the_edit_button? ⇒ Boolean
49 50 51 |
# File 'app/components/avo/views/resource_show_component.rb', line 49 def @resource..(:edit, raise_exception: false) end |
#destroy_path ⇒ Object
41 42 43 |
# File 'app/components/avo/views/resource_show_component.rb', line 41 def destroy_path helpers.resource_path(model: @resource.model, resource: @resource) end |
#detach_path ⇒ Object
37 38 39 |
# File 'app/components/avo/views/resource_show_component.rb', line 37 def detach_path helpers.resource_detach_path(params[:resource_name], params[:id], @reflection.name.to_s, @resource.model.id) end |
#edit_path ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/avo/views/resource_show_component.rb', line 24 def edit_path args = {} if via_resource? args = { via_resource_class: params[:via_resource_class], via_resource_id: params[:via_resource_id] } end helpers.edit_resource_path(model: @resource.model, resource: @resource, **args) end |