gestionnaire can be filter be procedure on dossier list tab

This commit is contained in:
Xavier J 2016-09-09 17:29:21 +02:00
parent 30acd9bb3e
commit f6ab83f8bd
3 changed files with 30 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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