Merge pull request #6749 from betagouv/zonage
rend le zonage disponible derrière le feature flag _zonage_ groupe les options lors de la séléction de la zone
This commit is contained in:
commit
e5bf318178
8 changed files with 41 additions and 35 deletions
9
app/helpers/zone_helper.rb
Normal file
9
app/helpers/zone_helper.rb
Normal 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
|
|
@ -13,10 +13,11 @@
|
|||
%span.mandatory *
|
||||
= f.text_area :description, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control'
|
||||
|
||||
= f.label :zone do
|
||||
= t('zone', scope: 'activerecord.attributes.procedure')
|
||||
%span.mandatory *
|
||||
= f.collection_select :zone_id, Zone.order(:label), :id, :label, prompt: true
|
||||
- if Flipper.enabled? :zonage
|
||||
= f.label :zone do
|
||||
= t('zone', scope: 'activerecord.attributes.procedure')
|
||||
%span.mandatory *
|
||||
= f.select :zone_id, grouped_options_for_zone
|
||||
|
||||
%h3.header-subsection Logo de la démarche
|
||||
= image_upload_and_render f, @procedure.logo
|
||||
|
|
|
@ -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 d’un 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:
|
||||
|
|
|
@ -13,13 +13,13 @@ ministeres:
|
|||
label: "Ministère de l'Économie, des Finances et de la Relance"
|
||||
- MJS:
|
||||
label: "Ministère de la Jeunesse et des Sports"
|
||||
- EN:
|
||||
- MEN:
|
||||
label: "Ministère de l'Éducation nationale, de la Jeunesse et des Sports"
|
||||
- ESR:
|
||||
label: "Ministère de l'Enseignement supérieur, de la Recherche et de l'Innovation"
|
||||
- MI:
|
||||
label: "Ministère de l'Intérieur"
|
||||
- MInArm:
|
||||
- MINARM:
|
||||
label: "Ministère des Armées"
|
||||
- MJ:
|
||||
label: "Ministère de la Justice"
|
||||
|
@ -27,7 +27,7 @@ ministeres:
|
|||
label: "Ministère de la Transition écologique"
|
||||
- MCTRCT:
|
||||
label: "Ministère de la Cohésion des territoires et des Relations avec les collectivités territoriales"
|
||||
- SPM:
|
||||
- PM:
|
||||
label: "Premier ministre"
|
||||
- MER:
|
||||
label: "Ministère de la Mer"
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: populate_zones'
|
||||
task populate_zones: :environment do
|
||||
puts "Running deploy task 'populate_zones'"
|
||||
|
||||
Zone.create!(acronym: 'COLLECTIVITE', label: 'Collectivité territoriale')
|
||||
config = Psych.safe_load(File.read(Rails.root.join("config", "zones.yml")))
|
||||
config["ministeres"].each do |ministere|
|
||||
acronym = ministere.keys.first
|
||||
Zone.create!(acronym: acronym, label: ministere["label"])
|
||||
end
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord
|
||||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
10
lib/tasks/populate_zones.rake
Normal file
10
lib/tasks/populate_zones.rake
Normal file
|
@ -0,0 +1,10 @@
|
|||
task populate_zones: :environment do
|
||||
puts "Running deploy task 'populate_zones'"
|
||||
|
||||
Zone.create!(acronym: 'COLLECTIVITE', label: 'Collectivité territoriale')
|
||||
config = Psych.safe_load(File.read(Rails.root.join("config", "zones.yml")))
|
||||
config["ministeres"].each do |ministere|
|
||||
acronym = ministere.keys.first
|
||||
Zone.create!(acronym: acronym, label: ministere["label"])
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
describe '20211116140232_populate_zones' do
|
||||
let(:rake_task) { Rake::Task['after_party:populate_zones'] }
|
||||
subject(:run_task) do
|
||||
rake_task.invoke
|
||||
end
|
||||
|
||||
it 'populates zones' do
|
||||
run_task
|
||||
expect(Zone.find_by(acronym: 'SPM').label).to eq "Premier ministre"
|
||||
end
|
||||
end
|
11
spec/lib/tasks/populate_zones_spec.rb
Normal file
11
spec/lib/tasks/populate_zones_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
describe 'populate_zones' do
|
||||
let(:rake_task) { Rake::Task['populate_zones'] }
|
||||
subject(:run_task) do
|
||||
rake_task.invoke
|
||||
end
|
||||
|
||||
it 'populates zones' do
|
||||
run_task
|
||||
expect(Zone.find_by(acronym: 'PM').label).to eq "Premier ministre"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue