DossierController: factorize page logic
This commit is contained in:
parent
05ab4c5ca6
commit
6fa4fc0046
1 changed files with 6 additions and 2 deletions
|
@ -85,8 +85,8 @@ module NewUser
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@user_dossiers = current_user.dossiers.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([params[:page].to_i, 1].max)
|
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).page(page)
|
||||||
|
|
||||||
@current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count)
|
@current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count)
|
||||||
|
|
||||||
|
@ -100,6 +100,10 @@ module NewUser
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def page
|
||||||
|
[params[:page].to_i, 1].max
|
||||||
|
end
|
||||||
|
|
||||||
def current_tab(mes_dossiers_count, dossiers_invites_count)
|
def current_tab(mes_dossiers_count, dossiers_invites_count)
|
||||||
if dossiers_invites_count == 0
|
if dossiers_invites_count == 0
|
||||||
'mes-dossiers'
|
'mes-dossiers'
|
||||||
|
|
Loading…
Reference in a new issue