Merge branch 'rails' into anonymous
This commit is contained in:
commit
ce805de4cc
5 changed files with 57 additions and 0 deletions
23
app/models/metadata_geo.rb
Normal file
23
app/models/metadata_geo.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Define un campo de coordenadas geográficas
|
||||
class MetadataGeo < MetadataTemplate
|
||||
def default_value
|
||||
{ 'lat' => nil, 'lng' => nil }
|
||||
end
|
||||
|
||||
def empty?
|
||||
value == default_value
|
||||
end
|
||||
|
||||
def to_param
|
||||
{ name => %i[lat lng] }
|
||||
end
|
||||
|
||||
def save
|
||||
self[:value] = {
|
||||
'lat' => self[:value]['lat'].to_f,
|
||||
'lng' => self[:value]['lng'].to_f
|
||||
}
|
||||
end
|
||||
end
|
9
app/views/posts/attribute_ro/_geo.haml
Normal file
9
app/views/posts/attribute_ro/_geo.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
- lat = metadata.value['lat']
|
||||
- lng = metadata.value['lng']
|
||||
%tr{ id: attribute }
|
||||
%th= post_label_t(attribute, post: post)
|
||||
%td
|
||||
= link_to t('posts.attributes.geo.uri'), "geo:#{lat},#{lng}"
|
||||
%br/
|
||||
= link_to t('posts.attributes.geo.osm'),
|
||||
"https://www.openstreetmap.org/?mlat=#{lat}&mlon=#{lng}#map=9/#{lat}/#{lng}"
|
19
app/views/posts/attributes/_geo.haml
Normal file
19
app/views/posts/attributes/_geo.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
.row
|
||||
.col
|
||||
.form-group
|
||||
= label_tag "post_#{attribute}_lat",
|
||||
post_label_t(attribute, :lat, post: post)
|
||||
= text_field(*field_name_for('post', attribute, :lat),
|
||||
value: metadata.value['lat'],
|
||||
**field_options(attribute, metadata))
|
||||
= render 'posts/attribute_feedback',
|
||||
post: post, attribute: [attribute, :lat], metadata: metadata
|
||||
.col
|
||||
.form-group
|
||||
= label_tag "post_#{attribute}_lng",
|
||||
post_label_t(attribute, :lng, post: post)
|
||||
= text_field(*field_name_for('post', attribute, :lng),
|
||||
value: metadata.value['lng'],
|
||||
**field_options(attribute, metadata))
|
||||
= render 'posts/attribute_feedback',
|
||||
post: post, attribute: [attribute, :lat], metadata: metadata
|
|
@ -365,6 +365,9 @@ en:
|
|||
feedback: 'This field cannot be empty!'
|
||||
uuid:
|
||||
label: 'Unique identifier'
|
||||
geo:
|
||||
uri: 'Open in app'
|
||||
osm: 'Open in web map'
|
||||
reorder: 'Reorder posts'
|
||||
sort:
|
||||
by: 'Sort by'
|
||||
|
|
|
@ -373,6 +373,9 @@ es:
|
|||
feedback: '¡Este campo no puede estar vacío!'
|
||||
uuid:
|
||||
label: 'Identificador único'
|
||||
geo:
|
||||
uri: 'Abrir en aplicación'
|
||||
osm: 'Abrir en mapa web'
|
||||
reorder: 'Reordenar artículos'
|
||||
sort:
|
||||
by: 'Ordenar por'
|
||||
|
|
Loading…
Reference in a new issue