[#1421] Move departements to DepartementChamp
This commit is contained in:
parent
5b59bce0b6
commit
0239f936d7
6 changed files with 7 additions and 8 deletions
|
@ -19,10 +19,6 @@ class Champ < ApplicationRecord
|
|||
mandatory? && value.blank?
|
||||
end
|
||||
|
||||
def self.departements
|
||||
JSON.parse(Carto::GeoAPI::Driver.departements).map { |liste| "#{liste['code']} - #{liste['nom']}" }.push('99 - Étranger')
|
||||
end
|
||||
|
||||
def self.pays
|
||||
JSON.parse(Carto::GeoAPI::Driver.pays).pluck("nom")
|
||||
end
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
class Champs::DepartementChamp < Champs::TextChamp
|
||||
def self.departements
|
||||
JSON.parse(Carto::GeoAPI::Driver.departements).map { |liste| "#{liste['code']} - #{liste['nom']}" }.push('99 - Étranger')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.select :value,
|
||||
Champ.departements,
|
||||
Champs::DepartementChamp.departements,
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
= select_tag("champs['#{champ.id}']",
|
||||
options_for_select(Champ.departements, selected: champ.object.value))
|
||||
options_for_select(Champs::DepartementChamp.departements, selected: champ.object.value))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue