Skip to content

Commit

Permalink
Update map_helper.rb
Browse files Browse the repository at this point in the history
Try to fix
  • Loading branch information
nimmolo committed Feb 3, 2025
1 parent 38f7fc9 commit 8998c03
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/helpers/map_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ def mapset_info_window(set, args)
lines.safe_join(safe_br)
end

def mapset_observation_header(set, args)
def mapset_observation_header(set, args) # don't need args?
show, map = mapset_associated_links(set, args, :observation)
map_point_text(:Observations.t, set.observations.length, show, map)
end

def mapset_location_header(set, args)
def mapset_location_header(set, args) # don't need args?
show, map = mapset_associated_links(set, args, :location)
map_point_text(:Locations.t, set.underlying_locations.length, show, map)
end
Expand All @@ -134,19 +134,25 @@ def map_point_text(label, count, show, map)
end

# Links to obs, locs or names within the current mapset, or maps of these
def mapset_associated_links(set, args, type)
params = args[:query_params] || {}
params = params.merge(mapset_box_params(set))
def mapset_associated_links(set, _args, type)
# params = args[:query_params] || {}
# this just gets us q.
# need to look up query from the QR and add in_box and resave.
# params = params.merge(mapset_box_params(set))
return unless [:observation, :location, :name].include?(type)

mapset_associated_links_for_type(type, params)
mapset_associated_links_for_type(set, type)
end

# Helper for the above
def mapset_associated_links_for_type(type, params)
def mapset_associated_links_for_type(set, type)
query_type = type.to_s.camelize.to_sym
path_helper = :"#{type.to_s.pluralize}_path"
query = Query.lookup(query_type, **params)
# query = Query.lookup(query_type, **params)
# probably already have a query, from the index that got us here. add box
query = controller.find_or_create_query(
query_type, in_box: mapset_box_params(set)
)
[link_to(:show_all.t, add_query_param(send(path_helper), query)),
link_to(:map_all.t, add_query_param(send(:"map_#{path_helper}"), query))]
end
Expand Down

0 comments on commit 8998c03

Please sign in to comment.