diff --git a/app/components/shared/map_location_component.html.erb b/app/components/shared/map_location_component.html.erb index 6a5084f95..38cf42d35 100644 --- a/app/components/shared/map_location_component.html.erb +++ b/app/components/shared/map_location_component.html.erb @@ -1,5 +1,5 @@ -<%= tag.div(id: dom_id(map_location), class: "map_location map", data: prepare_map_settings) %> +<%= tag.div(id: dom_id(map_location), class: "map_location map", data: data) %> <% if editable %> - <%= map_location_remove_marker %> + <%= remove_marker %> <% end %> diff --git a/app/components/shared/map_location_component.rb b/app/components/shared/map_location_component.rb index 4b317c51e..1db74b044 100644 --- a/app/components/shared/map_location_component.rb +++ b/app/components/shared/map_location_component.rb @@ -16,40 +16,40 @@ class Shared::MapLocationComponent < ApplicationComponent private - def map_location_latitude + def latitude map_location.latitude.presence || Setting["map.latitude"] end - def map_location_longitude + def longitude map_location.longitude.presence || Setting["map.longitude"] end - def map_location_zoom + def zoom map_location.zoom.presence || Setting["map.zoom"] end - def map_location_remove_marker_link_id + def remove_marker_link_id "remove-marker-link-#{dom_id(map_location)}" end - def map_location_remove_marker + def remove_marker tag.div class: "margin-bottom" do link_to remove_marker_label, "#", - id: map_location_remove_marker_link_id, + id: remove_marker_link_id, class: "js-location-map-remove-marker location-map-remove-marker" end end - def prepare_map_settings + def data options = { map: "", - map_center_latitude: map_location_latitude, - map_center_longitude: map_location_longitude, - map_zoom: map_location_zoom, + map_center_latitude: latitude, + map_center_longitude: longitude, + map_zoom: zoom, map_tiles_provider: Rails.application.secrets.map_tiles_provider, map_tiles_provider_attribution: Rails.application.secrets.map_tiles_provider_attribution, marker_editable: editable, - marker_remove_selector: "##{map_location_remove_marker_link_id}", + marker_remove_selector: "##{remove_marker_link_id}", 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")}",