Sha256: 9140063575fd6328ccb89d61bbacc985dcc58b07f32f6fb0079e3b7cf104f829

Contents?: true

Size: 968 Bytes

Versions: 20

Compression:

Stored size: 968 Bytes

Contents

module Katello
  module Concerns
    module FilteredAutoCompleteSearch
      extend ActiveSupport::Concern

      PAGE_SIZE = 20

      def auto_complete_search
        begin
          options = resource_class.respond_to?(:completer_scope_options) ? resource_class.completer_scope_options(params[:search]) : {}
          items = resource_class.where(:id => self.index_relation).complete_for(params[:search], options)
          items = items.map do |item|
            category = ['and', 'or', 'not', 'has'].include?(item.to_s.sub(/^.*\s+/, '')) ? _('Operators') : ''
            part = item.to_s.sub(/^.*\b(and|or)\b/i) { |match| match.sub(/^.*\s+/, '') }
            completed = item.to_s.chomp(part)
            {:completed => completed, :part => part, :label => item, :category => category}
          end
        rescue ScopedSearch::QueryNotSupported => e
          items = [{:error => e.to_s}]
        end
        render :json => items
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
katello-4.15.0.rc2 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.15.0.rc1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.14.1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.14.0 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.14.0.rc3 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.14.0.rc2 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.14.0.rc1.1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.14.0.rc1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.13.1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.13.0 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.12.1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.13.0.rc1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.12.0 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.12.0.rc3 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.12.0.rc2 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.12.0.rc1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.11.1 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.11.0 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.11.0.rc2 app/controllers/katello/concerns/filtered_auto_complete_search.rb
katello-4.11.0.rc1 app/controllers/katello/concerns/filtered_auto_complete_search.rb