Sha256: 75ddf0c9e2f5364f46f122504ce77383be80f80dab443a3c12753f01ef56c882

Contents?: true

Size: 692 Bytes

Versions: 38

Compression:

Stored size: 692 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
    "#{@resource.record_path}/active_storage_attachments/#{id}/#{file.id}"
  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

38 entries across 38 versions & 1 rubygems

Version Path
avo-2.9.2.pre1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.9.1.pre5 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.9.1.pre3 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.9.1.pre2 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.9.1.pre1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.9.0 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.8.0 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.7.1.pre.1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.7.0 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.6.1.pre.2 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.6.1.pre.1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.6.0 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.5.2.pre.7 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.5.2.pre.6 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.5.2.pre.5 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.5.2.pre.4 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.5.2.pre.3 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.5.2.pre.2 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.5.2.pre.1 app/components/avo/fields/common/single_file_viewer_component.rb
avo-2.5.1 app/components/avo/fields/common/single_file_viewer_component.rb