diff --git a/app/components/editable_champ/champ_label_content_component.rb b/app/components/editable_champ/champ_label_content_component.rb index 44cf3ece6..9981e297b 100644 --- a/app/components/editable_champ/champ_label_content_component.rb +++ b/app/components/editable_champ/champ_label_content_component.rb @@ -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 diff --git a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml index 8d13141a6..9ac355378 100644 --- a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml +++ b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml @@ -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)