style(exports): download link instead of button

This commit is contained in:
Colin Darie 2023-09-20 16:04:22 +02:00
parent 307ba68970
commit daa8eac9cc
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
4 changed files with 16 additions and 13 deletions

View file

@ -61,16 +61,19 @@ class Dossiers::ExportLinkComponent < ApplicationComponent
def export_button(export)
if export.available?
title = t(".everything_ready", export_format: ".#{export.format}")
content_tag(:a, title, { href: export.file.url, title: new_tab_suffix(title), target: "_blank", rel: "noopener", class: 'fr-btn' })
render Dsfr::DownloadComponent.new(attachment: export.file, name: title)
elsif export.pending?
content_tag(:a, t('.refresh_page'), { href: "", class: 'fr-btn fr-btn fr-btn--tertiary' })
content_tag(:a, t('.refresh_page'), { href: "", class: 'fr-btn fr-btn--sm fr-btn--tertiary' })
end
end
def refresh_button_options(export)
{
title: t(".refresh_old_export", export_format: ".#{export.format}"),
class: "fr-btn fr-btn--tertiary"
"aria-label" => t(".refresh_old_export", export_format: ".#{export.format}"),
class: class_names("fr-btn fr-btn--sm fr-icon-refresh-line fr-btn--tertiary" => true,
"fr-btn--icon" => !export.failed?,
"fr-btn--icon-left" => export.failed?)
}
end
end

View file

@ -6,8 +6,8 @@ en:
everything_zip_html: Request an export in .zip format<br>(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
refresh_old_export: Recreate this export
everything_ready: Download in %{export_format} format
refresh_old_export: Regenerate this export
everything_ready: Download export %{export_format}
success_label: Ready
failed_label: Failed
pending_label: In progress

View file

@ -6,8 +6,8 @@ fr:
everything_zip_html: Demander un export au format .zip<br>(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}
refresh_old_export: Recréer cet export
everything_ready: Télécharger au format %{export_format}
refresh_old_export: Regénérer cet export
everything_ready: Télécharger lexport %{export_format}
success_label: Prêt
failed_label: Erreur
pending_label: En préparation

View file

@ -9,10 +9,10 @@
= time_info(export)
.fr-ml-auto
= badge(export)
%ul.fr-btns-group.fr-btns-group--inline-sm
%li
= export_button(export)
- if export.old?
%li
= button_to refresh_button_options(export)[:title], download_export_path(export_format: export.format, statut: export.statut, force_export: true), refresh_button_options(export)
.flex.flex-gap-2
= export_button(export)
- if export.old? || export.failed?
= button_to refresh_button_options(export)[:title], download_export_path(export_format: export.format, statut: export.statut, force_export: true), refresh_button_options(export)