From a486fe9a2e42fee17913279dc256e8488a256064 Mon Sep 17 00:00:00 2001 From: Myriam Date: Thu, 25 Jun 2020 15:19:54 +0200 Subject: [PATCH] Instructeur : add overview table with counts for files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nombre total de dossier : - 'à suivre' - 'suivi' - 'traité' - 'dossier' - 'archivé' --- .../new_design/procedure_list.scss | 6 ++++- .../instructeurs/procedures_controller.rb | 12 +++++++++ .../procedures/_synthese.html.haml | 11 ++++++++ .../instructeurs/procedures/index.html.haml | 1 + .../procedures_controller_spec.rb | 24 ++++++++++++++++++ spec/features/routing/full_scenario_spec.rb | 12 ++++++--- .../procedures/_synthese.html.haml_spec.rb | 25 +++++++++++++++++++ 7 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 app/views/instructeurs/procedures/_synthese.html.haml create mode 100644 spec/views/instructeur/procedures/_synthese.html.haml_spec.rb diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss index cc7f09898..3d68bcd8c 100644 --- a/app/assets/stylesheets/new_design/procedure_list.scss +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -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); } diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 68e01c1b0..36eb469fd 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -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 diff --git a/app/views/instructeurs/procedures/_synthese.html.haml b/app/views/instructeurs/procedures/_synthese.html.haml new file mode 100644 index 000000000..43cdab495 --- /dev/null +++ b/app/views/instructeurs/procedures/_synthese.html.haml @@ -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 diff --git a/app/views/instructeurs/procedures/index.html.haml b/app/views/instructeurs/procedures/index.html.haml index 93efd2ba2..84c81ed1b 100644 --- a/app/views/instructeurs/procedures/index.html.haml +++ b/app/views/instructeurs/procedures/index.html.haml @@ -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, diff --git a/spec/controllers/instructeurs/procedures_controller_spec.rb b/spec/controllers/instructeurs/procedures_controller_spec.rb index f48b9df44..e218002c1 100644 --- a/spec/controllers/instructeurs/procedures_controller_spec.rb +++ b/spec/controllers/instructeurs/procedures_controller_spec.rb @@ -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 diff --git a/spec/features/routing/full_scenario_spec.rb b/spec/features/routing/full_scenario_spec.rb index 08c913e0b..40a2cd6dd 100644 --- a/spec/features/routing/full_scenario_spec.rb +++ b/spec/features/routing/full_scenario_spec.rb @@ -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) diff --git a/spec/views/instructeur/procedures/_synthese.html.haml_spec.rb b/spec/views/instructeur/procedures/_synthese.html.haml_spec.rb new file mode 100644 index 000000000..c103766b8 --- /dev/null +++ b/spec/views/instructeur/procedures/_synthese.html.haml_spec.rb @@ -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