Skip to content

Commit

Permalink
Fix NamesWithObservations link to All Names
Browse files Browse the repository at this point in the history
- Fixes #1841
- Adds helper for all_names_index_tabs
- Adds link to names_path (All Names)
unless that's already the query
  • Loading branch information
JoeCohen committed Jan 20, 2024
1 parent c2cc6f4 commit c136b4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/helpers/tabs/names_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,21 @@ def descriptions_of_these_names_tab(query)
{ class: tab_id(__method__.to_s) }]
end

def all_names_index_tabs(query:)
[
new_name_tab,
all_names_tab(query),
coerced_observation_query_tab(query)
].reject(&:empty?)
end

def all_names_tab(query)
return if query&.flavor == :all || query&.flavor&.empty?

[:all_objects.t(type: :name), names_path,
{ class: tab_id(__method__.to_s) }]
end

def names_index_sorts(query:)
[
["name", :sort_by_name.t],
Expand Down
2 changes: 1 addition & 1 deletion app/views/controllers/names/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%
@container = :text_image
add_index_title(@query, no_hits: "")
add_tab_set(names_index_tabs(query: @query))
add_tab_set(all_names_index_tabs(query: @query))
add_sorter(@query, names_index_sorts(query: @query))

flash_error(@error) if @error && @objects.empty?
Expand Down

0 comments on commit c136b4b

Please sign in to comment.