demarches-normaliennes/app/views/shared/champs/piece_justificative/_show.html.haml

29 lines
1.7 KiB
Text
Raw Normal View History

.fr-downloads-group
- if !feature_enabled?(:gallery_demande)
%ul
- champ.piece_justificative_file.attachments.each do |attachment|
%li= render Attachment::ShowComponent.new(attachment:, new_tab: true)
- else
.gallery-items-list
2024-05-07 16:41:20 +02:00
- champ.piece_justificative_file.attachments.with_all_variant_records.each do |attachment|
.gallery-item
- blob = attachment.blob
2024-05-24 09:46:45 +02:00
- if blob.previewable? && blob.content_type.in?(AUTHORIZED_PDF_TYPES)
= link_to blob.url, id: blob.id, data: { iframe: true, src: blob.url }, class: 'gallery-link', type: blob.content_type, title: "#{champ.libelle} -- #{blob.filename}" do
.thumbnail
2024-05-24 09:46:45 +02:00
= image_tag(attachment.preview(resize_to_limit: [400, 400]).processed.url, loading: :lazy)
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
= 'Visualiser'
2024-05-24 09:46:45 +02:00
- elsif blob.variable? && blob.content_type.in?(AUTHORIZED_IMAGE_TYPES)
- blob_url = blob.content_type.in?(RARE_IMAGE_TYPES) ? attachment.variant(resize_to_limit: [2000, 2000]).processed.url : blob.url
= link_to image_url(blob_url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do
.thumbnail
= image_tag(attachment.variant(resize_to_limit: [400, 400]).processed.url, loading: :lazy)
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
= 'Visualiser'
- else
.thumbnail
= image_tag('apercu-indisponible.png')
= render Attachment::ShowComponent.new(attachment:, new_tab: true, truncate: true)