feat(gallery): add badge for date of created_at or updated_at
This commit is contained in:
parent
3560d73b58
commit
df08617387
6 changed files with 36 additions and 0 deletions
|
@ -13,6 +13,10 @@
|
|||
object-fit: cover;
|
||||
}
|
||||
|
||||
.champ-updated {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
position: relative;
|
||||
display: flex;
|
||||
|
|
|
@ -34,4 +34,23 @@ class Attachment::GalleryItemComponent < ApplicationComponent
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def created_at
|
||||
attachment.record.created_at
|
||||
end
|
||||
|
||||
def updated?
|
||||
attachment.record.class.in?([Champs::PieceJustificativeChamp, Champs::TitreIdentiteChamp]) && updated_at > attachment.record.dossier.depose_at
|
||||
end
|
||||
|
||||
def updated_at
|
||||
blob.created_at
|
||||
end
|
||||
|
||||
def badge_updated_class
|
||||
class_names(
|
||||
"fr-badge fr-badge--sm" => true,
|
||||
"fr-badge--new" => updated?
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
en:
|
||||
created_at: "Added on %{datetime}"
|
||||
updated_at: "Updated on %{datetime}"
|
|
@ -0,0 +1,3 @@
|
|||
fr:
|
||||
created_at: "Ajoutée le %{datetime}"
|
||||
updated_at: "Modifiée le %{datetime}"
|
|
@ -1,4 +1,7 @@
|
|||
.gallery-item
|
||||
- if !gallery_demande?
|
||||
.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)
|
||||
= gallery_link(blob) do
|
||||
.thumbnail
|
||||
|
|
|
@ -25,6 +25,10 @@ RSpec.describe Attachment::GalleryItemComponent, type: :component do
|
|||
expect(component.title).to eq("#{libelle} -- #{filename}")
|
||||
end
|
||||
|
||||
it "displays when gallery item has been added" do
|
||||
expect(subject).to have_text(component.helpers.try_format_datetime(attachment.record.created_at, format: :veryshort))
|
||||
end
|
||||
|
||||
context "when gallery item is in page Demande" do
|
||||
let(:gallery_demande) { true }
|
||||
|
||||
|
|
Loading…
Reference in a new issue