From 1def444d0fff9643ad4313698c5096ab7f0a6222 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 11 Sep 2018 16:02:09 +0200 Subject: [PATCH 1/7] Do not add an empty ul to the DOM --- app/views/new_user/dossiers/_footer.html.haml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/views/new_user/dossiers/_footer.html.haml b/app/views/new_user/dossiers/_footer.html.haml index bf760ac11..7e88c27a2 100644 --- a/app/views/new_user/dossiers/_footer.html.haml +++ b/app/views/new_user/dossiers/_footer.html.haml @@ -1,9 +1,8 @@ %footer.dossier-footer .container - %ul.footer-columns - - - service = dossier.procedure.service - - if service.present? + - service = dossier.procedure.service + - if service.present? + %ul.footer-columns %li.footer-column %h3.footer-header Cette démarche est gérée par : %p @@ -29,12 +28,12 @@ %p Horaires : #{ service.horaires.sub(/\S/, &:downcase) } - - politiques = politiques_conservation_de_donnees(dossier.procedure) - - if politiques.present? - %li.footer-column - %h3.footer-header Conservation des données : - - politiques.each do |politique| - %p= politique + - politiques = politiques_conservation_de_donnees(dossier.procedure) + - if politiques.present? + %li.footer-column + %h3.footer-header Conservation des données : + - politiques.each do |politique| + %p= politique .footer-bottom-line = link_to "Accessibilité", accessibilite_index_path, :class => "footer-link" From 61c41fa9cbaef2ba1f3018eeee54b414d3a2f6e9 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 11 Sep 2018 16:28:08 +0200 Subject: [PATCH 2/7] Lower the footer inner padding --- app/assets/stylesheets/new_design/new_footer.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/new_footer.scss b/app/assets/stylesheets/new_design/new_footer.scss index 502875b70..4398d1a6b 100644 --- a/app/assets/stylesheets/new_design/new_footer.scss +++ b/app/assets/stylesheets/new_design/new_footer.scss @@ -15,7 +15,7 @@ footer { } .dossier-footer { - @include vertical-padding(48px); + @include vertical-padding(30px); line-height: 24px; } From 04c5667b92a51698f21c2b3f3d8d562b91541e95 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 11 Sep 2018 16:30:15 +0200 Subject: [PATCH 3/7] For footer columns, keep the same bottom margin at any width --- app/assets/stylesheets/new_design/new_footer.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/new_footer.scss b/app/assets/stylesheets/new_design/new_footer.scss index 4398d1a6b..523925e7e 100644 --- a/app/assets/stylesheets/new_design/new_footer.scss +++ b/app/assets/stylesheets/new_design/new_footer.scss @@ -36,7 +36,6 @@ footer { @media (max-width: 1000px) { width: 100%; - margin-bottom: 14px; } } From fc470e9c71bd32a8c5203868f94f3ac906ca3d58 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 11 Sep 2018 16:30:54 +0200 Subject: [PATCH 4/7] Fix some spacing issues in the footer --- .../stylesheets/new_design/new_footer.scss | 23 +++++++++++++++---- app/views/new_user/dossiers/_footer.html.haml | 4 ++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/new_design/new_footer.scss b/app/assets/stylesheets/new_design/new_footer.scss index 523925e7e..b17ff187d 100644 --- a/app/assets/stylesheets/new_design/new_footer.scss +++ b/app/assets/stylesheets/new_design/new_footer.scss @@ -32,9 +32,9 @@ footer { flex-grow: 1; min-width: 280px; margin: 0 20px; - margin-bottom: 20px; + margin-bottom: 30px; - @media (max-width: 1000px) { + @media (max-width: 550px) { width: 100%; } } @@ -97,8 +97,23 @@ footer { } .footer-bottom-line { - margin-top: 30px; - margin-bottom: -30px; text-align: center; font-size: small; + + @media (max-width: 550px) { + text-align: left; + } +} + +.footer-row { + margin-bottom: 30px; + + &:last-child { + margin-bottom: 0; + } + + // In this case, the bottom margin is defined directly on each individual column + &.footer-columns { + margin-bottom: 0; + } } diff --git a/app/views/new_user/dossiers/_footer.html.haml b/app/views/new_user/dossiers/_footer.html.haml index 7e88c27a2..95c0aa129 100644 --- a/app/views/new_user/dossiers/_footer.html.haml +++ b/app/views/new_user/dossiers/_footer.html.haml @@ -2,7 +2,7 @@ .container - service = dossier.procedure.service - if service.present? - %ul.footer-columns + %ul.footer-row.footer-columns %li.footer-column %h3.footer-header Cette démarche est gérée par : %p @@ -35,7 +35,7 @@ - politiques.each do |politique| %p= politique - .footer-bottom-line + .footer-row.footer-bottom-line = link_to "Accessibilité", accessibilite_index_path, :class => "footer-link" – = link_to "CGU", CGU_URL, :class => "footer-link", :target => "_blank", rel: "noopener noreferrer" From 523edac4c5176e2fbef82e374765edd5948dab19 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 10 Sep 2018 17:52:29 +0200 Subject: [PATCH 5/7] Scope the select2 config call --- app/javascript/new_design/select2.js | 2 +- app/views/new_gestionnaire/procedures/show.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/new_design/select2.js b/app/javascript/new_design/select2.js index 78d1f9023..268e47225 100644 --- a/app/javascript/new_design/select2.js +++ b/app/javascript/new_design/select2.js @@ -7,7 +7,7 @@ addEventListener('turbolinks:load', () => { width: '100%' }); - $('select.select2-limited').select2({ + $('.columns-form select.select2-limited').select2({ language: 'fr', placeholder: 'Sélectionnez des colonnes', maximumSelectionLength: '5', diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index ce6b9e971..2626e3cdb 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -81,7 +81,7 @@ %span.button.dropdown Personnaliser .dropdown-content.fade-in-down - = form_tag update_displayed_fields_gestionnaire_procedure_path(@procedure), method: :patch, class: 'dropdown-form' do + = form_tag update_displayed_fields_gestionnaire_procedure_path(@procedure), method: :patch, class: 'dropdown-form columns-form' do = select_tag :values, options_for_select(@procedure.fields_for_select, selected: @displayed_fields_values), From f8a6765367431df8b133d2c0efd960243fc751bb Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 10 Sep 2018 17:52:49 +0200 Subject: [PATCH 6/7] [Fix #2540] Allow an instructeur to send a dossier to several instructeurs --- .../new_design/personnes_impliquees.scss | 6 +++++ .../new_gestionnaire/dossiers_controller.rb | 10 ++++--- app/javascript/new_design/select2.js | 7 +++++ .../dossiers/_envoyer_dossier_block.html.haml | 10 ++++--- config/routes.rb | 2 +- .../dossiers_controller_spec.rb | 6 ++--- .../new_gestionnaire/gestionnaire_spec.rb | 26 +++++++++++++++++++ 7 files changed, 57 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/new_design/personnes_impliquees.scss b/app/assets/stylesheets/new_design/personnes_impliquees.scss index 80c227495..ac908f538 100644 --- a/app/assets/stylesheets/new_design/personnes_impliquees.scss +++ b/app/assets/stylesheets/new_design/personnes_impliquees.scss @@ -5,4 +5,10 @@ list-style-type: disc; margin-left: 16px; } + + // scss-lint:disable SelectorFormat + .form .select2-container .select2-selection__rendered { + padding: 12px; + } + // scss-lint:enable } diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index b23359872..76950e5a4 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -37,9 +37,13 @@ module NewGestionnaire @potential_recipients = procedure.gestionnaires.reject { |g| g == current_gestionnaire } end - def envoyer_a_instructeur - recipient = Gestionnaire.find(params[:recipient]) - GestionnaireMailer.send_dossier(current_gestionnaire, dossier, recipient).deliver_later + def send_to_instructeurs + recipients = Gestionnaire.find(params[:recipients]) + + recipients.each do |recipient| + GestionnaireMailer.send_dossier(current_gestionnaire, dossier, recipient).deliver_later + end + flash.notice = "Dossier envoyé" redirect_to(personnes_impliquees_gestionnaire_dossier_path(procedure, dossier)) end diff --git a/app/javascript/new_design/select2.js b/app/javascript/new_design/select2.js index 268e47225..ccd14b117 100644 --- a/app/javascript/new_design/select2.js +++ b/app/javascript/new_design/select2.js @@ -13,4 +13,11 @@ addEventListener('turbolinks:load', () => { maximumSelectionLength: '5', width: '300px' }); + + $('.recipients-form select.select2-limited').select2({ + language: 'fr', + placeholder: 'Sélectionnez des instructeurs', + maximumSelectionLength: '30', + width: '300px' + }); }); diff --git a/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml b/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml index 0fead70e5..20fccfb17 100644 --- a/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml +++ b/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml @@ -4,7 +4,11 @@ %p.tab-paragraph Vous êtes le seul instructeur assigné sur cette démarche - else - = form_for dossier, url: envoyer_a_instructeur_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form' } do |f| - .flex.justify-start.align-baseline - = select_tag(:recipient, options_from_collection_for_select(potential_recipients, :id, :email)) + = form_for dossier, url: send_to_instructeurs_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form recipients-form' } do |f| + .flex.justify-start.align-start + = select_tag(:recipients, + options_from_collection_for_select(potential_recipients, :id, :email), + multiple: true, + class: 'select2-limited', + placeholder: '') = f.submit "Envoyer", class: "button large send gap-left" diff --git a/config/routes.rb b/config/routes.rb index 78a27debe..19adc8ed6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -322,7 +322,7 @@ Rails.application.routes.draw do post 'passer-en-instruction' => 'dossiers#passer_en_instruction' post 'repasser-en-construction' => 'dossiers#repasser_en_construction' post 'terminer' - post 'envoyer-a-instructeur' => 'dossiers#envoyer_a_instructeur' + post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs' scope :carte do get 'position' end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 570a63cb9..65a0e2255 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -31,7 +31,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end end - describe '#envoyer_a_instructeur' do + describe '#send_to_instructeurs' do let(:recipient) { create(:gestionnaire) } let(:gestionnaires) { [gestionnaire, recipient] } let(:mail) { double("mail") } @@ -45,9 +45,9 @@ describe NewGestionnaire::DossiersController, type: :controller do .and_return(mail) post( - :envoyer_a_instructeur, + :send_to_instructeurs, params: { - recipient: recipient, + recipients: [recipient], procedure_id: procedure.id, dossier_id: dossier.id } diff --git a/spec/features/new_gestionnaire/gestionnaire_spec.rb b/spec/features/new_gestionnaire/gestionnaire_spec.rb index 24c5375ca..94826ca91 100644 --- a/spec/features/new_gestionnaire/gestionnaire_spec.rb +++ b/spec/features/new_gestionnaire/gestionnaire_spec.rb @@ -134,6 +134,32 @@ feature 'The gestionnaire part' do expect(page).to have_text(gestionnaire2.email) end + scenario 'A gestionnaire can send a dossier to several instructeurs', js: true do + instructeur_2 = FactoryBot.create(:gestionnaire) + instructeur_3 = FactoryBot.create(:gestionnaire) + procedure.gestionnaires << [instructeur_2, instructeur_3] + + send_dossier = double() + expect(GestionnaireMailer).to receive(:send_dossier).and_return(send_dossier).twice + expect(send_dossier).to receive(:deliver_later).twice + + log_in(gestionnaire.email, password) + + click_on procedure.libelle + click_on dossier.user.email + + click_on 'Personnes impliquées' + + first('.select2-container', minimum: 1).click + find('li.select2-results__option[role="treeitem"]', text: instructeur_2.email).click + first('.select2-container', minimum: 1).click + find('li.select2-results__option[role="treeitem"]', text: instructeur_3.email).click + + click_on 'Envoyer' + + expect(page).to have_text("Dossier envoyé") + end + def log_in(email, password) visit '/' click_on 'Connexion' From c1bec7cf0b4a5cafd5f82e5483cafa6842390599 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 11 Sep 2018 17:32:08 +0200 Subject: [PATCH 7/7] Pass the connected_user object instead of its email --- app/views/new_gestionnaire/avis/messagerie.html.haml | 2 +- app/views/new_gestionnaire/dossiers/messagerie.html.haml | 2 +- app/views/new_gestionnaire/dossiers/print.html.haml | 2 +- app/views/new_user/dossiers/messagerie.html.haml | 2 +- app/views/shared/dossiers/_messagerie.html.haml | 4 ++-- app/views/shared/dossiers/messages/_message.html.haml | 4 ++-- app/views/shared/dossiers/messages/_message_icon.html.haml | 2 +- app/views/shared/dossiers/messages/_message_issuer.html.haml | 2 +- spec/views/shared/dossiers/messages/message.html.haml_spec.rb | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/new_gestionnaire/avis/messagerie.html.haml b/app/views/new_gestionnaire/avis/messagerie.html.haml index 9bea14b67..0847cb19d 100644 --- a/app/views/new_gestionnaire/avis/messagerie.html.haml +++ b/app/views/new_gestionnaire/avis/messagerie.html.haml @@ -2,4 +2,4 @@ = render partial: 'header', locals: { avis: @avis, dossier: @dossier } -= render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, user_email: current_gestionnaire.email, messagerie_seen_at: nil, new_commentaire: @commentaire, form_url: commentaire_gestionnaire_avis_path(@avis) } += render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, connected_user: current_gestionnaire, messagerie_seen_at: nil, new_commentaire: @commentaire, form_url: commentaire_gestionnaire_avis_path(@avis) } diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index e62eeae7f..096d37588 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -2,4 +2,4 @@ = render partial: "header", locals: { dossier: @dossier } -= render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, user_email: current_gestionnaire.email, messagerie_seen_at: @messagerie_seen_at , new_commentaire: @commentaire, form_url: commentaire_gestionnaire_dossier_path(@dossier.procedure, @dossier) } += render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, connected_user: current_gestionnaire, messagerie_seen_at: @messagerie_seen_at , new_commentaire: @commentaire, form_url: commentaire_gestionnaire_dossier_path(@dossier.procedure, @dossier) } diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml index dbffd5ec5..9bcb22e0d 100644 --- a/app/views/new_gestionnaire/dossiers/print.html.haml +++ b/app/views/new_gestionnaire/dossiers/print.html.haml @@ -84,7 +84,7 @@ %ul.messages-list - @dossier.commentaires.each do |commentaire| %li - = render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, user_email: current_gestionnaire.email, messagerie_seen_at: nil } + = render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: current_gestionnaire, messagerie_seen_at: nil } %script{ type: "text/javascript" } window.print(); diff --git a/app/views/new_user/dossiers/messagerie.html.haml b/app/views/new_user/dossiers/messagerie.html.haml index 964b2f663..7715042cb 100644 --- a/app/views/new_user/dossiers/messagerie.html.haml +++ b/app/views/new_user/dossiers/messagerie.html.haml @@ -7,4 +7,4 @@ %p.messagerie-explanation La messagerie vous permet de contacter l’instructeur en charge de votre dossier. - = render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, user_email: current_user.email, messagerie_seen_at: nil, new_commentaire: @commentaire, form_url: commentaire_dossier_path(@dossier) } + = render partial: "shared/dossiers/messagerie", locals: { dossier: @dossier, connected_user: current_user, messagerie_seen_at: nil, new_commentaire: @commentaire, form_url: commentaire_dossier_path(@dossier) } diff --git a/app/views/shared/dossiers/_messagerie.html.haml b/app/views/shared/dossiers/_messagerie.html.haml index ee380ee09..c67d4a174 100644 --- a/app/views/shared/dossiers/_messagerie.html.haml +++ b/app/views/shared/dossiers/_messagerie.html.haml @@ -1,7 +1,7 @@ .messagerie.container %ul.messages-list - dossier.commentaires.each do |commentaire| - %li.message{ class: commentaire_is_from_me_class(commentaire, user_email) } - = render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, user_email: user_email, messagerie_seen_at: messagerie_seen_at } + %li.message{ class: commentaire_is_from_me_class(commentaire, connected_user.email) } + = render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at } = render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url } diff --git a/app/views/shared/dossiers/messages/_message.html.haml b/app/views/shared/dossiers/messages/_message.html.haml index b49e88abb..a1b78bc9d 100644 --- a/app/views/shared/dossiers/messages/_message.html.haml +++ b/app/views/shared/dossiers/messages/_message.html.haml @@ -1,9 +1,9 @@ -= render partial: 'shared/dossiers/messages/message_icon', locals: { commentaire: commentaire, user_email: user_email } += render partial: 'shared/dossiers/messages/message_icon', locals: { commentaire: commentaire, connected_user: connected_user } .width-100 %h2 %span.mail - = render partial: 'shared/dossiers/messages/message_issuer', locals: { commentaire: commentaire, user_email: user_email } + = render partial: 'shared/dossiers/messages/message_issuer', locals: { commentaire: commentaire, connected_user: connected_user } - if commentaire_is_from_guest(commentaire) %span.guest Invité %span.date{ class: highlight_if_unseen_class(messagerie_seen_at, commentaire.created_at) } diff --git a/app/views/shared/dossiers/messages/_message_icon.html.haml b/app/views/shared/dossiers/messages/_message_icon.html.haml index bfa5d2581..cca3f3568 100644 --- a/app/views/shared/dossiers/messages/_message_icon.html.haml +++ b/app/views/shared/dossiers/messages/_message_icon.html.haml @@ -1,5 +1,5 @@ - case commentaire.email -- when user_email +- when connected_user.email = image_tag('icons/account-circle.svg', class: 'person-icon') - when OLD_CONTACT_EMAIL - when CONTACT_EMAIL diff --git a/app/views/shared/dossiers/messages/_message_issuer.html.haml b/app/views/shared/dossiers/messages/_message_issuer.html.haml index dc4f7bce0..23cb7dbfc 100644 --- a/app/views/shared/dossiers/messages/_message_issuer.html.haml +++ b/app/views/shared/dossiers/messages/_message_issuer.html.haml @@ -1,5 +1,5 @@ - case commentaire.email -- when user_email +- when connected_user.email Vous - when OLD_CONTACT_EMAIL - when CONTACT_EMAIL diff --git a/spec/views/shared/dossiers/messages/message.html.haml_spec.rb b/spec/views/shared/dossiers/messages/message.html.haml_spec.rb index c33ff269b..585e3507c 100644 --- a/spec/views/shared/dossiers/messages/message.html.haml_spec.rb +++ b/spec/views/shared/dossiers/messages/message.html.haml_spec.rb @@ -1,7 +1,7 @@ describe 'shared/dossiers/messages/message.html.haml', type: :view do before { view.extend DossierHelper } - subject { render 'shared/dossiers/messages/message.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, user_email: dossier.user.email } + subject { render 'shared/dossiers/messages/message.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, connected_user: dossier.user } let(:dossier) { create(:dossier) } let(:commentaire) { create(:commentaire, dossier: dossier) }