Class: Avo::Views::ResourceShowComponent
- Inherits:
-
ResourceComponent
- Object
- ResourceComponent
- Avo::Views::ResourceShowComponent
- Includes:
- ApplicationHelper
- Defined in:
- app/components/avo/views/resource_show_component.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#display_breadcrumbs ⇒ Object
readonly
Returns the value of attribute display_breadcrumbs.
Instance Method Summary collapse
- #back_path ⇒ Object
- #controls ⇒ Object
- #edit_path ⇒ Object
-
#initialize(resource: nil, reflection: nil, parent_resource: nil, parent_record: nil, resource_panel: nil, actions: []) ⇒ ResourceShowComponent
constructor
A new instance of ResourceShowComponent.
- #title ⇒ Object
- #view_for(field) ⇒ Object
Methods included from ApplicationHelper
#a_button, #a_link, #button_classes, #card_classes, #chart_color, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes
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(resource: nil, reflection: nil, parent_resource: nil, parent_record: nil, resource_panel: nil, actions: []) ⇒ ResourceShowComponent
Returns a new instance of ResourceShowComponent.
8 9 10 11 12 13 14 15 16 17 |
# File 'app/components/avo/views/resource_show_component.rb', line 8 def initialize(resource: nil, reflection: nil, parent_resource: nil, parent_record: nil, resource_panel: nil, actions: []) @resource = resource @reflection = reflection @resource_panel = resource_panel @actions = actions @parent_record = parent_record @parent_resource = parent_resource @view = Avo::ViewInquirer.new("show") @display_breadcrumbs = reflection.blank? end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
6 7 8 |
# File 'app/components/avo/views/resource_show_component.rb', line 6 def actions @actions end |
#display_breadcrumbs ⇒ Object (readonly)
Returns the value of attribute display_breadcrumbs.
6 7 8 |
# File 'app/components/avo/views/resource_show_component.rb', line 6 def @display_breadcrumbs end |
Instance Method Details
#back_path ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/components/avo/views/resource_show_component.rb', line 29 def back_path if via_resource? helpers.resource_path(record: association_resource.model_class, resource: association_resource, resource_id: params[:via_record_id]) else helpers.resources_path(resource: @resource, **keep_referrer_params) end end |
#controls ⇒ Object
55 56 57 |
# File 'app/components/avo/views/resource_show_component.rb', line 55 def controls @resource.render_show_controls end |
#edit_path ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/components/avo/views/resource_show_component.rb', line 37 def edit_path args = if via_resource? { via_resource_class: params[:via_resource_class], via_record_id: params[:via_record_id] } elsif @parent_resource.present? { via_resource_class: @parent_resource.class, via_record_id: @parent_record.id } else {} end helpers.edit_resource_path(record: @resource.record, resource: @resource, **args) end |
#title ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/components/avo/views/resource_show_component.rb', line 19 def title if @reflection.present? return field.name if has_one_field? reflection_resource.name else @resource.default_panel_name end end |
#view_for(field) ⇒ Object
59 60 61 |
# File 'app/components/avo/views/resource_show_component.rb', line 59 def view_for(field) @view end |