Add map to sidebar on Heading's page
Signed-off-by: Matheus Miranda <matheusmirandalacerda@gmail.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
module Budgets
|
||||
class InvestmentsController < ApplicationController
|
||||
OSM_DISTRICT_LEVEL_ZOOM = 12
|
||||
|
||||
include FeatureFlags
|
||||
include CommentableActions
|
||||
include FlagActions
|
||||
@@ -32,13 +34,17 @@ module Budgets
|
||||
respond_to :html, :js
|
||||
|
||||
def index
|
||||
if @budget.finished?
|
||||
@investments = investments.winners.page(params[:page]).per(10).for_render
|
||||
else
|
||||
@investments = investments.page(params[:page]).per(10).for_render
|
||||
end
|
||||
all_investments = if @budget.finished?
|
||||
investments.winners
|
||||
else
|
||||
investments
|
||||
end
|
||||
|
||||
@investments = all_investments.page(params[:page]).per(10).for_render
|
||||
|
||||
@investment_ids = @investments.pluck(:id)
|
||||
@investments_map_coordinates = MapLocation.where(investment_id: all_investments).map { |l| l.json_data }
|
||||
|
||||
load_investment_votes(@investments)
|
||||
@tag_cloud = tag_cloud
|
||||
end
|
||||
@@ -142,6 +148,7 @@ module Budgets
|
||||
if params[:heading_id].present?
|
||||
@heading = @budget.headings.find(params[:heading_id])
|
||||
@assigned_heading = @ballot.try(:heading_for_group, @heading.try(:group))
|
||||
load_map
|
||||
end
|
||||
end
|
||||
|
||||
@@ -167,6 +174,13 @@ module Budgets
|
||||
end
|
||||
end
|
||||
|
||||
def load_map
|
||||
@map_location = MapLocation.new
|
||||
@map_location.zoom = OSM_DISTRICT_LEVEL_ZOOM
|
||||
@map_location.latitude = @heading.latitude.to_f
|
||||
@map_location.longitude = @heading.longitude.to_f
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user