class Avo::Fields::HasBaseField

def authorized?

def authorized?
  method = "view_#{id}?".to_sym
  service = field_resource.authorization
  if service.has_method? method
    service.authorize_action(method, raise_exception: false)
  else
    true
  end
end

def component_for_view(view = :index)

has_one, has_many, has_and_belongs_to_many fields don't have edit views
Adds the view override component
def component_for_view(view = :index)
  view = :show if view.in? [:new, :create, :update, :edit]
  super view
end

def default_name

def default_name
  use_resource&.name || super
end

def default_view

def default_view
  Avo.configuration.skip_show_view ? :edit : :show
end

def field_label

What the user sees in the text field
def field_label
  target_resource.hydrate(record: value).record_title
rescue
  nil
end

def field_resource

def field_resource
  resource || Avo.resource_manager.get_resource_by_model_class(@record.class)
end

def field_value

The value
def field_value
  value.send(database_value)
rescue
  nil
end

def frame_id

def frame_id
  use_resource.present? ? use_resource.route_key.to_sym : @id
end

def frame_url

def frame_url
  Avo::Services::URIService.parse(field_resource.record_path)
    .append_path(id.to_s)
    .append_query(turbo_frame: turbo_frame)
    .to_s
end

def has_own_panel?

def has_own_panel?
  true
end

def initialize(id, **args, &block)

def initialize(id, **args, &block)
  super(id, **args, &block)
  @scope = args[:scope].present? ? args[:scope] : nil
  @attach_scope = args[:attach_scope].present? ? args[:attach_scope] : nil
  @display = args[:display].present? ? args[:display] : :show
  @searchable = args[:searchable] == true
  @hide_search_input = args[:hide_search_input] || false
  @description = args[:description]
  @use_resource = args[:use_resource] || nil
  @discreet_pagination = args[:discreet_pagination] || false
  @link_to_child_resource = args[:link_to_child_resource] || false
end

def placeholder

def placeholder
  @placeholder || I18n.t("avo.choose_an_option")
end

def target_resource

def target_resource
  if @record._reflections[id.to_s].klass.present?
    Avo.resource_manager.get_resource_by_model_class @record._reflections[id.to_s].klass.to_s
  elsif @record._reflections[id.to_s].options[:class_name].present?
    Avo.resource_manager.get_resource_by_model_class @record._reflections[id.to_s].options[:class_name]
  else
    Avo.resource_manager.get_resource_by_name id.to_s
  end
end

def turbo_frame

def turbo_frame
  "#{self.class.name.demodulize.to_s.underscore}_#{display}_#{frame_id}"
end

def visible_in_reflection?

def visible_in_reflection?
  false
end