demarches-normaliennes/app/components/editable_champ/champ_label_content_component.rb

33 lines
767 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2022-08-12 10:45:04 +02:00
class EditableChamp::ChampLabelContentComponent < ApplicationComponent
include ApplicationHelper
2023-05-05 09:13:05 +02:00
include Dsfr::InputErrorable
attr_reader :attribute
2023-05-05 09:13:05 +02:00
def initialize(form:, champ:, seen_at: nil)
@form, @champ, @seen_at = form, champ, seen_at
@attribute = :value
2022-08-12 10:45:04 +02:00
end
def highlight_if_unseen_class
if highlight?
'highlighted'
end
end
def highlight?
@champ.updated_at.present? && @seen_at&.<(@champ.updated_at)
end
def rebased?
return false if @champ.rebased_at.blank?
return false if @champ.rebased_at <= (@seen_at || @champ.updated_at)
return false if !current_user.owns_or_invite?(@champ.dossier)
return false if @champ.dossier.for_procedure_preview?
true
end
2022-08-12 10:45:04 +02:00
end