Class: Kaui::HomeController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/home_controller.rb

Constant Summary collapse

QUERY_PARSE_REGEX =
['FIND:(?<object_type>.*) BY:(?<search_by>.*) FOR:(?<search_for>.*) ONLY_FIRST:(?<fast>.*)',
'FIND:(?<object_type>.*) BY:(?<search_by>.*) FOR:(?<search_for>.*)',
'FIND:(?<object_type>.*) FOR:(?<search_for>.*) ONLY_FIRST:(?<fast>.*)',
'FIND:(?<object_type>.*) FOR:(?<search_for>.*)'].freeze
SIMPLE_PARSE_REGEX =
'(?<search_for>.*)'

Constants included from EngineControllerUtil

EngineControllerUtil::MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD

Instance Method Summary collapse

Methods inherited from EngineController

#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user

Methods included from ErrorHandler

#perform_redirect_after_error

Instance Method Details

#indexObject



12
13
14
15
16
17
18
19
# File 'app/controllers/kaui/home_controller.rb', line 12

def index
  @search_query = params[:q]
  @max_records = {}
  %w[account payment invoice].each do |type|
    model = "Kaui::#{type.capitalize}".constantize
    @max_records[type.to_sym] = model.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records || 0
  end
end

#searchObject



21
22
23
24
25
26
# File 'app/controllers/kaui/home_controller.rb', line 21

def search
  object_type, search_query = splitting_new_search(params[:q])
  object_type = object_type.tr(' ', '_').downcase
  cached_options_for_klient = options_for_klient
  send("#{object_type}_search", search_query, nil, 0, cached_options_for_klient)
end