fix(champ_label_component): add missing helpers
This commit is contained in:
parent
93f6f22c9e
commit
93e3f5877e
2 changed files with 15 additions and 1 deletions
|
@ -2,4 +2,18 @@ class EditableChamp::ChampLabelContentComponent < ApplicationComponent
|
||||||
def initialize(champ:, seen_at: nil)
|
def initialize(champ:, seen_at: nil)
|
||||||
@champ, @seen_at = champ, seen_at
|
@champ, @seen_at = champ, seen_at
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
%span.mandatory *
|
%span.mandatory *
|
||||||
|
|
||||||
- if @champ.updated_at.present? && @seen_at.present?
|
- 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)}"
|
= "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)
|
- if @champ.rebased_at.present? && @champ.rebased_at > (@seen_at || @champ.updated_at) && controller.current_user.owns_or_invite?(@champ.dossier)
|
||||||
|
|
Loading…
Reference in a new issue