From ad1250af6f0fb815483dfb2836cfb05d460733e9 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 9 Mar 2017 16:55:47 +0100 Subject: [PATCH 1/2] Add confirm popup on important actions --- app/views/dossiers/_invites.html.haml | 2 +- ...ckoffice_dossierscontroller_show.html.haml | 26 ++++++++++--------- ...ckoffice_dossierscontroller_show.html.haml | 2 +- ...ers_recapitulatifcontroller_show.html.haml | 2 +- ...backoffice_dossierscontroller_show_spec.rb | 6 ++--- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/views/dossiers/_invites.html.haml b/app/views/dossiers/_invites.html.haml index 345760df0..a84af7849 100644 --- a/app/views/dossiers/_invites.html.haml +++ b/app/views/dossiers/_invites.html.haml @@ -14,5 +14,5 @@ .col-xs-3 = form_tag invites_dossier_path(dossier_id: @facade.dossier.id), method: :post, class: 'form-inline' do = text_field_tag :email, '', class: 'form-control', placeholder: 'Envoyer une invitation' - = submit_tag 'Ajouter', class: 'btn btn-success', id: 'send-invitation' + = submit_tag 'Ajouter', class: 'btn btn-success', id: 'send-invitation', data: {confirm: "Envoyer l'invitation ?"} diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml index 5868e5ae8..9c8748b5b 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml @@ -5,19 +5,21 @@ #action-block - if gestionnaire_signed_in? - if !@facade.dossier.read_only? || @facade.dossier.initiated? - = link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block' + = link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block', data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } - elsif @facade.dossier.received? - = form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Accepter') do - %button.action.close-dossier - %i.fa.fa-check - = form_tag(url_for({controller: 'backoffice/dossiers', action: :without_continuation, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Classer sans suite') do - %button.action.forget-dossier - %i.fa.fa-circle-o - = form_tag(url_for({controller: 'backoffice/dossiers', action: :refuse, dossier_id: @facade.dossier.id}), class: 'form-inline action_button', method: 'POST', style: 'display:inline', 'data-toggle' => :tooltip, title: 'Refuser') do - %button.action.refuse-dossier - %i.fa.fa-times - = link_to 'Reouvrir', backoffice_dossier_reopen_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block' + %ul.list-inline + %li + = link_to url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'btn btn-success', method: :post, title: 'Accepter', data: { toggle: :tooltip, confirm: "Accepter ce dossier ?" } do + %i.fa.fa-check + %li + = link_to url_for({controller: 'backoffice/dossiers', action: :without_continuation, dossier_id: @facade.dossier.id}), class: 'btn btn-warning', method: :post, title: 'Classer sans suite', data: { toggle: :tooltip, confirm: "Classer sans suite ce dossier ?" } do + %i.fa.fa-circle-o + %li + = link_to url_for({controller: 'backoffice/dossiers', action: :refuse, dossier_id: @facade.dossier.id}), class: 'btn btn-danger', method: :post, title: 'Refuser', data: { toggle: :tooltip, confirm: "Refuser ce dossier ?" } do + %i.fa.fa-times + + = link_to 'Reouvrir', backoffice_dossier_reopen_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block', data: { confirm: "Confirmer vous la réouverture de ce dossier ?" } %hr - if @facade.dossier.archived? @@ -26,7 +28,7 @@ = link_to 'Désarchiver', unarchive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block' - else - = link_to 'Archiver', archive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block' + = link_to 'Archiver', archive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block', data: { confirm: "Confirmer vous l'archivage de ce dossier ?" } diff --git a/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml index bcf5694b2..d6c9f218f 100644 --- a/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml +++ b/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml @@ -38,4 +38,4 @@ %li = form_tag invites_dossier_path(dossier_id: @facade.dossier.id), method: :post, class: 'form-inline', id: 'send-invitation' do = text_field_tag :email, '', class: 'form-control', placeholder: 'Envoyer une invitation', id: 'invitation-email' - = submit_tag 'Ajouter', class: 'btn btn-success' + = submit_tag 'Ajouter', class: 'btn btn-success', data: {confirm: "Envoyer l'invitation ?"} diff --git a/app/views/layouts/navbars/_navbar_users_recapitulatifcontroller_show.html.haml b/app/views/layouts/navbars/_navbar_users_recapitulatifcontroller_show.html.haml index 7a5f4299b..6be6d4927 100644 --- a/app/views/layouts/navbars/_navbar_users_recapitulatifcontroller_show.html.haml +++ b/app/views/layouts/navbars/_navbar_users_recapitulatifcontroller_show.html.haml @@ -28,4 +28,4 @@ %li = form_tag invites_dossier_path(dossier_id: @facade.dossier.id), method: :post, class: 'form-inline', id: 'send-invitation' do = text_field_tag :email, '', class: 'form-control', placeholder: 'Envoyer une invitation', id: 'invitation-email' - = submit_tag 'Ajouter', class: 'btn btn-success' + = submit_tag 'Ajouter', class: 'btn btn-success', data: {confirm: "Envoyer l'invitation ?"} diff --git a/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb b/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb index fc7322a97..53be1ef91 100644 --- a/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb +++ b/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb @@ -75,9 +75,9 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm it { expect(rendered).to have_content('En instruction') } it 'button accepter / refuser / classer sans suite are present' do - expect(rendered).to have_css('form[data-toggle="tooltip"][title="Accepter"]') - expect(rendered).to have_css('form[data-toggle="tooltip"][title="Classer sans suite"]') - expect(rendered).to have_css('form[data-toggle="tooltip"][title="Refuser"]') + expect(rendered).to have_css('a[title="Accepter"]') + expect(rendered).to have_css('a[title="Classer sans suite"]') + expect(rendered).to have_css('a[title="Refuser"]') end end From fc9ef92c374e1f480f238642b21fb4c094c1268b Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 13 Mar 2017 10:27:19 +0100 Subject: [PATCH 2/2] Destroy emails with procedure --- app/models/procedure.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 947499b30..304c459dc 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -39,7 +39,7 @@ class Procedure < ActiveRecord::Base MAIL_TEMPLATE_TYPES = %w(InitiatedMail ReceivedMail ClosedMail RefusedMail WithoutContinuationMail) MAIL_TEMPLATE_TYPES.each do |name| - has_one "#{name.underscore}".to_sym, class_name: "Mails::#{name}" + has_one "#{name.underscore}".to_sym, class_name: "Mails::#{name}", dependent: :destroy define_method("#{name.underscore}_with_override") do self.send("#{name.underscore}_without_override") || Object.const_get("Mails::#{name}").default end