From 2cdd0cce68cb061f15ee2c1b12186b452f757a5f Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 21 Sep 2023 13:59:14 +0200 Subject: [PATCH] chore(exports): minor wording improvements and clarifications --- .../dossiers/export_link_component.rb | 16 +++++------- .../export_link_component.en.yml | 26 ++++++------------- .../export_link_component.fr.yml | 22 +++++----------- .../administrateurs/archives_controller.rb | 2 +- .../instructeurs/procedures_controller.rb | 2 +- app/models/export.rb | 2 ++ .../instructeurs/procedures/exports.html.haml | 2 +- .../instructeurs/procedures/exports/en.yml | 6 +++-- .../instructeurs/procedures/exports/fr.yml | 4 ++- .../views/instructeurs/procedures/fr.yml | 2 -- .../dossiers/export_link_component_spec.rb | 4 +-- spec/system/instructeurs/instruction_spec.rb | 2 +- 12 files changed, 36 insertions(+), 54 deletions(-) diff --git a/app/components/dossiers/export_link_component.rb b/app/components/dossiers/export_link_component.rb index fede6c75977..e7ffea97326 100644 --- a/app/components/dossiers/export_link_component.rb +++ b/app/components/dossiers/export_link_component.rb @@ -23,18 +23,17 @@ def time_info(export) if export.available? t(".ready_link_label_time_info", export_time: helpers.time_ago_in_words(export.updated_at)) else - t(".not_ready_link_label_time_info", export_time: helpers.time_ago_in_words(export.updated_at)) + t(".not_ready_link_label_time_info", export_time: helpers.time_ago_in_words(export.created_at)) end end def export_title(export) - count = export.count - - case count - when nil - t(".export_title", export_tabs: human_export_status(export), export_format: export.format) + if export.procedure_presentation_id.nil? + t(".export_title_everything", export_format: export.format) + elsif export.tous? + t(".export_title", export_format: export.format, count: export.count) else - t(".export_title_counted", export_tabs: human_export_status(export), export_format: export.format, count: count) + t(".export_title_with_tab", export_tabs: human_export_status(export), export_format: export.format, count: export.count) end end @@ -56,8 +55,7 @@ def badge(export) def export_button(export) if export.available? - title = t(".everything_ready", export_format: ".#{export.format}") - render Dsfr::DownloadComponent.new(attachment: export.file, name: title) + render Dsfr::DownloadComponent.new(attachment: export.file, name: t('.download_export')) elsif export.pending? content_tag(:a, t('.refresh_page'), { href: "", class: 'fr-btn fr-btn--sm fr-btn--tertiary' }) end diff --git a/app/components/dossiers/export_link_component/export_link_component.en.yml b/app/components/dossiers/export_link_component/export_link_component.en.yml index b4280b37652..66956168885 100644 --- a/app/components/dossiers/export_link_component/export_link_component.en.yml +++ b/app/components/dossiers/export_link_component/export_link_component.en.yml @@ -1,27 +1,17 @@ --- en: - everything_csv_html: Request an export in .csv format
(only files, without repeatable fields) - everything_xlsx_html: Request an export in .xlsx format - everything_ods_html: Request an export in .ods format - everything_zip_html: Request an export in .zip format
(does not contains timestamp nor operation logs) - everything_json_html: Request an export in .json format (GeoJSON) - everything_short: Request an export in %{export_format} format + download_export: Download export refresh_old_export: Regenerate this export - everything_ready: Download export %{export_format} success_label: Ready failed_label: Failed pending_label: In progress refresh_page: Refresh page - export_title: Export .%{export_format} for files « %{export_tabs} » - export_title_counted: + export_title_everything: Export .%{export_format} of all files + export_title_with_tab: one: Export .%{export_format} of 1 file « %{export_tabs} » other: Export .%{export_format} of %{count} files « %{export_tabs} » - ready_link_label_time_info: " - generated %{export_time} ago" - not_ready_link_label_time_info: " - asked %{export_time} ago" - download_all: Download all files - download: - one: Download a file - other: Download %{count} files - macros_doc: - title: "Macros documentation" - url: "https://doc.demarches-simplifiees.fr/pour-aller-plus-loin/exports-et-macros" + export_title: + one: Export .%{export_format} of 1 file + other: Export .%{export_format} of %{count} files + ready_link_label_time_info: " generated %{export_time} ago" + not_ready_link_label_time_info: " asked %{export_time} ago" diff --git a/app/components/dossiers/export_link_component/export_link_component.fr.yml b/app/components/dossiers/export_link_component/export_link_component.fr.yml index 84e889cb35e..34f0c14d73e 100644 --- a/app/components/dossiers/export_link_component/export_link_component.fr.yml +++ b/app/components/dossiers/export_link_component/export_link_component.fr.yml @@ -1,27 +1,17 @@ --- fr: - everything_csv_html: Demander un export au format .csv
(uniquement les dossiers, sans les champs répétables) - everything_xlsx_html: Demander un export au format .xlsx - everything_ods_html: Demander un export au format .ods - everything_zip_html: Demander un export au format .zip
(ne contient pas l'horodatage ni le journal de log) - everything_json_html: Demander un export au format .json (GeoJSON) - everything_short: Demander un export au format %{export_format} + download_export: Télécharger l’export refresh_old_export: Regénérer cet export - everything_ready: Télécharger l’export %{export_format} success_label: Prêt failed_label: Erreur pending_label: En préparation refresh_page: Recharger la page - export_title: "Export .%{export_format} des dossiers « %{export_tabs} »" - export_title_counted: + export_title_everything: "Export .%{export_format} de tous les dossiers" + export_title_with_tab: one: "Export .%{export_format} d’un dossier « %{export_tabs} »" other: "Export .%{export_format} de %{count} dossiers « %{export_tabs} »" + export_title: + one: "Export .%{export_format} d’un dossier" + other: "Export .%{export_format} de %{count} dossiers" ready_link_label_time_info: " généré il y a %{export_time}" not_ready_link_label_time_info: " demandé il y a %{export_time}" - download_all: Télécharger tous les dossiers - download: - one: Télécharger un dossier - other: Télécharger %{count} dossiers - macros_doc: - title: "documentation sur les macros" - url: "https://doc.demarches-simplifiees.fr/pour-aller-plus-loin/exports-et-macros" diff --git a/app/controllers/administrateurs/archives_controller.rb b/app/controllers/administrateurs/archives_controller.rb index e0cbccd7d98..2bd184f2436 100644 --- a/app/controllers/administrateurs/archives_controller.rb +++ b/app/controllers/administrateurs/archives_controller.rb @@ -6,7 +6,7 @@ class ArchivesController < AdministrateurController helper_method :create_archive_url def index - @exports = Export.by_key(all_groupe_instructeurs.map(&:id), nil) + @exports = Export.ante_chronological.by_key(all_groupe_instructeurs.map(&:id), nil) @average_dossier_weight = @procedure.average_dossier_weight @count_dossiers_termines_by_month = @procedure.dossiers.processed_by_month(all_groupe_instructeurs).count @archives = Archive.for_groupe_instructeur(all_groupe_instructeurs).to_a diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index ebb3d059a1b..66ba47635de 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -222,7 +222,7 @@ def stats def exports @procedure = procedure - @exports = Export.for_groupe_instructeurs(groupe_instructeur_ids).order(updated_at: :desc) + @exports = Export.for_groupe_instructeurs(groupe_instructeur_ids).ante_chronological cookies.encrypted[cookies_export_key] = { value: DateTime.current, expires: Export::MAX_DUREE_GENERATION + Export::MAX_DUREE_CONSERVATION_EXPORT diff --git a/app/models/export.rb b/app/models/export.rb index c47a8f0d160..a20ea8dc43b 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -34,6 +34,8 @@ class Export < ApplicationRecord validates :format, :groupe_instructeurs, :key, presence: true + scope :ante_chronological, -> { order(updated_at: :desc) } + after_create_commit :compute_async FORMATS_WITH_TIME_SPAN = [:xlsx, :ods, :csv].flat_map do |format| diff --git a/app/views/instructeurs/procedures/exports.html.haml b/app/views/instructeurs/procedures/exports.html.haml index 97dd7c79e6c..40758372761 100644 --- a/app/views/instructeurs/procedures/exports.html.haml +++ b/app/views/instructeurs/procedures/exports.html.haml @@ -9,7 +9,7 @@ %h1= t('.title') = render Dsfr::CalloutComponent.new(title: nil) do |c| - c.with_body do - %p= t('.export_description') + %p= t('.export_description', expiration_time: Export::MAX_DUREE_CONSERVATION_EXPORT.in_hours.to_i) - if @exports.present? %div{ data: @exports.any?(&:pending?) ? { controller: "turbo-poll", turbo_poll_url_value: "", turbo_poll_interval_value: 10_000, turbo_poll_max_checks_value: 6 } : {} } diff --git a/config/locales/views/instructeurs/procedures/exports/en.yml b/config/locales/views/instructeurs/procedures/exports/en.yml index 5307ee6a3fc..58547bf96b0 100644 --- a/config/locales/views/instructeurs/procedures/exports/en.yml +++ b/config/locales/views/instructeurs/procedures/exports/en.yml @@ -5,5 +5,7 @@ en: export_pending_html: We generate this export. You will be able to download it in a few minutes from the exports list. exports: title: Exports list - export_description: This list of exports contains the last exports you requested as well as those requested by instructors belonging to the same group. - no_export_html: You have no export at the moment.
Can't find an export? It may have expired, exports are deleted after %{expiration_time} hours. + export_description: | + This list of exports contains the last exports you requested as well as those requested by instructors belonging to the same group. + They are available for %{expiration_time} hours after generation. + no_export_html: You have no export at the moment.
Can't find an export? It may have expired, exports are deleted after %{expiration_time} hours. diff --git a/config/locales/views/instructeurs/procedures/exports/fr.yml b/config/locales/views/instructeurs/procedures/exports/fr.yml index fc0b8f1f898..94f834a06c5 100644 --- a/config/locales/views/instructeurs/procedures/exports/fr.yml +++ b/config/locales/views/instructeurs/procedures/exports/fr.yml @@ -5,5 +5,7 @@ fr: export_pending_html: Nous générons cet export. Vous pourrez le télécharger dans quelques minutes depuis la liste des exports. exports: title: Liste des exports - export_description: Cette liste d'exports contient les derniers exports que vous avez demandés ainsi que ceux demandés par les instructeurs appartenant au même groupe. + export_description: | + Cette liste d'exports contient les derniers exports que vous avez demandés ainsi que ceux demandés par les instructeurs appartenant au même groupe. + Ils sont disponibles pendant %{expiration_time} heures après leur génération. no_export_html: Vous n'avez pas d'export pour le moment.
Vous ne trouvez pas un export ? Il a peut-être expiré, les exports sont supprimés au bout de %{expiration_time} heures. diff --git a/config/locales/views/instructeurs/procedures/fr.yml b/config/locales/views/instructeurs/procedures/fr.yml index 5ea58bd8990..886464b85d4 100644 --- a/config/locales/views/instructeurs/procedures/fr.yml +++ b/config/locales/views/instructeurs/procedures/fr.yml @@ -20,5 +20,3 @@ fr: title: "%{procedure_libelle} - n°%{procedure_id} - administrateurs" stats: title: Statistiques - exports: - title: Exports diff --git a/spec/components/dossiers/export_link_component_spec.rb b/spec/components/dossiers/export_link_component_spec.rb index 7e3f812fc1f..c413ec27652 100644 --- a/spec/components/dossiers/export_link_component_spec.rb +++ b/spec/components/dossiers/export_link_component_spec.rb @@ -1,7 +1,7 @@ RSpec.describe Dossiers::ExportLinkComponent, type: :component do let(:procedure) { create(:procedure) } let(:groupe_instructeur) { create(:groupe_instructeur, procedure: procedure) } - let(:export) { create(:export, groupe_instructeurs: [groupe_instructeur], updated_at: 5.minutes.ago) } + let(:export) { create(:export, groupe_instructeurs: [groupe_instructeur], updated_at: 5.minutes.ago, created_at: 10.minutes.ago) } let(:export_url) { double("ExportUrl", call: "/some/fake/path") } let(:component) { described_class.new(procedure:, exports: [export], export_url:) } @@ -34,7 +34,7 @@ end it "displays the pending label" do - expect(subject).to include("demandé il y a 5 minutes") + expect(subject).to include("demandé il y a 10 minutes") end it "displays a refresh page button" do diff --git a/spec/system/instructeurs/instruction_spec.rb b/spec/system/instructeurs/instruction_spec.rb index 97999e06928..da21f5ac8a0 100644 --- a/spec/system/instructeurs/instruction_spec.rb +++ b/spec/system/instructeurs/instruction_spec.rb @@ -130,7 +130,7 @@ end page.driver.browser.navigate.refresh - expect(page).to have_text('Télécharger l’export .csv') + expect(page).to have_text('Télécharger l’export') end scenario 'A instructeur can see the personnes impliquées' do