Sha256: bc5fcdfb0e8c4a097b47d823609d78e990b4b828d15e9a6b2b1f8da5c2b76a8e

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

module Avo
  module Fields
    class TrixField < BaseField
      attr_reader :always_show
      attr_reader :attachments_disabled
      attr_reader :attachment_key
      attr_reader :hide_attachment_filename
      attr_reader :hide_attachment_filesize
      attr_reader :hide_attachment_url

      def initialize(id, **args, &block)
        super(id, **args, &block)

        hide_on :index

        @always_show = args[:always_show] || false
        @attachment_key = args[:attachment_key]
        @attachments_disabled = disable_attachments?(args)
        @hide_attachment_filename = args[:hide_attachment_filename] || false
        @hide_attachment_filesize = args[:hide_attachment_filesize] || false
        @hide_attachment_url = args[:hide_attachment_url] || false
      end

      private

      def disable_attachments?(args)
        # If we don't have an attachment_key, we disable attachments. There's no point in having
        # attachments if we can't store them.
        return false if args[:attachment_key].present?

        args[:attachments_disabled] == true
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
avo-3.6.1 lib/avo/fields/trix_field.rb
avo-3.6.0 lib/avo/fields/trix_field.rb
avo-3.5.8 lib/avo/fields/trix_field.rb
avo-3.5.7 lib/avo/fields/trix_field.rb
avo-3.5.6 lib/avo/fields/trix_field.rb
avo-3.5.6.beta1 lib/avo/fields/trix_field.rb
avo-3.5.5 lib/avo/fields/trix_field.rb
avo-3.5.4 lib/avo/fields/trix_field.rb
avo-3.5.3 lib/avo/fields/trix_field.rb
avo-3.5.2 lib/avo/fields/trix_field.rb
avo-3.5.1 lib/avo/fields/trix_field.rb
avo-3.5.0 lib/avo/fields/trix_field.rb
avo-3.4.4 lib/avo/fields/trix_field.rb
avo-3.4.3 lib/avo/fields/trix_field.rb
avo-3.4.2 lib/avo/fields/trix_field.rb
avo-3.4.1 lib/avo/fields/trix_field.rb
avo-3.4.0 lib/avo/fields/trix_field.rb
avo-3.3.6 lib/avo/fields/trix_field.rb