class Avo::Views::ResourceShowComponent

def back_path

def back_path
  if via_resource?
    helpers.resource_path(model: association_resource.model_class, resource: association_resource, resource_id: params[:via_resource_id])
  else
    helpers.resources_path(resource: @resource)
  end
end

def edit_path

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

def has_one_field?

def has_one_field?
  field.present? and field.instance_of? Avo::Fields::HasOneField
end

def initialize(resource: nil, reflection: nil, parent_resource: nil, parent_model: nil, resource_panel: nil, actions: [])

def initialize(resource: nil, reflection: nil, parent_resource: nil, parent_model: nil, resource_panel: nil, actions: [])
  @resource = resource
  @reflection = reflection
  @resource_panel = resource_panel
  @actions = actions
  @parent_model = parent_model
  @parent_resource = parent_resource
  @view = :show
end

def should_display_invalid_fields_errors?

In development and test environments we shoudl show the invalid field errors
def should_display_invalid_fields_errors?
  (Rails.env.development? || Rails.env.test?) && @resource.invalid_fields.present?
end

def title

def title
  if @reflection.present?
    return field.name if has_one_field?
    reflection_resource.name
  else
    @resource.default_panel_name
  end
end