diff --git a/app/assets/stylesheets/new_design/dossier_edit.scss b/app/assets/stylesheets/new_design/dossier_edit.scss index b37369943..3b631c66b 100644 --- a/app/assets/stylesheets/new_design/dossier_edit.scss +++ b/app/assets/stylesheets/new_design/dossier_edit.scss @@ -38,4 +38,11 @@ flex-shrink: 0; // Display the button label on a single line } } + + .warning { + margin-bottom: 20px; + background-color: #f9b91666; + padding: 20px; + border-radius: 4px; + } } diff --git a/app/assets/stylesheets/new_design/new_footer.scss b/app/assets/stylesheets/new_design/new_footer.scss index 35966b2a4..502875b70 100644 --- a/app/assets/stylesheets/new_design/new_footer.scss +++ b/app/assets/stylesheets/new_design/new_footer.scss @@ -22,6 +22,7 @@ footer { .footer-columns { @extend %horizontal-list; justify-content: flex-start; + margin: 0 -20px; } .footer-column { @@ -29,7 +30,9 @@ footer { font-size: 14px; vertical-align: top; flex-grow: 1; - min-width: 320px; + min-width: 280px; + margin: 0 20px; + margin-bottom: 20px; @media (max-width: 1000px) { width: 100%; diff --git a/app/helpers/conservation_de_donnees_helper.rb b/app/helpers/conservation_de_donnees_helper.rb index ff1d9bfc5..35c15090a 100644 --- a/app/helpers/conservation_de_donnees_helper.rb +++ b/app/helpers/conservation_de_donnees_helper.rb @@ -7,13 +7,13 @@ module ConservationDeDonneesHelper def conservation_dans_ds(procedure) if procedure.duree_conservation_dossiers_dans_ds.present? - "dans demarches-simplifiees.fr #{procedure.duree_conservation_dossiers_dans_ds} mois après le début de l’instruction du dossier" + "Dans demarches-simplifiees.fr : #{procedure.duree_conservation_dossiers_dans_ds} mois" end end def conservation_hors_ds(procedure) if procedure.duree_conservation_dossiers_hors_ds.present? - "hors demarches-simplifiees.fr pendant #{procedure.duree_conservation_dossiers_hors_ds} mois" + "Par l’administration : #{procedure.duree_conservation_dossiers_hors_ds} mois" end end end diff --git a/app/helpers/procedure_helper.rb b/app/helpers/procedure_helper.rb index ceba04317..4b70aa452 100644 --- a/app/helpers/procedure_helper.rb +++ b/app/helpers/procedure_helper.rb @@ -21,4 +21,29 @@ module ProcedureHelper action = procedure.archivee? ? :reopen : :publish t(action, scope: [:modal, :publish, key]) end + + def dossiers_deletion_warning(procedure) + dossiers_count = procedure.dossiers.state_not_brouillon.count + brouillons_count = procedure.dossiers.state_brouillon.count + formatted_dossiers_count = nil + formatted_brouillons_count = nil + + if dossiers_count > 0 + formatted_dossiers_count = pluralize(dossiers_count, "dossier", "dossiers") + end + + if brouillons_count > 0 + formatted_brouillons_count = pluralize(brouillons_count, "brouillon", "brouillons") + end + + formatted_combination = [formatted_dossiers_count, formatted_brouillons_count] + .compact + .join(" et ") + + [ + formatted_combination, + dossiers_count + brouillons_count == 1 ? "est rattaché" : "sont rattachés", + "à cette procédure, la suppression de cette procédure entrainera également leur suppression." + ].join(" ") + end end diff --git a/app/javascript/packs/application-old.js b/app/javascript/packs/application-old.js index 7a2aa3e77..5bd38c5ea 100644 --- a/app/javascript/packs/application-old.js +++ b/app/javascript/packs/application-old.js @@ -10,6 +10,7 @@ import 'babel-polyfill'; import '../shared/sentry'; import '../shared/rails-ujs-fix'; +import '../shared/safari-11-file-xhr-workaround'; import '../shared/autocomplete'; // Start Rails helpers diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 8eebcb3a3..563e8a386 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -12,6 +12,7 @@ import 'babel-polyfill'; import '../shared/sentry'; import '../shared/rails-ujs-fix'; +import '../shared/safari-11-file-xhr-workaround'; import '../shared/autocomplete'; import '../new_design/buttons'; diff --git a/app/javascript/shared/safari-11-file-xhr-workaround.js b/app/javascript/shared/safari-11-file-xhr-workaround.js new file mode 100644 index 000000000..1cedc369e --- /dev/null +++ b/app/javascript/shared/safari-11-file-xhr-workaround.js @@ -0,0 +1,26 @@ +// iOS 11.3 Safari / macOS Safari 11.1 empty XHR bug workaround. +// This should work with every modern browser which supports ES5 (including IE9). +// https://stackoverflow.com/questions/49614091/safari-11-1-ajax-xhr-form-submission-fails-when-inputtype-file-is-empty +// https://github.com/rails/rails/issues/32440 + +document.addEventListener('ajax:before', function(e) { + let inputs = e.target.querySelectorAll('input[type="file"]:not([disabled])'); + inputs.forEach(function(input) { + if (input.files.length > 0) { + return; + } + input.setAttribute('data-safari-temp-disabled', 'true'); + input.setAttribute('disabled', ''); + }); +}); + +// You should call this by yourself when you aborted an ajax request by stopping a event in ajax:before hook. +document.addEventListener('ajax:beforeSend', function(e) { + let inputs = e.target.querySelectorAll( + 'input[type="file"][data-safari-temp-disabled]' + ); + inputs.forEach(function(input) { + input.removeAttribute('data-safari-temp-disabled'); + input.removeAttribute('disabled'); + }); +}); diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index 12c51c98b..cd5c515ff 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -109,11 +109,12 @@ .alert.alert-danger %p Attention : la suppression d’une procédure est définitive. + - dossiers_count = @procedure.dossiers.count - if dossiers_count > 0 %p - = pluralize(dossiers_count, "dossier est rattaché", "dossiers sont rattachés") - à cette procédure, la suppression de cette procédure entrainera également leur suppression. + = dossiers_deletion_warning(@procedure) + %p.text-right = link_to "J'ai compris, je supprime la procédure", hide_admin_procedure_path(@procedure), diff --git a/app/views/new_user/dossiers/_footer.html.haml b/app/views/new_user/dossiers/_footer.html.haml index a012e66ea..bf760ac11 100644 --- a/app/views/new_user/dossiers/_footer.html.haml +++ b/app/views/new_user/dossiers/_footer.html.haml @@ -29,6 +29,13 @@ %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 + .footer-bottom-line = link_to "Accessibilité", accessibilite_index_path, :class => "footer-link" – diff --git a/app/views/shared/dossiers/_edit.html.haml b/app/views/shared/dossiers/_edit.html.haml index ba27df72a..09b93fc56 100644 --- a/app/views/shared/dossiers/_edit.html.haml +++ b/app/views/shared/dossiers/_edit.html.haml @@ -32,6 +32,11 @@ .card-title Pièces jointes + .warning + Pour éviter toute erreur, nous vous conseillons de limiter la taille de chaque pièce jointe à 20 Mo, et de les ajouter une par une, en enregistrant votre + = dossier.brouillon? ? "brouillon" : "dossier" + après chaque ajout. + - tpjs.each do |tpj| .pj-input %label{ for: "piece_justificative_#{tpj.id}" } diff --git a/spec/helpers/conservation_de_donnees_helper_spec.rb b/spec/helpers/conservation_de_donnees_helper_spec.rb index 5303ffc1e..e15a59e56 100644 --- a/spec/helpers/conservation_de_donnees_helper_spec.rb +++ b/spec/helpers/conservation_de_donnees_helper_spec.rb @@ -10,21 +10,21 @@ RSpec.describe ConservationDeDonneesHelper, type: :helper do let(:dans_ds) { 3 } let(:hors_ds) { 6 } - it { is_expected.to eq([ "dans demarches-simplifiees.fr 3 mois après le début de l’instruction du dossier", "hors demarches-simplifiees.fr pendant 6 mois" ]) } + it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois", "Par l’administration : 6 mois" ]) } end context "when only in-app retention time is set" do let(:dans_ds) { 3 } let(:hors_ds) { nil } - it { is_expected.to eq([ "dans demarches-simplifiees.fr 3 mois après le début de l’instruction du dossier" ]) } + it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois" ]) } end context "when only out of app retention time is set" do let(:dans_ds) { nil } let(:hors_ds) { 6 } - it { is_expected.to eq([ "hors demarches-simplifiees.fr pendant 6 mois" ]) } + it { is_expected.to eq([ "Par l’administration : 6 mois" ]) } end context "when the retention time is not set" do diff --git a/spec/helpers/procedure_helper_spec.rb b/spec/helpers/procedure_helper_spec.rb new file mode 100644 index 000000000..d9e27e5bb --- /dev/null +++ b/spec/helpers/procedure_helper_spec.rb @@ -0,0 +1,51 @@ +RSpec.describe ProcedureHelper, type: :helper do + let(:procedure) { create(:procedure) } + + describe '#dossiers_deletion_warning' do + subject { dossiers_deletion_warning(procedure) } + + context 'with 1 submitted dossier' do + before do + dossier_1 = create(:dossier, :en_construction, procedure: procedure) + end + + it { is_expected.to eq('1 dossier est rattaché à cette procédure, la suppression de cette procédure entrainera également leur suppression.') } + end + + context 'with 2 submitted dossiers' do + before do + dossier_1 = create(:dossier, :en_construction, procedure: procedure) + dossier_2 = create(:dossier, :en_instruction, procedure: procedure) + end + + it { is_expected.to eq('2 dossiers sont rattachés à cette procédure, la suppression de cette procédure entrainera également leur suppression.') } + end + + context 'with 1 brouillon dossier' do + before do + dossier_1 = create(:dossier, procedure: procedure) + end + + it { is_expected.to eq('1 brouillon est rattaché à cette procédure, la suppression de cette procédure entrainera également leur suppression.') } + end + + context 'with 2 brouillons dossiers' do + before do + dossier_1 = create(:dossier, procedure: procedure) + dossier_2 = create(:dossier, procedure: procedure) + end + + it { is_expected.to eq('2 brouillons sont rattachés à cette procédure, la suppression de cette procédure entrainera également leur suppression.') } + end + + context 'with 2 submitted dossiers and 1 brouillon dossier' do + before do + dossier_1 = create(:dossier, :en_instruction, procedure: procedure) + dossier_2 = create(:dossier, :en_instruction, procedure: procedure) + dossier_3 = create(:dossier, procedure: procedure) + end + + it { is_expected.to eq('2 dossiers et 1 brouillon sont rattachés à cette procédure, la suppression de cette procédure entrainera également leur suppression.') } + end + end +end