feat(exports): humanize status name

This commit is contained in:
Colin Darie 2023-09-20 14:00:18 +02:00
parent 3af93735a3
commit 307ba68970
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
6 changed files with 42 additions and 15 deletions

View file

@ -1,5 +1,6 @@
class Dossiers::ExportLinkComponent < ApplicationComponent
include ApplicationHelper
include TabsHelper
def initialize(procedure:, exports:, statut: nil, count: nil, class_btn: nil, export_url: nil)
@procedure = procedure
@ -35,12 +36,18 @@ class Dossiers::ExportLinkComponent < ApplicationComponent
case count
when nil
t(".export_title", export_tabs: export.statut.to_s, export_format: export.format)
t(".export_title", export_tabs: human_export_status(export), export_format: export.format)
else
t(".export_title_counted", export_tabs: export.statut.to_s, export_format: export.format, count: count)
t(".export_title_counted", export_tabs: human_export_status(export), export_format: export.format, count: count)
end
end
def human_export_status(export)
key = tab_i18n_key_from_status(export.statut)
t(key, count: export.count) || export.statut
end
def badge(export)
if export.available?
content_tag(:span, t(".success_label"), { class: "fr-badge fr-badge--success fr-text-right" })

View file

@ -1,4 +1,25 @@
module TabsHelper
def tab_i18n_key_from_status(status)
case status
when 'a-suivre'
'views.instructeurs.dossiers.tab_steps.to_follow' # i18n-tasks-use t('views.instructeurs.dossiers.tab_steps.to_follow')
when 'suivis'
'pluralize.followed'
when 'traites'
'pluralize.processed'
when 'tous'
'views.instructeurs.dossiers.tab_steps.total' # i18n-tasks-use t('views.instructeurs.dossiers.tab_steps.total')
when 'supprimes_recemment'
'pluralize.dossiers_supprimes_recemment'
when 'expirant'
'pluralize.dossiers_close_to_expiration'
when 'archives'
'pluralize.archived'
else
fail ArgumentError, "Unknown tab status: #{status}"
end
end
def tab_item(label, url, active: false, badge: nil, notification: false)
render partial: 'shared/tab_item', locals: {
label: label,

View file

@ -1,40 +1,39 @@
%nav.tabs.mt-3
%ul
= tab_item(t('views.instructeurs.dossiers.tab_steps.to_follow'),
= tab_item(t(tab_i18n_key_from_status('a-suivre')),
instructeur_procedure_path(procedure, statut: 'a-suivre'),
active: statut == 'a-suivre',
badge: number_with_html_delimiter(a_suivre_count))
= tab_item(t('pluralize.followed', count: suivis_count),
= tab_item(t(tab_i18n_key_from_status('suivis'), count: suivis_count),
instructeur_procedure_path(procedure, statut: 'suivis'),
active: statut == 'suivis',
badge: number_with_html_delimiter(suivis_count),
notification: has_en_cours_notifications)
= tab_item(t('pluralize.processed', count: traites_count),
= tab_item(t(tab_i18n_key_from_status('traites'), count: traites_count),
instructeur_procedure_path(procedure, statut: 'traites'),
active: statut == 'traites',
badge: number_with_html_delimiter(traites_count),
notification: has_termine_notifications)
= tab_item(t('views.instructeurs.dossiers.tab_steps.total'),
= tab_item(t(tab_i18n_key_from_status('tous')),
instructeur_procedure_path(procedure, statut: 'tous'),
active: statut == 'tous',
badge: number_with_html_delimiter(tous_count))
= tab_item(t('pluralize.dossiers_supprimes_recemment', count: supprimes_recemment_count),
= tab_item(t(tab_i18n_key_from_status('supprimes_recemment'), count: supprimes_recemment_count),
instructeur_procedure_path(procedure, statut: 'supprimes_recemment'),
active: statut == 'supprimes_recemment',
badge: number_with_html_delimiter(supprimes_recemment_count))
- if procedure.procedure_expires_when_termine_enabled
= tab_item(t('pluralize.dossiers_close_to_expiration', count: expirant_count),
= tab_item(t(tab_i18n_key_from_status('expirant'), count: expirant_count),
instructeur_procedure_path(procedure, statut: 'expirant'),
active: statut == 'expirant',
badge: number_with_html_delimiter(expirant_count))
= tab_item(t('pluralize.archived', count: archives_count),
= tab_item(t(tab_i18n_key_from_status('archives'), count: archives_count),
instructeur_procedure_path(procedure, statut: 'archives'),
active: statut == 'archives',
badge: number_with_html_delimiter(archives_count))

View file

@ -5,5 +5,5 @@ en:
export_pending_html: We generate this export. You will be able to download it in a few minutes from <a href="%{url}">the exports list</a>.
exports:
title: Exports list
export_description: This list of exports contains the exports you requested as well as those requested by instructors belonging to the same group.
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. <br> Can't find an export? It may have expired, exports are deleted after %{expiration_time} hours.

View file

@ -5,5 +5,5 @@ fr:
export_pending_html: Nous générons cet export. Vous pourrez le télécharger dans quelques minutes depuis <a href="%{url}">la liste des exports</a>.
exports:
title: Liste des exports
export_description: Cette liste d'exports contient les exports que vous avez demandé 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.
no_export_html: Vous n'avez pas d'export pour le moment. <br> Vous ne trouvez pas un export ? Il a peut-être expiré, les exports sont supprimés au bout de %{expiration_time} heures.

View file

@ -122,15 +122,15 @@ describe 'Instructing a dossier:', js: true, retry: 3 do
expect(page).to have_text('Nous générons cet export.')
click_on "voir les exports"
expect(page).to have_text("Export .csv pour les dossiers « a-suivre » - demandé il y a moins d'une minute")
expect(page).to have_text("En cours")
expect(page).to have_text("Export .csv dun dossier « à suivre » demandé il y a moins d'une minute")
expect(page).to have_text("En préparation")
assert_performed_jobs 2 do
perform_enqueued_jobs(only: ExportJob)
end
page.driver.browser.navigate.refresh
expect(page).to have_text('Télécharger lexport au format .csv')
expect(page).to have_text('Télécharger lexport .csv')
end
scenario 'A instructeur can see the personnes impliquées' do