refactor(gallery): add attachment_gallery_item component
This commit is contained in:
parent
6b1c6a796a
commit
bae752f1aa
6 changed files with 96 additions and 39 deletions
22
app/components/attachment/gallery_item_component.rb
Normal file
22
app/components/attachment/gallery_item_component.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue