Merge pull request #8194 from mfo/US/fix-download-target
amelioration(liens-de-telechargement): permet de specifier si le lien de téléchargement se fait sur l'onglet actuel ou vers un nouvel onglet
This commit is contained in:
commit
b68e150dd1
5 changed files with 9 additions and 6 deletions
|
@ -1,9 +1,10 @@
|
|||
class Attachment::ShowComponent < ApplicationComponent
|
||||
def initialize(attachment:)
|
||||
def initialize(attachment:, new_tab: false)
|
||||
@attachment = attachment
|
||||
@new_tab = new_tab
|
||||
end
|
||||
|
||||
attr_reader :attachment
|
||||
attr_reader :attachment, :new_tab
|
||||
|
||||
def should_display_link?
|
||||
(attachment.virus_scanner.safe? || !attachment.virus_scanner.started?) && !attachment.watermark_pending?
|
||||
|
|
|
@ -1,6 +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) do |c|
|
||||
= render Dsfr::DownloadComponent.new(attachment: attachment, new_tab: new_tab) do |c|
|
||||
- if !attachment.virus_scanner.started?
|
||||
- c.right do
|
||||
= "(#{t(".virus_not_analyzed")})"
|
||||
|
|
|
@ -4,11 +4,13 @@ class Dsfr::DownloadComponent < ApplicationComponent
|
|||
attr_reader :attachment
|
||||
attr_reader :html_class
|
||||
attr_reader :name
|
||||
attr_reader :new_tab
|
||||
|
||||
def initialize(attachment:, name: nil, url: nil)
|
||||
def initialize(attachment:, name: nil, url: nil, new_tab: false)
|
||||
@attachment = attachment
|
||||
@name = name || attachment.filename.to_s
|
||||
@url = url
|
||||
@new_tab = new_tab
|
||||
end
|
||||
|
||||
def title
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.fr-download
|
||||
%p
|
||||
= link_to url, download: "", class: "fr-download__link", title: title do
|
||||
= link_to url, {class: "fr-download__link", title: title}.merge(new_tab ? { target: '_blank' } : { download: '' }) do
|
||||
= name
|
||||
%span.fr-download__detail
|
||||
= helpers.download_details(attachment)
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
.fr-downloads-group
|
||||
%ul
|
||||
- pj.attachments.each do |attachment|
|
||||
%li= render Attachment::ShowComponent.new(attachment:)
|
||||
%li= render Attachment::ShowComponent.new(attachment:, new_tab: true)
|
||||
- else
|
||||
Pièce justificative non fournie
|
||||
|
|
Loading…
Reference in a new issue