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,
|
||||
horaires: Field::String,
|
||||
adresse: Field::String,
|
||||
siret: Field::String
|
||||
siret: Field::String,
|
||||
etablissement_adresse: Field::String,
|
||||
etablissement_latlng: GeopointField
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
|
@ -46,7 +48,9 @@ class ServiceDashboard < Administrate::BaseDashboard
|
|||
:telephone,
|
||||
:horaires,
|
||||
:adresse,
|
||||
:siret
|
||||
:siret,
|
||||
:etablissement_adresse,
|
||||
:etablissement_latlng
|
||||
].freeze
|
||||
|
||||
# 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)
|
||||
end
|
||||
|
||||
def etablissement_latlng
|
||||
[etablissement_lat, etablissement_lng]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue