Merge pull request #7749 from mfo/fix/annotations-privees-suivis

fix(champ_label_component): add missing helpers
This commit is contained in:
mfo 2022-09-09 12:11:28 +02:00 committed by GitHub
commit ec94fb25cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -2,4 +2,18 @@ class EditableChamp::ChampLabelContentComponent < ApplicationComponent
def initialize(champ:, seen_at: nil)
@champ, @seen_at = champ, seen_at
end
def highlight_if_unseen_class
if highlight?
'highlighted'
end
end
def highlight?
@champ.updated_at.present? && @seen_at&.<(@champ.updated_at)
end
def try_format_datetime(datetime)
datetime.present? ? I18n.l(datetime) : ''
end
end

View file

@ -3,7 +3,7 @@
%span.mandatory *
- if @champ.updated_at.present? && @seen_at.present?
%span.updated-at{ class: highlight_if_unseen_class(@seen_at, @champ.updated_at) }
%span.updated-at{ class: highlight_if_unseen_class }
= "modifié le #{try_format_datetime(@champ.updated_at)}"
- if @champ.rebased_at.present? && @champ.rebased_at > (@seen_at || @champ.updated_at) && controller.current_user.owns_or_invite?(@champ.dossier)