diff --git a/app/facades/dossiers_list_facades.rb b/app/facades/dossiers_list_facades.rb index 39ee69c4d..87a72b22f 100644 --- a/app/facades/dossiers_list_facades.rb +++ b/app/facades/dossiers_list_facades.rb @@ -19,6 +19,10 @@ class DossiersListFacades @liste end + def gestionnaire_procedures_name_and_id_list + @current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle})} + end + def procedure_id @procedure.nil? ? nil : @procedure.id end diff --git a/app/views/backoffice/dossiers/_onglets.html.haml b/app/views/backoffice/dossiers/_onglets.html.haml index 55c4c85a4..cb69ef779 100644 --- a/app/views/backoffice/dossiers/_onglets.html.haml +++ b/app/views/backoffice/dossiers/_onglets.html.haml @@ -1,6 +1,12 @@ =link_to 'Tous mes dossiers en CSV', backoffice_download_dossiers_tps_path, {class: 'btn btn-success btn-sm', style: 'float: right; margin-right: 4%; margin-top: 7px'} %h1 Gestion des dossiers -%br + +#filter_by_procedure{style:'margin-left: 5%'} + %select{onchange: 'location = this.value', style:'margin-top: 10px; margin-bottom: 10px', id: 'filter_by_procedure_select'} + %option{value: backoffice_dossiers_path} + - @dossiers_list_facade.gestionnaire_procedures_name_and_id_list.each do |procedure| + %option{value: backoffice_dossiers_procedure_path(procedure[:id]), ('selected' if procedure[:id] == params[:id].to_i) => '' } + = truncate(procedure[:libelle], {length: 50}) #onglets %ul.nav.nav-tabs diff --git a/spec/facades/dossiers_list_facades_spec.rb b/spec/facades/dossiers_list_facades_spec.rb index c701092f8..625643930 100644 --- a/spec/facades/dossiers_list_facades_spec.rb +++ b/spec/facades/dossiers_list_facades_spec.rb @@ -4,8 +4,12 @@ describe DossiersListFacades do let(:gestionnaire) { create :gestionnaire } let(:procedure) { create :procedure } + let(:procedure_2) { create :procedure, libelle: 'plop' } before do + create :assign_to, procedure: procedure, gestionnaire: gestionnaire + create :assign_to, procedure: procedure_2, gestionnaire: gestionnaire + create :preference_list_dossier, gestionnaire: gestionnaire, table: '', @@ -36,4 +40,19 @@ describe DossiersListFacades do it { expect(subject.size).to eq 1 } end end + + describe '#gestionnaire_procedures_name_and_id_list' do + let(:facade) { described_class.new gestionnaire, 'nouveaux' } + + subject { facade.gestionnaire_procedures_name_and_id_list } + + it { expect(subject.size).to eq 2 } + + it { expect(subject.first[:id]).to eq procedure.id } + it { expect(subject.first[:libelle]).to eq procedure.libelle } + + it { expect(subject.last[:id]).to eq procedure_2.id } + it { expect(subject.last[:libelle]).to eq procedure_2.libelle } + + end end \ No newline at end of file