From ed057737a534d3992bfc230a330d9761909e24c0 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 20 Sep 2023 12:22:43 +0200 Subject: [PATCH] feat(exports): name the dossiers count --- app/components/dossiers/export_link_component.rb | 11 ++++++++--- .../export_link_component.en.yml | 5 ++++- .../export_link_component.fr.yml | 13 ++++++++----- .../export_link_component.html.haml | 9 +++++---- app/models/export.rb | 2 +- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/app/components/dossiers/export_link_component.rb b/app/components/dossiers/export_link_component.rb index 6b3ea1e7a..7edc3782a 100644 --- a/app/components/dossiers/export_link_component.rb +++ b/app/components/dossiers/export_link_component.rb @@ -31,9 +31,14 @@ class Dossiers::ExportLinkComponent < ApplicationComponent end def export_title(export) - t(".export_title", - export_tabs: export.statut.to_s, - export_format: export.format) + count = export.count + + case count + when nil + t(".export_title", export_tabs: export.statut.to_s, export_format: export.format) + else + t(".export_title_counted", export_tabs: export.statut.to_s, export_format: export.format, count: count) + end end def badge(export) 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 3fb2c648c..81217dd25 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 @@ -7,12 +7,15 @@ en: everything_json_html: Request an export in .json format (GeoJSON) everything_short: Request an export in %{export_format} format refresh_old_export: Recreate this export - everything_ready: Download the export in %{export_format} format + everything_ready: Download in %{export_format} 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: + 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 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 ab716486e..a2a7db1c4 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 @@ -7,14 +7,17 @@ fr: everything_json_html: Demander un export au format .json (GeoJSON) everything_short: Demander un export au format %{export_format} refresh_old_export: Recréer cet export - everything_ready: Télécharger l’export au format %{export_format} + everything_ready: Télécharger au format %{export_format} success_label: Prêt failed_label: Erreur - pending_label: En cours + pending_label: En préparation refresh_page: Recharger la page - export_title: Export .%{export_format} pour les dossiers « %{export_tabs} » - 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}" + export_title: "Export .%{export_format} des dossiers « %{export_tabs} »" + export_title_counted: + one: "Export .%{export_format} d’un dossier « %{export_tabs} »" + other: "Export .%{export_format} de %{count} dossiers « %{export_tabs} »" + 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 diff --git a/app/components/dossiers/export_link_component/export_link_component.html.haml b/app/components/dossiers/export_link_component/export_link_component.html.haml index 4dee7c57a..3e57732d0 100644 --- a/app/components/dossiers/export_link_component/export_link_component.html.haml +++ b/app/components/dossiers/export_link_component/export_link_component.html.haml @@ -2,10 +2,11 @@ - @exports.each do |export| %li.fr-mb-3w .flex - %strong - = export_title(export) - %span.fr-text-mention--grey.fr-mb-1w - = time_info(export) + %span + %strong + = export_title(export) + %span.fr-text-mention--grey.fr-mb-1w + = time_info(export) .fr-ml-auto = badge(export) %ul.fr-btns-group.fr-btns-group--inline-sm diff --git a/app/models/export.rb b/app/models/export.rb index a70faa947..b17a2cac9 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -114,7 +114,7 @@ class Export < ApplicationRecord def count if procedure_presentation_id.present? - dossiers_for_export.size + dossiers_for_export.count end end