Merge pull request #9628 from tchak/fix-departement-epci
fix(epci): do not show let select departements with no epci
This commit is contained in:
commit
566b6b186e
7 changed files with 16 additions and 3 deletions
|
@ -8,7 +8,7 @@ class EditableChamp::EpciComponent < EditableChamp::EditableChampBaseComponent
|
||||||
private
|
private
|
||||||
|
|
||||||
def departement_options
|
def departement_options
|
||||||
APIGeoService.departements.filter { _1[:code] != '99' }.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
APIGeoService.departements.filter(&method(:departement_with_epci?)).map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def epci_options
|
def epci_options
|
||||||
|
@ -26,4 +26,9 @@ class EditableChamp::EpciComponent < EditableChamp::EditableChampBaseComponent
|
||||||
def epci_select_options
|
def epci_select_options
|
||||||
{ selected: @champ.code }.merge(@champ.mandatory? ? { prompt: '' } : { include_blank: '' })
|
{ selected: @champ.code }.merge(@champ.mandatory? ? { prompt: '' } : { include_blank: '' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def departement_with_epci?(departement)
|
||||||
|
code = departement[:code]
|
||||||
|
!code.start_with?('98') && !code.in?(['99', '975', '977', '978'])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
1
lib/data/api_geo/epcis-984.json
Normal file
1
lib/data/api_geo/epcis-984.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[]
|
1
lib/data/api_geo/epcis-986.json
Normal file
1
lib/data/api_geo/epcis-986.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[]
|
1
lib/data/api_geo/epcis-987.json
Normal file
1
lib/data/api_geo/epcis-987.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[]
|
1
lib/data/api_geo/epcis-988.json
Normal file
1
lib/data/api_geo/epcis-988.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[]
|
1
lib/data/api_geo/epcis-989.json
Normal file
1
lib/data/api_geo/epcis-989.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[]
|
|
@ -10,8 +10,11 @@ namespace :api_geo_data do
|
||||||
departements = get_from_api_geo('departements?zone=metro,drom,com', 'departements')
|
departements = get_from_api_geo('departements?zone=metro,drom,com', 'departements')
|
||||||
departements.each do |departement|
|
departements.each do |departement|
|
||||||
departement_code = departement[:code]
|
departement_code = departement[:code]
|
||||||
if !departement_code.start_with?('98')
|
epci_filename = "epcis-#{departement_code}"
|
||||||
get_from_api_geo("epcis?codeDepartement=#{departement_code}", "epcis-#{departement_code}")
|
if departement_code.start_with?('98')
|
||||||
|
PATH.join("#{epci_filename}.json").write(JSON.dump([]))
|
||||||
|
else
|
||||||
|
get_from_api_geo("epcis?codeDepartement=#{departement_code}", epci_filename)
|
||||||
end
|
end
|
||||||
get_from_api_geo("communes?codeDepartement=#{departement_code}&type=commune-actuelle,arrondissement-municipal", "communes-#{departement_code}")
|
get_from_api_geo("communes?codeDepartement=#{departement_code}&type=commune-actuelle,arrondissement-municipal", "communes-#{departement_code}")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue