Instructeur : add overview table with counts for files

nombre total de dossier :
- 'à suivre'
- 'suivi'
- 'traité'
- 'dossier'
- 'archivé'
This commit is contained in:
Myriam 2020-06-25 15:19:54 +02:00 committed by Keirua (Rebase PR Action)
parent 22515ffbfe
commit a486fe9a2e
7 changed files with 87 additions and 4 deletions

View file

@ -3,6 +3,10 @@
@import "mixins";
.procedure-list {
&.synthese {
margin-top: 16px;
}
.procedure-item {
border-bottom: 1px solid $border-grey;
@ -51,7 +55,7 @@
width: 90px;
position: relative;
&:hover {
&:not(.procedure-synthese):hover {
background-color: rgba(0, 0, 0, 0.05);
}

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['suivi'] = current_instructeur
.followed_dossiers
.joins(:groupe_instructeur)
.en_cours
.where(groupe_instructeur_id: groupe_ids)
.count
@all_dossiers_counts['traité'] = dossiers.termine.count
@all_dossiers_counts['dossier'] = dossiers.all_state.count
@all_dossiers_counts['archivé'] = dossiers.archived.count
end
def show

View file

@ -0,0 +1,11 @@
.tab-title
Synthèse des dossiers
.procedure-list.synthese
%ul.procedure-stats.flex
- all_dossiers_counts.each_with_index do |(label, dossier_count)|
%li.procedure-synthese
%object
.stats-number
= number_with_html_delimiter(dossier_count)
.stats-legend
= label

View file

@ -2,6 +2,7 @@
.container
%h1.page-title Démarches
= render partial: 'instructeurs/procedures/synthese', locals: { 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)['suivi']).to eq(0) }
it { expect(assigns(:all_dossiers_counts)['traité']).to eq(0) }
it { expect(assigns(:all_dossiers_counts)['dossier']).to eq(0) }
it { expect(assigns(:all_dossiers_counts)['archivé']).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)['suivi']).to eq(0 + 1) }
it { expect(assigns(:all_dossiers_counts)['traité']).to eq(0 + 1) }
it { expect(assigns(:all_dossiers_counts)['dossier']).to eq(3 + 3) }
it { expect(assigns(:all_dossiers_counts)['archivé']).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)['suivi']).to eq(6) }
it { expect(assigns(:all_dossiers_counts)['traité']).to eq(10) }
it { expect(assigns(:all_dossiers_counts)['dossier']).to eq(4 + 6 + 10) }
it { expect(assigns(:all_dossiers_counts)['archivé']).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)['suivi']).to eq(3) }
it { expect(assigns(:all_dossiers_counts)['traité']).to eq(5) }
it { expect(assigns(:all_dossiers_counts)['dossier']).to eq(2 + 3 + 5) }
it { expect(assigns(:all_dossiers_counts)['archivé']).to eq(7) }
end
end
end

View file

@ -122,7 +122,9 @@ feature 'The routing', js: true do
## on the procedures list
expect(page).to have_current_path(instructeur_procedures_path)
expect(find('.procedure-stats')).to have_css('span.notifications')
within find('.procedure-details') do
expect(find('.procedure-stats')).to have_css('span.notifications')
end
## on the dossiers list
click_on procedure.libelle
@ -142,7 +144,9 @@ feature 'The routing', js: true do
sign_in_with marie.user.email, password
expect(page).to have_current_path(instructeur_procedures_path)
expect(find('.procedure-stats')).not_to have_css('span.notifications')
within find('.procedure-details') do
expect(find('.procedure-stats')).not_to have_css('span.notifications')
end
log_out
# the instructeurs who belong to scientifique AND litteraire groups manage scientifique and litterraire dossiers
@ -168,7 +172,9 @@ feature 'The routing', js: true do
sign_in_with superwoman.user.email, password
expect(page).to have_current_path(instructeur_procedures_path)
expect(find('.procedure-stats')).to have_css('span.notifications')
within find('.procedure-details') do
expect(find('.procedure-stats')).to have_css('span.notifications')
end
end
def publish_procedure(procedure)

View file

@ -0,0 +1,25 @@
describe 'instructeurs/procedures/_synthese.html.haml', type: :view do
let(:current_instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure) }
let!(:dossier) { create(:dossier, procedure: procedure) }
subject {
render 'instructeurs/procedures/synthese.html.haml',
all_dossiers_counts: {
'à suivre': 0,
'suivi': 0,
'traité': 1,
'dossier': 1,
'archivé': 0
}
}
context 'when instructeur has 1 procedure and has 1 dossier' do
it { is_expected.to have_text('Synthèse des dossiers') }
it { is_expected.to have_css('.synthese') }
it { is_expected.to have_text('suivi') }
it { is_expected.to have_text('traité') }
it { is_expected.to have_text('dossier') }
it { is_expected.to have_text('archivé') }
end
end