From 7de608cd647c9479adc99bed8b28465a1f08f7e0 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 5 Jun 2023 14:25:51 +0200 Subject: [PATCH] add link notice on procedure presentation page and small refactor of download component --- app/assets/stylesheets/02_utils.scss | 8 -------- .../attachment/show_component/show_component.en.yml | 1 - .../attachment/show_component/show_component.fr.yml | 1 - .../show_component/show_component.html.haml | 5 +---- app/components/dsfr/download_component.rb | 8 +++++--- .../download_component/download_component.en.yml | 2 ++ .../download_component/download_component.fr.yml | 2 ++ .../download_component/download_component.html.haml | 8 +++++++- .../shared/_piece_justificative_template.html.haml | 8 +------- app/views/shared/_procedure_description.html.haml | 4 ++++ app/views/shared/dossiers/_edit.html.haml | 13 +------------ config/locales/en.yml | 2 -- config/locales/fr.yml | 2 -- 13 files changed, 23 insertions(+), 41 deletions(-) diff --git a/app/assets/stylesheets/02_utils.scss b/app/assets/stylesheets/02_utils.scss index ac37efcbd..cad30c225 100644 --- a/app/assets/stylesheets/02_utils.scss +++ b/app/assets/stylesheets/02_utils.scss @@ -90,14 +90,6 @@ display: none !important; } -.visible-on-previous-hover { - visibility: hidden; -} - -:hover + .visible-on-previous-hover { - visibility: visible; -} - // sizing .width-100 { width: 100%; diff --git a/app/components/attachment/show_component/show_component.en.yml b/app/components/attachment/show_component/show_component.en.yml index 00e599d65..b8e1f6059 100644 --- a/app/components/attachment/show_component/show_component.en.yml +++ b/app/components/attachment/show_component/show_component.en.yml @@ -1,6 +1,5 @@ --- en: - virus_not_analyzed: this file has not been scanned by our antivirus, download it with care errors: virus_infected: Virus detected, download is blocked. corrupted_file: The file is corrupted, the download is blocked. diff --git a/app/components/attachment/show_component/show_component.fr.yml b/app/components/attachment/show_component/show_component.fr.yml index dc82c353f..72b202fe7 100644 --- a/app/components/attachment/show_component/show_component.fr.yml +++ b/app/components/attachment/show_component/show_component.fr.yml @@ -1,6 +1,5 @@ --- fr: - virus_not_analyzed: ce fichier n’a pas été analysé par notre antivirus, téléchargez-le avec précaution errors: virus_infected: "Virus détecté, le téléchargement est bloqué." corrupted_file: "Le fichier est corrompu, le téléchargement est bloqué." diff --git a/app/components/attachment/show_component/show_component.html.haml b/app/components/attachment/show_component/show_component.html.haml index 7a91132fa..681aab1fb 100644 --- a/app/components/attachment/show_component/show_component.html.haml +++ b/app/components/attachment/show_component/show_component.html.haml @@ -1,9 +1,6 @@ %div{ id: dom_id(attachment, :show), class: class_names("attachment-error": error?, "fr-mb-2w": !should_display_link?) } - if should_display_link? - = render Dsfr::DownloadComponent.new(attachment: attachment, new_tab: new_tab) do |c| - - if !attachment.virus_scanner.started? - - c.right do - = "(#{t(".virus_not_analyzed")})" + = render Dsfr::DownloadComponent.new(attachment: attachment, virus_not_analized: !attachment.virus_scanner.started?, new_tab: new_tab) - else .attachment-filename.fr-mb-1w.fr-mr-1w= attachment.filename.to_s diff --git a/app/components/dsfr/download_component.rb b/app/components/dsfr/download_component.rb index 2b92ca77c..b129c4193 100644 --- a/app/components/dsfr/download_component.rb +++ b/app/components/dsfr/download_component.rb @@ -1,15 +1,17 @@ class Dsfr::DownloadComponent < ApplicationComponent - renders_one :right - attr_reader :attachment attr_reader :html_class attr_reader :name + attr_reader :ephemeral_link + attr_reader :virus_not_analized attr_reader :new_tab - def initialize(attachment:, name: nil, url: nil, new_tab: false) + def initialize(attachment:, name: nil, url: nil, ephemeral_link: false, virus_not_analized: false, new_tab: false) @attachment = attachment @name = name || attachment.filename.to_s @url = url + @ephemeral_link = ephemeral_link + @virus_not_analized = virus_not_analized @new_tab = new_tab end diff --git a/app/components/dsfr/download_component/download_component.en.yml b/app/components/dsfr/download_component/download_component.en.yml index 8e05b9ca3..8eb96693c 100644 --- a/app/components/dsfr/download_component/download_component.en.yml +++ b/app/components/dsfr/download_component/download_component.en.yml @@ -1,3 +1,5 @@ --- en: title: "Download file %{filename}" + ephemeral_link: This link is ephemeral and should not be shared. + virus_not_analyzed: this file has not been scanned by our antivirus, download it with care diff --git a/app/components/dsfr/download_component/download_component.fr.yml b/app/components/dsfr/download_component/download_component.fr.yml index 230a588ed..0de6b11d9 100644 --- a/app/components/dsfr/download_component/download_component.fr.yml +++ b/app/components/dsfr/download_component/download_component.fr.yml @@ -1,3 +1,5 @@ --- fr: title: "Télécharger le fichier %{filename}" + ephemeral_link: Ce lien est éphémère et ne devrait pas être partagé. + virus_not_analyzed: ce fichier n’a pas été analysé par notre antivirus, téléchargez-le avec précaution diff --git a/app/components/dsfr/download_component/download_component.html.haml b/app/components/dsfr/download_component/download_component.html.haml index aed3645c3..6b0a63b58 100644 --- a/app/components/dsfr/download_component/download_component.html.haml +++ b/app/components/dsfr/download_component/download_component.html.haml @@ -4,5 +4,11 @@ = name %span.fr-download__detail = helpers.download_details(attachment) + - if ephemeral_link + %span.fr-ml-2w.fr-text--xs.fr-text-mention--grey + %span.fr-icon-questionnaire-line{ "aria-hidden": "true" } + = t('.ephemeral_link') - = right + - if virus_not_analized + .fr-text--xs.fr-text-mention--grey + = t('.virus_not_analyzed') diff --git a/app/views/shared/_piece_justificative_template.html.haml b/app/views/shared/_piece_justificative_template.html.haml index 6bf7ef005..abb90edbf 100644 --- a/app/views/shared/_piece_justificative_template.html.haml +++ b/app/views/shared/_piece_justificative_template.html.haml @@ -1,7 +1 @@ -= render Dsfr::DownloadComponent.new(attachment: champ.type_de_champ.piece_justificative_template, url: champs_piece_justificative_template_path(champ), name: "Modèle à télécharger") do |c| - - if administrateur_signed_in? - - c.with_right do - %span.fr-ml-2w.fr-text--xs.fr-text-mention--grey.visible-on-previous-hover - %span.fr-text-action-high--blue-france.fr-icon-questionnaire-line{ "aria-hidden": "true" } - = t('shared.ephemeral_link') - += render Dsfr::DownloadComponent.new(attachment: champ.type_de_champ.piece_justificative_template, url: champs_piece_justificative_template_path(champ), name: "Modèle à télécharger", ephemeral_link: administrateur_signed_in? ) diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 886fbb258..8be58f2aa 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -49,3 +49,7 @@ = t('shared.procedure_description.estimated_fill_duration_title') #accordion-116.fr-collapse.js_description_target_audience = t('shared.procedure_description.estimated_fill_duration_detail', estimated_minutes: estimated_fill_duration_minutes(procedure)) + +- if notice_url(procedure).present? + .fr-my-3w + = render Dsfr::DownloadComponent.new(attachment: procedure.notice , url: notice_url(procedure), name: t("views.shared.dossiers.edit.notice"), ephemeral_link: administrateur_signed_in?) diff --git a/app/views/shared/dossiers/_edit.html.haml b/app/views/shared/dossiers/_edit.html.haml index 1f1dbefcd..f1c585394 100644 --- a/app/views/shared/dossiers/_edit.html.haml +++ b/app/views/shared/dossiers/_edit.html.haml @@ -17,18 +17,7 @@ = t('views.shared.dossiers.edit.autosave') - if notice_url(dossier.procedure).present? - .fr-download - %p - = link_to notice_url(dossier.procedure), download: "", class: "fr-download__link mr-2", title: t("views.shared.dossiers.edit.notice_title") do - = t("views.shared.dossiers.edit.notice") - - if dossier.procedure.notice.attached? - %span.fr-download__detail - = download_details(dossier.procedure.notice) - - - if administrateur_signed_in? - %span.fr-text--xs.fr-text-mention--grey.visible-on-previous-hover - %span.fr-text-action-high--blue-france.fr-icon-questionnaire-line{ "aria-hidden": "true" } - = t('shared.ephemeral_link') + = render Dsfr::DownloadComponent.new(attachment: dossier.procedure.notice , url: notice_url(dossier.procedure), name: t("views.shared.dossiers.edit.notice"), ephemeral_link: administrateur_signed_in?) - if dossier.show_groupe_instructeur_selector? %span{ data: { controller: 'autosave' } } diff --git a/config/locales/en.yml b/config/locales/en.yml index 0711e91be..ad5e60bf4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -331,7 +331,6 @@ en: edit: autosave: Your file is automatically saved after each modification. You can close the window at any time and pick up where you left off later. notice: "Download the notice of the procedure" - notice_title: "To help you complete your file, you can consult the notice to this procedure." pending_correction: confirm_label: I certify that I have made all corrections requested by the administration. messages: @@ -803,7 +802,6 @@ en: connection_done: "The accounts for FranceConnect and %{application_name} are now merged." merger_token_expired: "Le delay to merge your FranceConnect and %{application_name} accounts is expired. Please retry." shared: - ephemeral_link: This link is ephemeral and should not be shared. procedures: stats: usual_processing_time: "Usual processing time" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index f3a1131b3..af3df9794 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -331,7 +331,6 @@ fr: edit: autosave: Votre dossier est enregistré automatiquement après chaque modification. Vous pouvez à tout moment fermer la fenêtre et reprendre plus tard là où vous en étiez. notice: Télécharger le guide de la démarche - notice_title: "Pour vous aider à remplir votre dossier, vous pouvez consulter le guide de cette démarche." pending_correction: confirm_label: Je certifie avoir effectué toutes les corrections demandées par l’administration. messages: @@ -849,7 +848,6 @@ fr: connection_done: "Les comptes FranceConnect et %{application_name} sont à présent fusionnés" merger_token_expired: "Le délai pour fusionner les comptes FranceConnect et %{application_name} est expirée. Veuillez recommencer la procédure pour vous fusionner les comptes." shared: - ephemeral_link: Ce lien est éphémère et ne devrait pas être partagé. procedures: stats: usual_processing_time: "Temps de traitement usuel"