Sha256: 21f48dc350c642ed9f573d6502f9dfe4f4186e21ed45e390d41561a8c3d62c0c

Contents?: true

Size: 828 Bytes

Versions: 16

Compression:

Stored size: 828 Bytes

Contents

module Formstrap
  module Autocompletable
    extend ActiveSupport::Concern

    included do
      def autocomplete?
        collection.is_a?(String) || collection.is_a?(Array)
      end

      def autocomplete_options
        {
          collection: collection.is_a?(Array) ? collection : []
        }
      end

      def autocomplete_input_options
        {
          data: {
            autocomplete_target: autocomplete? ? "input" : nil
          }
        }
      end

      def autocomplete_input_group_options
        options = {
          data: {
            controller: autocomplete? ? "autocomplete" : nil,
            autocomplete_url_value: collection.is_a?(String) ? collection : nil
          }
        }
        options = options.merge(bypass: false) if autocomplete?
        options
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
formstrap-0.4.5 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.4.4 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.4.3 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.4.2 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.3.5 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.3.4 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.3.3 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.3.2 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.3.1 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.3.0 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.2.1 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.2.0 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.1.3 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.1.2 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.1.1 app/models/concerns/formstrap/autocompletable.rb
formstrap-0.1.0 app/models/concerns/formstrap/autocompletable.rb