feat(gallery): add origin tag to gallery item

This commit is contained in:
Eric Leroy-Terquem 2024-09-10 11:43:25 +02:00
parent df08617387
commit bc237152e7
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
3 changed files with 49 additions and 7 deletions

View file

@ -16,7 +16,34 @@ class Attachment::GalleryItemComponent < ApplicationComponent
def gallery_demande? = @gallery_demande
def libelle
attachment.record.class.in?([Champs::PieceJustificativeChamp, Champs::TitreIdentiteChamp]) ? attachment.record.libelle : 'Pièce jointe au message'
from_dossier? ? attachment.record.libelle : 'Pièce jointe au message'
end
def from_dossier?
attachment.record.class.in?([Champs::PieceJustificativeChamp, Champs::TitreIdentiteChamp])
end
def from_messagerie?
attachment.record.is_a?(Commentaire)
end
def from_messagerie_instructeur?
from_messagerie? && attachment.record.instructeur.present?
end
def from_messagerie_usager?
from_messagerie? && attachment.record.instructeur.nil?
end
def origin
case
when from_dossier?
'Dossier usager'
when from_messagerie_instructeur?
'Messagerie (instructeur)'
when from_messagerie_usager?
'Messagerie (usager)'
end
end
def title
@ -40,7 +67,7 @@ class Attachment::GalleryItemComponent < ApplicationComponent
end
def updated?
attachment.record.class.in?([Champs::PieceJustificativeChamp, Champs::TitreIdentiteChamp]) && updated_at > attachment.record.dossier.depose_at
from_dossier? && updated_at > attachment.record.dossier.depose_at
end
def updated_at

View file

@ -1,5 +1,8 @@
.gallery-item
- if !gallery_demande?
.fr-mb-1v
.fr-tag
= origin
.fr-mb-2v.champ-updated{ class: badge_updated_class }
= t(updated? ? '.updated_at' : '.created_at', datetime: helpers.try_format_datetime(updated_at, format: :veryshort))
- if displayable_pdf?(blob) || displayable_image?(blob)