Extract the load_map logic from the :load_heading callback
Create a new callback for load_map. In this way we simplify a bit the logic of :load_heading callback and unify the logic of the map loading.
This commit is contained in:
@@ -20,6 +20,7 @@ module Budgets
|
||||
|
||||
before_action :load_ballot, only: [:index, :show]
|
||||
before_action :load_heading, only: [:index, :show]
|
||||
before_action :load_map, only: [:index]
|
||||
before_action :set_random_seed, only: :index
|
||||
before_action :load_categories, only: :index
|
||||
before_action :set_default_investment_filter, only: :index
|
||||
@@ -134,10 +135,8 @@ module Budgets
|
||||
if params[:heading_id].present?
|
||||
@heading = @budget.headings.find_by_slug_or_id! params[:heading_id]
|
||||
@assigned_heading = @ballot&.heading_for_group(@heading.group)
|
||||
load_map
|
||||
elsif @budget.single_heading?
|
||||
@heading = @budget.headings.first
|
||||
load_map
|
||||
end
|
||||
end
|
||||
|
||||
@@ -180,7 +179,7 @@ module Budgets
|
||||
end
|
||||
|
||||
def load_map
|
||||
@map_location = MapLocation.load_from_heading(@heading)
|
||||
@map_location = MapLocation.load_from_heading(@heading) if @heading.present?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user