group related options in zone select box

This commit is contained in:
Christophe Robillard 2021-12-14 13:54:26 +01:00
parent 99665d8119
commit 829d644c10
3 changed files with 13 additions and 1 deletions

View file

@ -0,0 +1,9 @@
module ZoneHelper
def grouped_options_for_zone
collectivite = Zone.find_by(acronym: "COLLECTIVITE")
{
"--" => [[I18n.t('i_dont_know', scope: 'utils'), nil], [collectivite.label, collectivite.id]],
I18n.t('ministeres', scope: 'zones') => (Zone.order(:label) - [collectivite]).map { |m| [m.label, m.id] }
}
end
end

View file

@ -16,7 +16,7 @@
= f.label :zone do
= t('zone', scope: 'activerecord.attributes.procedure')
%span.mandatory *
= f.collection_select :zone_id, Zone.order(:label), :id, :label, prompt: true
= f.select :zone_id, grouped_options_for_zone
%h3.header-subsection Logo de la démarche
= image_upload_and_render f, @procedure.logo

View file

@ -24,6 +24,7 @@ fr:
utils:
'yes': Oui
'no': Non
i_dont_know: Je ne sais pas
deconnexion: "Déconnexion"
pj: "Pièces jointes"
asterisk_html: Les champs suivis dun astérisque ( <span class = mandatory> * </span> ) sont obligatoires.
@ -442,6 +443,8 @@ fr:
ready: "Validé"
needs_configuration: "À configurer"
configure_api_particulier_token: "Configurer le jeton API particulier"
zones:
ministeres: Ministères
france_connect:
particulier:
password_confirmation: