Simplify code setting marker data in maps
We were probably setting them separately to avoid having blank data attributes in the HTML. However, when a data attribute is `nil`, Rails doesn't write it in the HTML in the first place.
This commit is contained in:
@@ -44,7 +44,7 @@ class Shared::MapLocationComponent < ApplicationComponent
|
|||||||
end
|
end
|
||||||
|
|
||||||
def data
|
def data
|
||||||
options = {
|
{
|
||||||
map: "",
|
map: "",
|
||||||
map_center_latitude: latitude,
|
map_center_latitude: latitude,
|
||||||
map_center_longitude: longitude,
|
map_center_longitude: longitude,
|
||||||
@@ -56,10 +56,9 @@ class Shared::MapLocationComponent < ApplicationComponent
|
|||||||
latitude_input_selector: "##{map_location_input_id(parent_class, "latitude")}",
|
latitude_input_selector: "##{map_location_input_id(parent_class, "latitude")}",
|
||||||
longitude_input_selector: "##{map_location_input_id(parent_class, "longitude")}",
|
longitude_input_selector: "##{map_location_input_id(parent_class, "longitude")}",
|
||||||
zoom_input_selector: "##{map_location_input_id(parent_class, "zoom")}",
|
zoom_input_selector: "##{map_location_input_id(parent_class, "zoom")}",
|
||||||
marker_investments_coordinates: investments_coordinates
|
marker_investments_coordinates: investments_coordinates,
|
||||||
|
marker_latitude: map_location.latitude.presence,
|
||||||
|
marker_longitude: map_location.longitude.presence
|
||||||
}
|
}
|
||||||
options[:marker_latitude] = map_location.latitude if map_location.latitude.present?
|
|
||||||
options[:marker_longitude] = map_location.longitude if map_location.longitude.present?
|
|
||||||
options
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user