From e613815ac6229da15970a659e9236b7abd230cda Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 24 Jul 2018 16:58:03 +0200 Subject: [PATCH 1/9] mailer: remove last mention of TPS --- .../notification_mailer/closed_mail_with_attestation.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/notification_mailer/closed_mail_with_attestation.html.haml b/app/views/notification_mailer/closed_mail_with_attestation.html.haml index 2cec1ca59..e1851d5db 100644 --- a/app/views/notification_mailer/closed_mail_with_attestation.html.haml +++ b/app/views/notification_mailer/closed_mail_with_attestation.html.haml @@ -14,7 +14,7 @@ Bonne journée, %p - L'équipe demarches-simplifiees.fr (anciennement Téléprocédures Simplifiées) + L'équipe demarches-simplifiees.fr %p — From 07be63b48ea1006812c4bd70f6a5dd9152664f0f Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 24 Jul 2018 17:43:07 +0200 Subject: [PATCH 2/9] patron: add missing button styles --- app/views/root/patron.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index e2d3e5ad7..5b3405a76 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -49,7 +49,6 @@ = link_to ".button.secondary", "#", class: "button secondary" - = link_to ".button.accepted", "#", class: "button accepted" = link_to "#", class: "button" do %span.icon.follow @@ -58,6 +57,13 @@ = link_to "#", class: "button icon-only" do %span.icon.follow + %p + = link_to ".button.accepted", "#", class: "button accepted" + + = link_to ".button.refused", "#", class: "button refused" + + = link_to ".button.without-continuation", "#", class: "button without-continuation" + %p = link_to ".button.large", "#", class: "button large" From 768537fedc7602516276ede27ee2e0a30b4c0e7d Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 24 Jul 2018 18:25:10 +0200 Subject: [PATCH 3/9] buttons: center text also on link styled as buttons --- app/assets/stylesheets/new_design/buttons.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index 78be9682c..ca4d53c6b 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -11,6 +11,7 @@ background-color: #FFFFFF; color: $black; cursor: pointer; + text-align: center; -webkit-appearance: none; &:hover { From 0f1811dd4ed206c7fec7790f8e023f35dd90bce0 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 24 Jul 2018 15:43:28 +0000 Subject: [PATCH 4/9] dossier: add an button to delete a brouillon --- app/assets/stylesheets/new_design/buttons.scss | 12 ++++++++++++ app/assets/stylesheets/new_design/forms.scss | 3 +++ app/views/root/patron.html.haml | 1 + app/views/shared/dossiers/_edit.html.haml | 9 ++++++++- spec/features/new_user/dossier_spec.rb | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index ca4d53c6b..1fe64d228 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -45,6 +45,18 @@ } } + &.danger { + color: $black; + border-color: $border-grey; + background-color: #FFFFFF; + + &:hover { + color: #FFFFFF; + border-color: $medium-red; + background-color: $medium-red; + } + } + &.accepted { color: #FFFFFF; border-color: $green; diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index ba7b16d39..470e78524 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -288,6 +288,9 @@ .button { margin-bottom: 0; } + .button.danger { + float:left; + } } .inline-champ { diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 5b3405a76..be5252fce 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -49,6 +49,7 @@ = link_to ".button.secondary", "#", class: "button secondary" + = link_to ".button.danger", "#", class: "button danger" = link_to "#", class: "button" do %span.icon.follow diff --git a/app/views/shared/dossiers/_edit.html.haml b/app/views/shared/dossiers/_edit.html.haml index c975b16d2..eaf3e6c18 100644 --- a/app/views/shared/dossiers/_edit.html.haml +++ b/app/views/shared/dossiers/_edit.html.haml @@ -62,9 +62,16 @@ = hidden_field_tag 'submit_action', 'draft' - if dossier.brouillon? + - if current_user.owns?(dossier) + = link_to ask_deletion_dossier_path(dossier), + method: :post, + class: 'button danger', + data: { confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" } do + Supprimer le brouillon + = f.button 'Enregistrer le brouillon', formnovalidate: true, - class: 'button send', + class: 'button send secondary', data: { action: 'draft', disable_with: 'Envoi...' } - if current_user.owns?(dossier) && dossier.can_transition_to_en_construction? diff --git a/spec/features/new_user/dossier_spec.rb b/spec/features/new_user/dossier_spec.rb index 26acaa12d..4b8100e65 100644 --- a/spec/features/new_user/dossier_spec.rb +++ b/spec/features/new_user/dossier_spec.rb @@ -112,6 +112,20 @@ feature 'The user' do expect(page).to have_current_path(merci_dossier_path(user_dossier)) end + scenario 'delete a draft', js: true do + log_in(user.email, password, simple_procedure) + fill_individual + + page.accept_alert('Confirmer la suppression ?') do + click_on 'Supprimer le brouillon' + end + + expect(page).to have_current_path(dossiers_path) + expect(page).to have_text('Votre dossier a bien été supprimé') + expect(page).not_to have_text(user_dossier.procedure.libelle) + expect(user_dossier.reload.hidden_at).to be_present + end + private def log_in(email, password, procedure) From 547c36243d09aa26ffceab3b212df552c9ace403 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 24 Jul 2018 18:10:00 +0200 Subject: [PATCH 5/9] dossier: add responsive layout for action buttons --- app/assets/stylesheets/new_design/forms.scss | 36 +++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index 470e78524..5322c2f90 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -281,15 +281,43 @@ } .send-wrapper { - text-align: right; - margin-top: 2 * $default-padding; + display: flex; + width: 100%; + justify-content: flex-end; + margin-top: $default-padding; margin-bottom: 2 * $default-padding; .button { + margin-top: $default-padding; margin-bottom: 0; } - .button.danger { - float:left; + + // Wide layout: align buttons on a single row + @media (min-width: 550px) { + flex-direction: row; + + .button:not(:first-of-type) { + margin-left: $default-spacer; + } + + .button.danger { + margin-right: auto; + } + } + + // Narrow layout: stack buttons vertically + @media (max-width: 550px) { + flex-direction: column-reverse; + align-items: center; + + .button, + .button.danger { + width: 100%; + max-width: 350px; + line-height: 30px; + margin-left: none; + margin-right: none; + } } } From 6daa31d410632ac85ac308dad5a76f5268f175c9 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 23 Jul 2018 12:44:42 +0000 Subject: [PATCH 6/9] spec: add tests for Dossier#delete_and_keep_track --- spec/models/dossier_spec.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 829009f61..b6106cca8 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -806,6 +806,34 @@ describe Dossier do end end + describe "#delete_and_keep_track" do + let(:dossier) { create(:dossier) } + let(:deleted_dossier) { DeletedDossier.find_by!(dossier_id: dossier.id) } + + before do + allow(DossierMailer).to receive(:notify_deletion_to_user).and_return(double(deliver_later: nil)) + allow(DossierMailer).to receive(:notify_deletion_to_administration).and_return(double(deliver_later: nil)) + end + + subject! { dossier.delete_and_keep_track } + + it 'hides the dossier' do + expect(dossier.hidden_at).to be_present + end + + it 'creates a DeletedDossier record' do + expect(deleted_dossier.dossier_id).to eq dossier.id + expect(deleted_dossier.procedure).to eq dossier.procedure + expect(deleted_dossier.state).to eq dossier.state + expect(deleted_dossier.deleted_at).to be_present + end + + it 'sends notification emails' do + expect(DossierMailer).to have_received(:notify_deletion_to_user).with(deleted_dossier, dossier.user.email) + expect(DossierMailer).to have_received(:notify_deletion_to_administration).with(deleted_dossier, dossier.procedure.administrateur.email) + end + end + describe 'webhook' do let(:dossier) { create(:dossier) } From 13182ad291f0796e0d5bf47f50ae177067e845cd Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 23 Jul 2018 13:06:06 +0000 Subject: [PATCH 7/9] dossier: send deletion email also to the following gestionnaires --- app/models/dossier.rb | 6 +++++- spec/models/dossier_spec.rb | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 1cf543a63..f91a0e245 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -276,8 +276,12 @@ class Dossier < ApplicationRecord now = Time.now deleted_dossier = DeletedDossier.create!(dossier_id: id, procedure: procedure, state: state, deleted_at: now) update(hidden_at: now) + + administration_emails = followers_gestionnaires.present? ? followers_gestionnaires.pluck(:email) : [procedure.administrateur.email] + administration_emails.each do |email| + DossierMailer.notify_deletion_to_administration(deleted_dossier, email).deliver_later + end DossierMailer.notify_deletion_to_user(deleted_dossier, user.email).deliver_later - DossierMailer.notify_deletion_to_administration(deleted_dossier, procedure.administrateur.email).deliver_later end private diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index b6106cca8..dc7bc7999 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -828,9 +828,29 @@ describe Dossier do expect(deleted_dossier.deleted_at).to be_present end - it 'sends notification emails' do + it 'notifies the user' do expect(DossierMailer).to have_received(:notify_deletion_to_user).with(deleted_dossier, dossier.user.email) - expect(DossierMailer).to have_received(:notify_deletion_to_administration).with(deleted_dossier, dossier.procedure.administrateur.email) + end + + context 'where gestionnaires are following the dossier' do + let(:dossier) { create(:dossier, :followed) } + let!(:non_following_gestionnaire) do + non_following_gestionnaire = create(:gestionnaire) + non_following_gestionnaire.procedures << dossier.procedure + non_following_gestionnaire + end + + it 'notifies the following gestionnaires' do + expect(DossierMailer).to have_received(:notify_deletion_to_administration).once + expect(DossierMailer).to have_received(:notify_deletion_to_administration).with(deleted_dossier, dossier.followers_gestionnaires.first.email) + end + end + + context 'when there are no following gestionnaires' do + it 'notifies the procedure administrateur' do + expect(DossierMailer).to have_received(:notify_deletion_to_administration).once + expect(DossierMailer).to have_received(:notify_deletion_to_administration).with(deleted_dossier, dossier.procedure.administrateur.email) + end end end From c3de45307d93c8ef6dff267805dd4bc039b03a77 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 25 Jul 2018 13:48:29 +0200 Subject: [PATCH 8/9] =?UTF-8?q?dossiers:=20rename=20"=C3=89diter"=20to=20"?= =?UTF-8?q?Modifier"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Éditer" is a anglicism. --- app/views/dossiers/_edit_carto.html.haml | 2 +- app/views/dossiers/_edit_dossier.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/dossiers/_edit_carto.html.haml b/app/views/dossiers/_edit_carto.html.haml index d0f57a8a9..fc7dff7e5 100644 --- a/app/views/dossiers/_edit_carto.html.haml +++ b/app/views/dossiers/_edit_carto.html.haml @@ -2,4 +2,4 @@ - if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier)) %a#maj_carte.action{ href: "/users/dossiers/#{@facade.dossier.id}/carte" } .col-lg-2.col-md-2.col-sm-2.col-xs-2.action - = 'ÉDITER' + = 'MODIFIER' diff --git a/app/views/dossiers/_edit_dossier.html.haml b/app/views/dossiers/_edit_dossier.html.haml index ecbed3cca..4f442527c 100644 --- a/app/views/dossiers/_edit_dossier.html.haml +++ b/app/views/dossiers/_edit_dossier.html.haml @@ -2,4 +2,4 @@ - if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier)) = link_to modifier_dossier_path(@facade.dossier), class: 'action', id: 'maj_infos' do #edit-dossier.col-lg-2.col-md-2.col-sm-2.col-xs-2.action - = "ÉDITER" + = "MODIFIER" From abbd4e3c6927bd765d3484a0fde05d4624155384 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 19 Jul 2018 15:29:06 +0200 Subject: [PATCH 9/9] [Fix #2277] Do not crash when creating a service with invalid data --- app/controllers/new_administrateur/services_controller.rb | 2 ++ .../new_administrateur/services_controller_spec.rb | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/new_administrateur/services_controller.rb b/app/controllers/new_administrateur/services_controller.rb index 9e5d682a4..a969da1b3 100644 --- a/app/controllers/new_administrateur/services_controller.rb +++ b/app/controllers/new_administrateur/services_controller.rb @@ -17,6 +17,7 @@ module NewAdministrateur redirect_to services_path(procedure_id: params[:procedure_id]), notice: "#{new_service.nom} créé" else + @procedure = procedure flash[:alert] = new_service.errors.full_messages render :new end @@ -34,6 +35,7 @@ module NewAdministrateur redirect_to services_path(procedure_id: params[:procedure_id]), notice: "#{@service.nom} modifié" else + @procedure = procedure flash[:alert] = @service.errors.full_messages render :edit end diff --git a/spec/controllers/new_administrateur/services_controller_spec.rb b/spec/controllers/new_administrateur/services_controller_spec.rb index 8bf213f79..3a2c4866b 100644 --- a/spec/controllers/new_administrateur/services_controller_spec.rb +++ b/spec/controllers/new_administrateur/services_controller_spec.rb @@ -1,5 +1,6 @@ describe NewAdministrateur::ServicesController, type: :controller do let(:admin) { create(:administrateur) } + let(:procedure) { create(:procedure, administrateur: admin) } describe '#create' do before do @@ -38,7 +39,7 @@ describe NewAdministrateur::ServicesController, type: :controller do end context 'when submitting an invalid service' do - let(:params) { { service: { nom: 'super service' } } } + let(:params) { { service: { nom: 'super service' }, procedure_id: procedure.id } } it { expect(flash.alert).not_to be_nil } it { expect(response).to render_template(:new) } @@ -54,7 +55,7 @@ describe NewAdministrateur::ServicesController, type: :controller do params = { id: service.id, service: service_params, - procedure_id: 12 + procedure_id: procedure.id } patch :update, params: params end @@ -64,7 +65,7 @@ describe NewAdministrateur::ServicesController, type: :controller do it { expect(flash.notice).to eq('nom modifié') } it { expect(Service.last.nom).to eq('nom') } it { expect(Service.last.type_organisme).to eq('region') } - it { expect(response).to redirect_to(services_path(procedure_id: 12)) } + it { expect(response).to redirect_to(services_path(procedure_id: procedure.id)) } end context 'when updating a service with invalid data' do