demarches-normaliennes/app/helpers/dossier_helper.rb

52 lines
1.2 KiB
Ruby
Raw Normal View History

module DossierHelper
def button_or_label_class(dossier)
2017-12-04 18:00:12 +01:00
if dossier.accepte?
'accepted'
elsif dossier.sans_suite?
'without-continuation'
2017-12-04 18:15:40 +01:00
elsif dossier.refuse?
'refuse'
end
end
def highlight_if_unseen_class(seen_at, updated_at)
if seen_at&.<(updated_at)
"highlighted"
end
end
def url_for_dossier(dossier)
if dossier.brouillon?
brouillon_dossier_path(dossier)
else
2018-10-02 12:23:53 +02:00
dossier_path(dossier)
end
end
def dossier_submission_is_closed?(dossier)
dossier.brouillon? && dossier.procedure.archivee?
end
2018-11-06 18:44:32 +01:00
def dossier_display_state(dossier, lower: false)
state = I18n.t(dossier.state, scope: [:activerecord, :attributes, :dossier, :state])
lower ? state.downcase : state
end
2018-11-07 14:46:22 +01:00
def dossier_legacy_state(dossier)
case dossier.state
when Dossier.states.fetch(:en_construction)
'initiated'
when Dossier.states.fetch(:en_instruction)
'received'
when Dossier.states.fetch(:accepte)
'closed'
when Dossier.states.fetch(:refuse)
'refused'
when Dossier.states.fetch(:sans_suite)
'without_continuation'
else
dossier.state
end
end
end