Sha256: 4cc42c887d3dfbf122032c24bff8969c629f708736055251238ac693fc0efc84

Contents?: true

Size: 566 Bytes

Versions: 9

Compression:

Stored size: 566 Bytes

Contents

# frozen_string_literal: true

class Avo::Views::ResourceEditComponent < ViewComponent::Base
  include Avo::ResourcesHelper
  include Avo::ApplicationHelper

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

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avo-0.5.0.beta9 app/components/avo/views/resource_edit_component.rb
avo-0.5.0.beta8 app/components/avo/views/resource_edit_component.rb
avo-0.5.0.beta7 app/components/avo/views/resource_edit_component.rb
avo-0.5.0.beta6 app/components/avo/views/resource_edit_component.rb
avo-0.5.0.beta5 app/components/avo/views/resource_edit_component.rb
avo-0.5.0.beta4 app/components/avo/views/resource_edit_component.rb
avo-0.5.0.beta3 app/components/avo/views/resource_edit_component.rb
avo-0.5.0.beta2 app/components/avo/views/resource_edit_component.rb
avo-0.5.0.beta1 app/components/avo/views/resource_edit_component.rb