diff --git a/app/controllers/administrateurs/procedures_controller.rb b/app/controllers/administrateurs/procedures_controller.rb index c8c59adbf..1e50c6130 100644 --- a/app/controllers/administrateurs/procedures_controller.rb +++ b/app/controllers/administrateurs/procedures_controller.rb @@ -351,7 +351,7 @@ module Administrateurs :monavis_embed, :api_entreprise_token, :duree_conservation_dossiers_dans_ds, - :zone_id, + { zone_ids: [] }, :lien_dpo, :opendata, :procedure_expires_when_termine_enabled diff --git a/app/helpers/zone_helper.rb b/app/helpers/zone_helper.rb deleted file mode 100644 index 5275c9899..000000000 --- a/app/helpers/zone_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -module ZoneHelper - def grouped_options_for_zone(date) - date ||= Time.zone.now - collectivite = Zone.find_by(acronym: "COLLECTIVITE") - { - "--" => [ - [I18n.t('i_dont_know', scope: 'utils'), nil], - [collectivite.label, collectivite.id] - ], - I18n.t('ministeres', scope: 'zones') => (Zone.available_at(date) - [collectivite]).map { |m| [m.label_at(date), m.id] } - } - end -end diff --git a/app/models/zone.rb b/app/models/zone.rb index aa13a174b..5d34310da 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -28,5 +28,8 @@ class Zone < ApplicationRecord def self.available_at(date) Zone.all.filter { |zone| zone.available_at?(date) }.sort_by { |zone| zone.label_at(date) } + .map do |zone| + OpenStruct.new(id: zone.id, label: zone.label_at(date)) + end end end diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index 695584dba..b3c8c8e5b 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -14,10 +14,10 @@ = f.text_area :description, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control' - if Flipper.enabled? :zonage - = f.label :zone do - = t('zone', scope: 'activerecord.attributes.procedure') - %span.mandatory * - = f.select :zone_id, grouped_options_for_zone(@procedure.published_or_created_at) + = f.collection_check_boxes :zone_ids, Zone.available_at(@procedure.published_or_created_at), :id, :label do |b| + .editable-champ.editable-champ-checkbox + = b.check_box + = b.label %h3.header-subsection Logo de la démarche = render Attachment::EditComponent.new(form: f, attached_file: @procedure.logo, direct_upload: true, user_can_destroy: true) diff --git a/spec/models/zone_spec.rb b/spec/models/zone_spec.rb index 0d31d7721..085c4bb2e 100644 --- a/spec/models/zone_spec.rb +++ b/spec/models/zone_spec.rb @@ -114,8 +114,8 @@ describe Zone do end it 'returns only available zones at specific date' do - expect(Zone.available_at(start_last_government + 1.day)).to eq [culture] - expect(Zone.available_at(start_previous_government + 1.day)).to eq [culture, om] + expect(Zone.available_at(start_last_government + 1.day).map(&:label)).to eq ["Ministère de la Culture"] + expect(Zone.available_at(start_previous_government + 1.day).map(&:label)).to eq ["Ministère de la Culture", "Ministère des Outre-mer"] end end end