2018-08-14 15:17:22 +02:00
|
|
|
module ProcedureHelper
|
|
|
|
def procedure_lien(procedure)
|
2018-09-13 18:33:35 +02:00
|
|
|
if procedure.path.present?
|
2018-08-14 15:17:22 +02:00
|
|
|
if procedure.brouillon_avec_lien?
|
|
|
|
commencer_test_url(procedure_path: procedure.path)
|
|
|
|
else
|
|
|
|
commencer_url(procedure_path: procedure.path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def procedure_libelle(procedure)
|
2018-09-18 14:10:15 +02:00
|
|
|
parts = procedure.brouillon? ? [content_tag(:span, 'démarche non publiée', class: 'badge')] : []
|
|
|
|
parts << procedure.libelle
|
|
|
|
safe_join(parts, ' ')
|
2018-08-14 15:17:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def procedure_modal_text(procedure, key)
|
|
|
|
action = procedure.archivee? ? :reopen : :publish
|
|
|
|
t(action, scope: [:modal, :publish, key])
|
|
|
|
end
|
2018-08-30 23:51:50 +02:00
|
|
|
|
|
|
|
def dossiers_deletion_warning(procedure)
|
|
|
|
dossiers_count = procedure.dossiers.state_not_brouillon.count
|
|
|
|
brouillons_count = procedure.dossiers.state_brouillon.count
|
|
|
|
formatted_dossiers_count = nil
|
|
|
|
formatted_brouillons_count = nil
|
|
|
|
|
|
|
|
if dossiers_count > 0
|
|
|
|
formatted_dossiers_count = pluralize(dossiers_count, "dossier", "dossiers")
|
|
|
|
end
|
|
|
|
|
|
|
|
if brouillons_count > 0
|
|
|
|
formatted_brouillons_count = pluralize(brouillons_count, "brouillon", "brouillons")
|
|
|
|
end
|
|
|
|
|
|
|
|
formatted_combination = [formatted_dossiers_count, formatted_brouillons_count]
|
|
|
|
.compact
|
|
|
|
.join(" et ")
|
|
|
|
|
|
|
|
[
|
|
|
|
formatted_combination,
|
|
|
|
dossiers_count + brouillons_count == 1 ? "est rattaché" : "sont rattachés",
|
2018-09-05 14:48:42 +02:00
|
|
|
"à cette démarche, la suppression de cette démarche entrainera également leur suppression."
|
2018-08-30 23:51:50 +02:00
|
|
|
].join(" ")
|
|
|
|
end
|
2018-08-14 15:17:22 +02:00
|
|
|
end
|