Commit 89039023 authored by Alexandre Friquet's avatar Alexandre Friquet

More readable code: refs #12.

parent ab410910
......@@ -111,15 +111,13 @@ class MemberGroupsController < ApplicationController
base_members = base_members.localized
@published_members = base_members.published
@private_members = base_members.not_published
@markers = [].tap do |markers|
base_members.each do |member|
markers << {
latlng: [member.latitude, member.longitude],
title: member.name,
popup: render_to_string(partial: "/members/infowindow", locals: { member: member}),
icon: (member.published ? :blue : :grey)
}
end
@markers = base_members.map do |member|
{
latlng: [member.latitude, member.longitude],
title: member.name,
popup: render_to_string(partial: "/members/infowindow", locals: { member: member}),
icon: (member.published ? :blue : :grey)
}
end
else
authorize
......
......@@ -66,20 +66,18 @@ class MembersController < ApplicationController
else
requested_groups = []
end
@markers = [].tap do |markers|
@members.each do |member|
color = if !member.member_groups.empty? && (mg = (member.member_groups & requested_groups).first) && @legend[mg.id].present?
@legend[mg.id][:color]
else
default_color
end
markers << {
latlng: [member.latitude, member.longitude],
title: member.name,
popup: render_to_string(partial: "/members/infowindow", locals: { member: member}),
icon: color
}
@markers = @members.map do |member|
color = if !member.member_groups.empty? && (mg = (member.member_groups & requested_groups).first) && @legend[mg.id].present?
@legend[mg.id][:color]
else
default_color
end
{
latlng: [member.latitude, member.longitude],
title: member.name,
popup: render_to_string(partial: "/members/infowindow", locals: { member: member}),
icon: color
}
end
end
end
......
module MapHelper
def tailored_map(markers)
update_icon_settings(markers)
final_map = case markers.length
when 0
""
when 1
update_icon_settings(markers)
map(markers: markers, center: {latlng: markers.first[:latlng], zoom: 13})
else
update_icon_settings(markers)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment