Module: SearchHelper

Included in:
SearchController
Defined in:
app/helpers/search_helper.rb

Instance Method Summary collapse

Instance Method Details

#search_autocomplete_opts(term) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/search_helper.rb', line 3

def search_autocomplete_opts(term)
  return unless current_user

  resources_results = [
    groups_autocomplete(term),
    projects_autocomplete(term)
  ].flatten

  generic_results = project_autocomplete + default_autocomplete + help_autocomplete
  generic_results.select! { |result| result[:label] =~ Regexp.new(term, "i") }

  [
    resources_results,
    generic_results
  ].flatten.uniq do |item|
    item[:label]
  end
end

#search_entries_info(collection, scope, term) ⇒ Object


22
23
24
25
26
27
28
29
30
# File 'app/helpers/search_helper.rb', line 22

def search_entries_info(collection, scope, term)
  return unless collection.count > 0

  from = collection.offset_value + 1
  to = collection.offset_value + collection.length
  count = collection.total_count

  "Showing #{from} - #{to} of #{count} #{scope.humanize(capitalize: false)} for \"#{term}\""
end