refactor(gallery): use gallery component in gallery demande
This commit is contained in:
parent
664ef63e74
commit
3560d73b58
4 changed files with 23 additions and 27 deletions
|
@ -4,14 +4,17 @@ class Attachment::GalleryItemComponent < ApplicationComponent
|
|||
include GalleryHelper
|
||||
attr_reader :attachment
|
||||
|
||||
def initialize(attachment:)
|
||||
def initialize(attachment:, gallery_demande: false)
|
||||
@attachment = attachment
|
||||
@gallery_demande = gallery_demande
|
||||
end
|
||||
|
||||
def blob
|
||||
attachment.blob
|
||||
end
|
||||
|
||||
def gallery_demande? = @gallery_demande
|
||||
|
||||
def libelle
|
||||
attachment.record.class.in?([Champs::PieceJustificativeChamp, Champs::TitreIdentiteChamp]) ? attachment.record.libelle : 'Pièce jointe au message'
|
||||
end
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
= image_tag(representation_url_for(attachment), loading: :lazy)
|
||||
.fr-btn.fr-btn--tertiary.fr-btn--icon-left.fr-icon-eye{ role: :button }
|
||||
Visualiser
|
||||
.champ-libelle
|
||||
= libelle.truncate(25)
|
||||
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
|
||||
- if !gallery_demande?
|
||||
.champ-libelle
|
||||
= libelle.truncate(25)
|
||||
= render Attachment::ShowComponent.new(attachment:, truncate: true, new_tab: gallery_demande?)
|
||||
- else
|
||||
.thumbnail
|
||||
= image_tag('apercu-indisponible.png')
|
||||
.champ-libelle
|
||||
= libelle.truncate(25)
|
||||
= render Attachment::ShowComponent.new(attachment: attachment, truncate: true)
|
||||
- if !gallery_demande?
|
||||
.champ-libelle
|
||||
= libelle.truncate(25)
|
||||
= render Attachment::ShowComponent.new(attachment:, truncate: true, new_tab: gallery_demande?)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue