Remove DossierListFacade dependency

This commit is contained in:
Mathieu Magnin 2017-04-11 17:56:11 +02:00
parent 236dc15507
commit 1a628dc42c
5 changed files with 31 additions and 73 deletions

View file

@ -10,19 +10,29 @@ class Users::DossiersController < UsersController
end
def index
cookies[:liste] = param_liste
set_liste
@dossiers_list_facade = DossiersListFacades.new current_user, param_liste
@user_dossiers = current_user.dossiers
unless DossiersListUserService.dossiers_liste_libelle.include?(param_liste)
cookies[:liste] = 'a_traiter'
@dossiers_filtered = case @liste
when 'brouillon'
@user_dossiers.brouillon
when 'a_traiter'
@user_dossiers.en_construction
when 'en_instruction'
@user_dossiers.en_instruction
when 'termine'
@user_dossiers.termine
when 'invite'
current_user.invites
else
return redirect_to users_dossiers_path
end
@dossiers = smart_listing_create :dossiers,
@dossiers_list_facade.dossiers_to_display,
partial: "users/dossiers/list",
array: true
@dossiers_filtered,
partial: "users/dossiers/list",
array: true
end
def commencer
@ -223,7 +233,7 @@ class Users::DossiersController < UsersController
DossierFacades.new id, current_user.email
end
def param_liste
@liste ||= params[:liste] || cookies[:liste] || 'a_traiter'
def set_liste
@liste ||= params[:liste] || 'a_traiter'
end
end

View file

@ -63,70 +63,18 @@ class DossiersListFacades
preference_list_dossiers_filter.where(table: :champs).where.not(filter: '').size == 0
end
def all_state_class
(@liste == 'all_state' ? 'active' : '')
end
def brouillon_class
(@liste == 'brouillon' ? 'active' : '')
end
def en_construction_class
(@liste == 'a_traiter' ? 'active' : '')
end
def valides_class
(@liste == 'valides' ? 'active' : '')
end
def en_instruction_class
(@liste == 'en_instruction' ? 'active' : '')
end
def termine_class
(@liste == 'termine' ? 'active' : '')
end
def invite_class
(@liste == 'invite' ? 'active' : '')
end
def all_state_total
service.all_state.count
end
def brouillon_total
service.brouillon.count
end
def nouveaux_total
service.nouveaux.count
end
def en_construction_total
service.en_construction.count
end
def valides_total
service.valides.count
end
def en_instruction_total
service.en_instruction.count
end
def termine_total
service.termine.count
end
def suivi_total
service.suivi.count
end
def invite_total
service.invite.count
end
def filter_url
@procedure.nil? ? backoffice_dossiers_filter_path(liste: liste) : backoffice_dossiers_procedure_filter_path(id: @procedure.id, liste: liste)
end

View file

@ -12,34 +12,34 @@
#procedure-list
- unless current_user.dossiers.count == 0
%a{ :href => "#{url_for users_dossiers_path(liste: 'brouillon')}", 'data-toggle' => :tooltip, title: 'Les dossiers jamais proposés à la relecture.' }
.procedure-list-element{ class: @dossiers_list_facade.brouillon_class, id: 'brouillon' }
.procedure_list_element{ class: ('active' if @liste == 'brouillon'), id: 'brouillon' }
Brouillons
.badge.progress-bar-default
= @dossiers_list_facade.brouillon_total
= @user_dossiers.brouillon.count
%a{ :href => "#{url_for users_dossiers_path(liste: 'a_traiter')}", 'data-toggle' => :tooltip, title: 'Les dossiers qui requièrent une action de votre part.' }
.procedure-list-element{ class: @dossiers_list_facade.en_construction_class, id: 'a_traiter' }
.procedure-list-element{ class: ('active' if @liste == 'a_traiter'), id: 'a_traiter' }
En construction
.badge.progress-bar-danger
= @dossiers_list_facade.en_construction_total
= @user_dossiers.en_construction.count
%a{ :href => "#{url_for users_dossiers_path(liste: 'en_instruction')}", 'data-toggle' => :tooltip, title: 'Les dossiers en cours d\'examen par l\'administration compétante.' }
.procedure-list-element{ class: @dossiers_list_facade.en_instruction_class, id: 'en_instruction' }
.procedure_list_element{ class: ('active' if @liste == 'en_instruction'), id: 'en_instruction' }
En instruction
.badge.progress-bar-default
= @dossiers_list_facade.en_instruction_total
= @user_dossiers.en_instruction.count
%a{ :href => "#{url_for users_dossiers_path(liste: 'termine')}", 'data-toggle' => :tooltip, title: 'Les dossiers cloturés qui peuvent être "Accepté", "Refusé" ou "Sans suite".' }
.procedure-list-element{ class: @dossiers_list_facade.termine_class, id: 'termine' }
.procedure_list_element{ class: ('active' if @liste == 'termine'), id: 'termine' }
Terminé
.badge.progress-bar-success
= @dossiers_list_facade.termine_total
= @user_dossiers.termine.count
%a{ :href => "#{url_for users_dossiers_path(liste: 'invite')}" }
.procedure-list-element{ class: @dossiers_list_facade.invite_class, id: 'invite' }
.procedure_list_element{ class: ('active' if @liste == 'invite'), id: 'invite' }
Invitation
.badge.progress-bar-warning
= @dossiers_list_facade.invite_total
= current_user.invites.count
.split-hr-left

View file

@ -5,7 +5,7 @@
.col-md-1.col-lg-1.col-sm-1.col-xs-1
.fa.fa-info-circle.text-info{ style: 'font-size: 2em; margin-top: 20%;' }
.col-xs-11
- case dossiers_list_facade.liste
- case liste
- when 'brouillon'
Les dossiers présents dans cette liste
%b

View file

@ -12,4 +12,4 @@
.body
= smart_listing_render :dossiers
= render partial: 'state_description', locals: { dossiers_list_facade: @dossiers_list_facade }
= render partial: 'state_description', locals: { liste: @liste }