Sha256: 449ece94d52c9c390ae911c149adee62a0eda63fdfd211770fe3f3302fc916af

Contents?: true

Size: 737 Bytes

Versions: 32

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

class Avo::Fields::Common::SingleFileViewerComponent < ViewComponent::Base
  include Avo::ApplicationHelper

  def initialize(file: nil, field:, resource:)
    @file = file
    @field = field
    @resource = resource
  end

  def destroy_path
    Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, file.id).to_s
  end

  def id
    @field.id
  end

  def file
    @file || @field.value.attachment
  rescue
    nil
  end

  def is_image?
    file.image? || @field.is_image
  rescue
    false
  end

  def is_audio?
    file.audio? || @field.is_audio
  rescue
    false
  end

  def is_video?
    file.video? || @field.is_video
  rescue
    false
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
avo-2.11.2.pre.1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.11.1.pre.3 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.11.1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.11.1.pre.2 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.11.1.pre.1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.11.0 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.10.3.pre.1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.10.2 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.10.0 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.9.1.pre7 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.9.1.pre6 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.9.1.pre4 app/components/avo/fields/common/single_file_viewer_component.rb