refactor(gallery): add attachment_gallery_item component

This commit is contained in:
Eric Leroy-Terquem 2024-09-06 17:17:57 +02:00
parent 6b1c6a796a
commit bae752f1aa
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
6 changed files with 96 additions and 39 deletions

View file

@ -0,0 +1,22 @@
# frozen_string_literal: true
class Attachment::GalleryItemComponent < ApplicationComponent
include GalleryHelper
attr_reader :attachment
def initialize(attachment:)
@attachment = attachment
end
def blob
attachment.blob
end
def libelle
attachment.record.class.in?([Champs::PieceJustificativeChamp, Champs::TitreIdentiteChamp]) ? attachment.record.libelle : 'Pièce jointe au message'
end
def title
"#{libelle} -- #{sanitize(blob.filename.to_s)}"
end
end