feat(gallery): update gallery item badge class after seen
This commit is contained in:
parent
d9f604e8ce
commit
3bc232e81e
4 changed files with 49 additions and 5 deletions
|
@ -2,11 +2,12 @@
|
|||
|
||||
class Attachment::GalleryItemComponent < ApplicationComponent
|
||||
include GalleryHelper
|
||||
attr_reader :attachment
|
||||
attr_reader :attachment, :seen_at
|
||||
|
||||
def initialize(attachment:, gallery_demande: false)
|
||||
def initialize(attachment:, gallery_demande: false, seen_at: nil)
|
||||
@attachment = attachment
|
||||
@gallery_demande = gallery_demande
|
||||
@seen_at = seen_at
|
||||
end
|
||||
|
||||
def blob
|
||||
|
@ -77,7 +78,7 @@ class Attachment::GalleryItemComponent < ApplicationComponent
|
|||
def badge_updated_class
|
||||
class_names(
|
||||
"fr-badge fr-badge--sm" => true,
|
||||
"fr-badge--new" => updated?
|
||||
"fr-badge--new" => seen_at.present? && updated_at&.>(seen_at)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -386,6 +386,7 @@ module Instructeurs
|
|||
.flatten
|
||||
|
||||
@gallery_attachments = champs_attachments + commentaires_attachments
|
||||
@pieces_jointes_seen_at = current_instructeur.follows.find_by(dossier: dossier)&.pieces_jointes_seen_at
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
.fr-container
|
||||
.gallery.gallery-pieces-jointes{ "data-controller": "lightbox" }
|
||||
- @gallery_attachments.each do |attachment|
|
||||
= render Attachment::GalleryItemComponent.new(attachment:)
|
||||
= render Attachment::GalleryItemComponent.new(attachment:, seen_at: @pieces_jointes_seen_at)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue