Merge pull request #5312 from myriamzbyt/fix_5300_instructeur_tableau_synthese_dossiers

Fix 5300 instructeur tableau synthese dossiers
This commit is contained in:
Keirua 2020-07-02 11:25:02 +02:00 committed by GitHub
commit b96b842d1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 96 additions and 0 deletions

View file

@ -15,4 +15,10 @@
background-color: $orange;
color: #FFFFFF;
}
&.procedure-synthese-badge {
color: $white;
background-color: #6C757D;
margin-right: 3px;
}
}

View file

@ -29,6 +29,18 @@ module Instructeurs
.group('groupe_instructeurs.procedure_id')
.reorder(nil)
.count
@all_dossiers_counts = {}
@all_dossiers_counts['à suivre'] = dossiers.without_followers.en_cours.count
@all_dossiers_counts['suivis'] = current_instructeur
.followed_dossiers
.joins(:groupe_instructeur)
.en_cours
.where(groupe_instructeur_id: groupe_ids)
.count
@all_dossiers_counts['traités'] = dossiers.termine.count
@all_dossiers_counts['dossiers'] = dossiers.all_state.count
@all_dossiers_counts['archivés'] = dossiers.archived.count
end
def show

View file

@ -0,0 +1,6 @@
- if procedures.length > 1
.tab-title
%span
Synthèse des dossiers
- all_dossiers_counts.each_with_index do |(label, dossier_count)|
%span.badge.procedure-synthese-badge= number_with_html_delimiter(dossier_count) + ' ' + label

View file

@ -2,6 +2,7 @@
.container
%h1.page-title Démarches
= render partial: 'instructeurs/procedures/synthese', locals: { procedures: @procedures, all_dossiers_counts: @all_dossiers_counts }
= render partial: 'instructeurs/procedures/list', locals: { procedures: @procedures,
dossiers_count_per_procedure: @dossiers_count_per_procedure,

View file

@ -134,6 +134,12 @@ describe Instructeurs::ProceduresController, type: :controller do
it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(nil) }
it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure.id]).to eq(nil) }
it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure.id]).to eq(nil) }
it { expect(assigns(:all_dossiers_counts)['à suivre']).to eq(0) }
it { expect(assigns(:all_dossiers_counts)['suivis']).to eq(0) }
it { expect(assigns(:all_dossiers_counts)['traités']).to eq(0) }
it { expect(assigns(:all_dossiers_counts)['dossiers']).to eq(0) }
it { expect(assigns(:all_dossiers_counts)['archivés']).to eq(0) }
end
context "with not draft state on multiple procedures" do
@ -164,6 +170,12 @@ describe Instructeurs::ProceduresController, type: :controller do
it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure2.id]).to eq(1) }
it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure2.id]).to eq(nil) }
it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure2.id]).to eq(1) }
it { expect(assigns(:all_dossiers_counts)['à suivre']).to eq(3 + 0) }
it { expect(assigns(:all_dossiers_counts)['suivis']).to eq(0 + 1) }
it { expect(assigns(:all_dossiers_counts)['traités']).to eq(0 + 1) }
it { expect(assigns(:all_dossiers_counts)['dossiers']).to eq(3 + 3) }
it { expect(assigns(:all_dossiers_counts)['archivés']).to eq(1 + 0) }
end
end
@ -198,6 +210,12 @@ describe Instructeurs::ProceduresController, type: :controller do
it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure.id]).to eq(10) }
it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(4 + 6 + 10) }
it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(14) }
it { expect(assigns(:all_dossiers_counts)['à suivre']).to eq(4) }
it { expect(assigns(:all_dossiers_counts)['suivis']).to eq(6) }
it { expect(assigns(:all_dossiers_counts)['traités']).to eq(10) }
it { expect(assigns(:all_dossiers_counts)['dossiers']).to eq(4 + 6 + 10) }
it { expect(assigns(:all_dossiers_counts)['archivés']).to eq(14) }
end
context 'when an instructeur only belongs to one of them gi' do
@ -213,6 +231,12 @@ describe Instructeurs::ProceduresController, type: :controller do
it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure.id]).to eq(5) }
it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(2 + 3 + 5) }
it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(7) }
it { expect(assigns(:all_dossiers_counts)['à suivre']).to eq(2) }
it { expect(assigns(:all_dossiers_counts)['suivis']).to eq(3) }
it { expect(assigns(:all_dossiers_counts)['traités']).to eq(5) }
it { expect(assigns(:all_dossiers_counts)['dossiers']).to eq(2 + 3 + 5) }
it { expect(assigns(:all_dossiers_counts)['archivés']).to eq(7) }
end
end
end

View file

@ -0,0 +1,47 @@
describe 'instructeurs/procedures/_synthese.html.haml', type: :view do
let(:current_instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure) }
let!(:dossier) { create(:dossier, procedure: procedure) }
context 'when instructeur has 2 procedures and 1 file, table is shown' do
let(:procedure2) { create(:procedure) }
subject {
render 'instructeurs/procedures/synthese.html.haml',
all_dossiers_counts: {
'à suivre': 0,
'suivis': 0,
'traités': 1,
'dossiers': 1,
'archivés': 0
},
procedures: [procedure, procedure2]
}
it { is_expected.to have_text('Synthèse des dossiers') }
it { is_expected.to have_text('suivis') }
it { is_expected.to have_text('traités') }
it { is_expected.to have_text('dossiers') }
it { is_expected.to have_text('archivés') }
end
context 'when instructeur has 1 procedure and 1 file, table is not shown' do
subject {
render 'instructeurs/procedures/synthese.html.haml',
all_dossiers_counts: {
'à suivre': 0,
'suivis': 0,
'traités': 1,
'dossiers': 1,
'archivés': 0
},
procedures: [procedure]
}
it { is_expected.not_to have_text('Synthèse des dossiers') }
it { is_expected.not_to have_text('suivis') }
it { is_expected.not_to have_text('traités') }
it { is_expected.not_to have_text('dossiers') }
it { is_expected.not_to have_text('archivés') }
end
end