2017-07-31 11:58:52 +02:00
|
|
|
module NewGestionnaire
|
2017-11-22 09:56:36 +01:00
|
|
|
class RechercheController < GestionnaireController
|
2017-07-31 11:58:52 +02:00
|
|
|
def index
|
|
|
|
@search_terms = params[:q]
|
|
|
|
|
|
|
|
# exact id match?
|
|
|
|
if @search_terms.to_i != 0
|
2018-01-16 09:27:32 +01:00
|
|
|
@dossiers = current_gestionnaire.dossiers.where(id: @search_terms.to_i) +
|
|
|
|
current_gestionnaire.dossiers_from_avis.where(id: @search_terms.to_i)
|
|
|
|
@dossiers.uniq!
|
2017-07-31 11:58:52 +02:00
|
|
|
end
|
|
|
|
|
2018-01-16 09:25:23 +01:00
|
|
|
if @dossiers.nil?
|
|
|
|
@dossiers = Dossier.none
|
|
|
|
end
|
2017-07-31 11:58:52 +02:00
|
|
|
|
|
|
|
# full text search
|
|
|
|
if @dossiers.empty?
|
|
|
|
@dossiers = Search.new(
|
2018-01-15 18:48:14 +01:00
|
|
|
gestionnaire: current_gestionnaire,
|
|
|
|
query: @search_terms,
|
|
|
|
page: params[:page]
|
2017-07-31 11:58:52 +02:00
|
|
|
).results
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|