recherche usager full-text avec plusieurs resultats
This commit is contained in:
parent
98337f2334
commit
76139dbc71
1 changed files with 11 additions and 3 deletions
|
@ -220,12 +220,20 @@ module Users
|
|||
|
||||
def recherche
|
||||
@search_terms = params[:q]
|
||||
@dossiers = DossierSearchService.matching_dossiers_for_user(@search_terms, current_user)
|
||||
return redirect_to dossiers_path if @search_terms.blank?
|
||||
|
||||
@dossiers = DossierSearchService.matching_dossiers_for_user(@search_terms, current_user).page(page)
|
||||
|
||||
if @dossiers.present?
|
||||
# we need the page condition when accessing page n with n>1 when the page has only 1 result
|
||||
# in order to avoid an unpleasant redirection when changing page
|
||||
if @dossiers.count == 1 && page == 1
|
||||
redirect_to url_for_dossier(@dossiers.first)
|
||||
else
|
||||
flash.alert = "Vous n’avez pas de dossier contenant «#{@search_terms}»."
|
||||
render :index
|
||||
end
|
||||
else
|
||||
flash.alert = "Vous n’avez pas de dossiers contenant « #{@search_terms} »."
|
||||
redirect_to dossiers_path
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue