Refactor map locations helper
This commit is contained in:
@@ -32,21 +32,7 @@ module MapLocationsHelper
|
|||||||
map = content_tag_for :div,
|
map = content_tag_for :div,
|
||||||
map_location,
|
map_location,
|
||||||
class: "map",
|
class: "map",
|
||||||
data:{
|
data: prepare_map_settings(map_location, editable, parent_class)
|
||||||
map: "",
|
|
||||||
map_center_latitude: map_location_latitude(map_location),
|
|
||||||
map_center_longitude: map_location_longitude(map_location),
|
|
||||||
map_zoom: map_location_zoom(map_location),
|
|
||||||
map_tiles_attribution_selector: map_location_attribution_id(map_location),
|
|
||||||
map_tiles_provider: "//{s}.tile.osm.org/{z}/{x}/{y}.png",
|
|
||||||
marker_editable: editable,
|
|
||||||
marker_latitude: map_location.latitude,
|
|
||||||
marker_longitude: map_location.longitude,
|
|
||||||
marker_remove_selector: "##{map_location_remove_marker_link_id(map_location)}",
|
|
||||||
latitude_input_selector: "##{map_location_input_id(parent_class, 'latitude')}",
|
|
||||||
longitude_input_selector: "##{map_location_input_id(parent_class, 'longitude')}",
|
|
||||||
zoom_input_selector: "##{map_location_input_id(parent_class, 'zoom')}"
|
|
||||||
}
|
|
||||||
map += map_attributtion(map_location)
|
map += map_attributtion(map_location)
|
||||||
map += map_location_remove_marker(map_location, remove_marker_label) if editable
|
map += map_location_remove_marker(map_location, remove_marker_label) if editable
|
||||||
map
|
map
|
||||||
@@ -69,4 +55,24 @@ module MapLocationsHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def prepare_map_settings(map_location, editable, parent_class)
|
||||||
|
options = {
|
||||||
|
map: "",
|
||||||
|
map_center_latitude: map_location_latitude(map_location),
|
||||||
|
map_center_longitude: map_location_longitude(map_location),
|
||||||
|
map_zoom: map_location_zoom(map_location),
|
||||||
|
map_tiles_attribution_selector: map_location_attribution_id(map_location),
|
||||||
|
map_tiles_provider: "//{s}.tile.osm.org/{z}/{x}/{y}.png",
|
||||||
|
marker_editable: editable,
|
||||||
|
marker_latitude: map_location.latitude,
|
||||||
|
marker_longitude: map_location.longitude,
|
||||||
|
marker_remove_selector: "##{map_location_remove_marker_link_id(map_location)}",
|
||||||
|
latitude_input_selector: "##{map_location_input_id(parent_class, 'latitude')}",
|
||||||
|
longitude_input_selector: "##{map_location_input_id(parent_class, 'longitude')}",
|
||||||
|
zoom_input_selector: "##{map_location_input_id(parent_class, 'zoom')}"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<%= form.label :map_location, label %>
|
<%= form.label :map_location, label %>
|
||||||
<p class="help-text" id="tag-list-help-text"><%= help %></p>
|
<p class="help-text" id="tag-list-help-text"><%= help %></p>
|
||||||
|
|
||||||
<%= render_map(map_location, parent_class, true, remove_marker_label) %>
|
<%= render_map(map_location, parent_class, editable = true, remove_marker_label) %>
|
||||||
|
|
||||||
<%= form.fields_for :map_location, map_location do |m_l_fields| %>
|
<%= form.fields_for :map_location, map_location do |m_l_fields| %>
|
||||||
<%= m_l_fields.hidden_field :latitude,
|
<%= m_l_fields.hidden_field :latitude,
|
||||||
|
|||||||
Reference in New Issue
Block a user