From 0f542527fb40cb89f07d8d5e83f8cd693db7bdb5 Mon Sep 17 00:00:00 2001 From: Myriam Date: Fri, 26 Jun 2020 15:22:40 +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 - changement du design - tableau visible seulement si plus d'une procédure --- app/assets/stylesheets/new_design/badges.scss | 6 +++ .../new_design/procedure_list.scss | 6 +-- .../instructeurs/procedures_controller.rb | 8 +-- .../procedures/_synthese.html.haml | 15 ++---- .../instructeurs/procedures/index.html.haml | 2 +- .../procedures_controller_spec.rb | 32 +++++------ spec/features/routing/full_scenario_spec.rb | 12 ++--- .../procedures/_synthese.html.haml_spec.rb | 54 +++++++++++++------ 8 files changed, 74 insertions(+), 61 deletions(-) diff --git a/app/assets/stylesheets/new_design/badges.scss b/app/assets/stylesheets/new_design/badges.scss index 6151b9d47..b107e7f49 100644 --- a/app/assets/stylesheets/new_design/badges.scss +++ b/app/assets/stylesheets/new_design/badges.scss @@ -15,4 +15,10 @@ background-color: $orange; color: #FFFFFF; } + + &.procedure-synthese-badge { + color: $white; + background-color: #6C757D; + margin-right: 3px; + } } diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss index 3d68bcd8c..cc7f09898 100644 --- a/app/assets/stylesheets/new_design/procedure_list.scss +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -3,10 +3,6 @@ @import "mixins"; .procedure-list { - &.synthese { - margin-top: 16px; - } - .procedure-item { border-bottom: 1px solid $border-grey; @@ -55,7 +51,7 @@ width: 90px; position: relative; - &:not(.procedure-synthese):hover { + &: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 36eb469fd..d53539048 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -32,15 +32,15 @@ module Instructeurs @all_dossiers_counts = {} @all_dossiers_counts['à suivre'] = dossiers.without_followers.en_cours.count - @all_dossiers_counts['suivi'] = current_instructeur + @all_dossiers_counts['suivis'] = 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 + @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 diff --git a/app/views/instructeurs/procedures/_synthese.html.haml b/app/views/instructeurs/procedures/_synthese.html.haml index 43cdab495..5724eba3c 100644 --- a/app/views/instructeurs/procedures/_synthese.html.haml +++ b/app/views/instructeurs/procedures/_synthese.html.haml @@ -1,11 +1,6 @@ -.tab-title - Synthèse des dossiers - .procedure-list.synthese - %ul.procedure-stats.flex +- if procedures.length > 1 + .tab-title + %span + Synthèse des dossiers - 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 + %span.badge.procedure-synthese-badge= number_with_html_delimiter(dossier_count) + ' ' + label diff --git a/app/views/instructeurs/procedures/index.html.haml b/app/views/instructeurs/procedures/index.html.haml index 84c81ed1b..d2275f38b 100644 --- a/app/views/instructeurs/procedures/index.html.haml +++ b/app/views/instructeurs/procedures/index.html.haml @@ -2,7 +2,7 @@ .container %h1.page-title Démarches - = render partial: 'instructeurs/procedures/synthese', locals: { all_dossiers_counts: @all_dossiers_counts } + = 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, diff --git a/spec/controllers/instructeurs/procedures_controller_spec.rb b/spec/controllers/instructeurs/procedures_controller_spec.rb index e218002c1..d32d7dffa 100644 --- a/spec/controllers/instructeurs/procedures_controller_spec.rb +++ b/spec/controllers/instructeurs/procedures_controller_spec.rb @@ -136,10 +136,10 @@ describe Instructeurs::ProceduresController, type: :controller do 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) } + 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 @@ -172,10 +172,10 @@ describe Instructeurs::ProceduresController, type: :controller do 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) } + 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 @@ -212,10 +212,10 @@ describe Instructeurs::ProceduresController, type: :controller do 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) } + 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 @@ -233,10 +233,10 @@ describe Instructeurs::ProceduresController, type: :controller do 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) } + 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 diff --git a/spec/features/routing/full_scenario_spec.rb b/spec/features/routing/full_scenario_spec.rb index 40a2cd6dd..08c913e0b 100644 --- a/spec/features/routing/full_scenario_spec.rb +++ b/spec/features/routing/full_scenario_spec.rb @@ -122,9 +122,7 @@ feature 'The routing', js: true do ## on the procedures list expect(page).to have_current_path(instructeur_procedures_path) - within find('.procedure-details') do - expect(find('.procedure-stats')).to have_css('span.notifications') - end + expect(find('.procedure-stats')).to have_css('span.notifications') ## on the dossiers list click_on procedure.libelle @@ -144,9 +142,7 @@ feature 'The routing', js: true do sign_in_with marie.user.email, password expect(page).to have_current_path(instructeur_procedures_path) - within find('.procedure-details') do - expect(find('.procedure-stats')).not_to have_css('span.notifications') - end + expect(find('.procedure-stats')).not_to have_css('span.notifications') log_out # the instructeurs who belong to scientifique AND litteraire groups manage scientifique and litterraire dossiers @@ -172,9 +168,7 @@ feature 'The routing', js: true do sign_in_with superwoman.user.email, password expect(page).to have_current_path(instructeur_procedures_path) - within find('.procedure-details') do - expect(find('.procedure-stats')).to have_css('span.notifications') - end + expect(find('.procedure-stats')).to have_css('span.notifications') 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 index c103766b8..a5b743857 100644 --- a/spec/views/instructeur/procedures/_synthese.html.haml_spec.rb +++ b/spec/views/instructeur/procedures/_synthese.html.haml_spec.rb @@ -3,23 +3,45 @@ describe 'instructeurs/procedures/_synthese.html.haml', type: :view do 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 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] + } - 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é') } + 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