Sha256: a6b418a433d97e61b883762fb5f6c06c0bb5a1d2fc839a1b0e8bd55b633d2a76

Contents?: true

Size: 627 Bytes

Versions: 3

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true

class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
  include Avo::ResourcesHelper
  include Avo::ApplicationHelper

  def initialize(resource: nil)
    @resource = resource
  end

  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.resource_path(model: @resource.model, resource: @resource)
    end
  end

  private

  def via_resource?
    params[:via_resource_class].present? && params[:via_resource_id].present?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
avo-1.19.1.pre.2 app/components/avo/views/resource_edit_component.rb
avo-1.19.1.pre.1 app/components/avo/views/resource_edit_component.rb
avo-1.19.0 app/components/avo/views/resource_edit_component.rb