fix(gallery): display attachments tab only if attachments in dossier

This commit is contained in:
Eric Leroy-Terquem 2024-05-03 14:41:17 +02:00
parent 479fdb9dbe
commit db8de9e657
No known key found for this signature in database
GPG key ID: ECE60B4C1FA2ABB3
2 changed files with 31 additions and 35 deletions

View file

@ -7,7 +7,7 @@
instructeur_dossier_path(dossier.procedure, dossier), instructeur_dossier_path(dossier.procedure, dossier),
notification: notifications_summary[:demande]) notification: notifications_summary[:demande])
- if dossier.revision.types_de_champ.any?(&:piece_justificative?) - if dossier.champs.map(&:piece_justificative_file).flatten.any?
= dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.attachments'), = dynamic_tab_item(t('views.instructeurs.dossiers.tab_steps.attachments'),
pieces_jointes_instructeur_dossier_path(dossier.procedure, dossier)) pieces_jointes_instructeur_dossier_path(dossier.procedure, dossier))

View file

@ -3,38 +3,34 @@
= render partial: "header", locals: { dossier: @dossier } = render partial: "header", locals: { dossier: @dossier }
.fr-container .fr-container
- if @champs_with_pieces_jointes.map(&:piece_justificative_file).flatten.none? .gallery.gallery-pieces-jointes{ "data-controller": "lightbox" }
.empty-text - @champs_with_pieces_jointes.each do |champ|
Ce dossier ne contient pas de pièces jointes - champ.piece_justificative_file.each do |attachment|
- else .gallery-item
.gallery.gallery-pieces-jointes{ "data-controller": "lightbox" } - blob = attachment.blob
- @champs_with_pieces_jointes.each do |champ| - if blob.content_type.in?(AUTHORIZED_PDF_TYPES)
- champ.piece_justificative_file.each do |attachment| = 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
.gallery-item
- blob = attachment.blob
- if 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
= image_tag("pdf-placeholder.png")
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
Visualiser
.champ-libelle
= champ.libelle.truncate(25)
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
- elsif blob.content_type.in?(AUTHORIZED_IMAGE_TYPES)
= link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do
.thumbnail
= image_tag(attachment.variant(:medium), loading: :lazy)
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
Visualiser
.champ-libelle
= champ.libelle.truncate(25)
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
- else
.thumbnail .thumbnail
= image_tag('apercu-indisponible.png') = image_tag("pdf-placeholder.png")
.champ-libelle .fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
= champ.libelle.truncate(25) Visualiser
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true) .champ-libelle
= champ.libelle.truncate(25)
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
- elsif blob.content_type.in?(AUTHORIZED_IMAGE_TYPES)
= link_to image_url(blob.url), title: "#{champ.libelle} -- #{blob.filename}", data: { src: blob.url }, class: 'gallery-link' do
.thumbnail
= image_tag(attachment.variant(:medium), loading: :lazy)
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
Visualiser
.champ-libelle
= champ.libelle.truncate(25)
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
- else
.thumbnail
= image_tag('apercu-indisponible.png')
.champ-libelle
= champ.libelle.truncate(25)
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)