Sha256: 503ce59fc1b2a6851292fd14adfd9092813ce7322543413f2e1c520b49399454

Contents?: true

Size: 998 Bytes

Versions: 11

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

class Avo::BaseComponent < ViewComponent::Base
  include Turbo::FramesHelper

  def has_with_trial(ability)
    ::Avo::App.license.has_with_trial(ability)
  end

  private

  # Use the @parent_resource to fetch the field using the @reflection name.
  def field
    @parent_resource.get_field_definitions.find { |f| f.id == @reflection.name }
  rescue
    nil
  end

  def relation_resource
    model = params[:via_resource_class] || params[:via_relation_class]
    ::Avo::App.get_resource_by_model_name model.safe_constantize
  end

  # Get the resource for the resource using the klass attribute so we get the namespace too
  def reflection_resource
    ::Avo::App.get_resource_by_model_name(@reflection.klass.to_s)
  rescue
    nil
  end

  # Get the resource for the resource using the klass attribute so we get the namespace too
  def reflection_parent_resource
    ::Avo::App.get_resource_by_model_name(@reflection.active_record.to_s)
  rescue
    nil
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
avo-2.16.0 app/components/avo/base_component.rb
avo-2.15.3 app/components/avo/base_component.rb
avo-2.15.3.pre.1.data.attrs.to.sidebar.items app/components/avo/base_component.rb
avo-2.15.2 app/components/avo/base_component.rb
avo-2.15.2.pre.1 app/components/avo/base_component.rb
avo-2.15.1 app/components/avo/base_component.rb
avo-2.15.0 app/components/avo/base_component.rb
avo-2.14.3.pre.7.polytranslations1 app/components/avo/base_component.rb
avo-2.14.3.pre.6.nosprockets app/components/avo/base_component.rb
avo-2.14.3.pre.5.nosprockets app/components/avo/base_component.rb
avo-2.13.5.pre.2 app/components/avo/base_component.rb