chore(manager/services): show etablissement adresse & geopoint
This commit is contained in:
parent
67cbc61e1e
commit
9d59a50cd4
5 changed files with 35 additions and 2 deletions
|
@ -19,7 +19,9 @@ class ServiceDashboard < Administrate::BaseDashboard
|
||||||
telephone: Field::String,
|
telephone: Field::String,
|
||||||
horaires: Field::String,
|
horaires: Field::String,
|
||||||
adresse: Field::String,
|
adresse: Field::String,
|
||||||
siret: Field::String
|
siret: Field::String,
|
||||||
|
etablissement_adresse: Field::String,
|
||||||
|
etablissement_latlng: GeopointField
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# COLLECTION_ATTRIBUTES
|
# COLLECTION_ATTRIBUTES
|
||||||
|
@ -46,7 +48,9 @@ class ServiceDashboard < Administrate::BaseDashboard
|
||||||
:telephone,
|
:telephone,
|
||||||
:horaires,
|
:horaires,
|
||||||
:adresse,
|
:adresse,
|
||||||
:siret
|
:siret,
|
||||||
|
:etablissement_adresse,
|
||||||
|
:etablissement_latlng
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
# FORM_ATTRIBUTES
|
# FORM_ATTRIBUTES
|
||||||
|
|
11
app/fields/geopoint_field.rb
Normal file
11
app/fields/geopoint_field.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
require "administrate/field/base"
|
||||||
|
|
||||||
|
class GeopointField < Administrate::Field::Base
|
||||||
|
def lat
|
||||||
|
data.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def lng
|
||||||
|
data.last
|
||||||
|
end
|
||||||
|
end
|
|
@ -63,6 +63,10 @@ class Service < ApplicationRecord
|
||||||
etablissement_infos.fetch("adresse", nil)
|
etablissement_infos.fetch("adresse", nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def etablissement_latlng
|
||||||
|
[etablissement_lat, etablissement_lng]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def enqueue_api_entreprise
|
def enqueue_api_entreprise
|
||||||
|
|
2
app/views/fields/geopoint_field/_show.html.haml
Normal file
2
app/views/fields/geopoint_field/_show.html.haml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
- if field.data.present?
|
||||||
|
= link_to field.data.join(", "), "https://www.geoportail.gouv.fr/carte?c=#{field.lng},#{field.lat}&z=17&permalink=yes", target: '_blank', rel: 'noopener'
|
|
@ -136,4 +136,16 @@ describe Service, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'etablissement_latlng' do
|
||||||
|
it 'without coordinates' do
|
||||||
|
service = build(:service, etablissement_lat: nil, etablissement_lng: nil)
|
||||||
|
expect(service.etablissement_latlng).to eq([nil, nil])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'with coordinates' do
|
||||||
|
service = build(:service)
|
||||||
|
expect(service.etablissement_latlng).to eq([48.87, 2.34])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue