feat(dossier): use new combobox on champ adresse
This commit is contained in:
parent
ae450a2d2b
commit
89582d2e09
3 changed files with 14 additions and 12 deletions
11
app/controllers/data_sources/adresse_controller.rb
Normal file
11
app/controllers/data_sources/adresse_controller.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class DataSources::AdresseController < ApplicationController
|
||||
def search
|
||||
if params[:q].present? && params[:q].length > 3
|
||||
response = Typhoeus.get("#{API_ADRESSE_URL}/search", params: { q: params[:q], limit: 10 })
|
||||
result = JSON.parse(response.body, symbolize_names: true)
|
||||
render json: result[:features].map { { label: _1[:properties][:label], value: _1[:properties][:label] } }
|
||||
else
|
||||
render json: []
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue