DossierController: factorize page logic

This commit is contained in:
simon lehericey 2018-03-30 18:17:47 +02:00
parent 05ab4c5ca6
commit 6fa4fc0046

View file

@ -85,8 +85,8 @@ module NewUser
end
def index
@user_dossiers = current_user.dossiers.includes(:procedure).page([params[:page].to_i, 1].max)
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).page([params[:page].to_i, 1].max)
@user_dossiers = current_user.dossiers.includes(:procedure).page(page)
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).page(page)
@current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count)
@ -100,6 +100,10 @@ module NewUser
private
def page
[params[:page].to_i, 1].max
end
def current_tab(mes_dossiers_count, dossiers_invites_count)
if dossiers_invites_count == 0
'mes-dossiers'