Skip to content

Commit

Permalink
start alphabetical listing with a
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansing committed Aug 20, 2020
1 parent 82b767a commit 4c368dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions app/controllers/concepts/alphabetical_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ def identify_used_first_letters
end

def find_labelings
query = (params[:prefix] || @letters.first || 'a').mb_chars.downcase.to_s
letter = (@letters.include?('A')) ? 'a' : @letters.first
query = (params[:prefix] || letter).mb_chars.downcase.to_s

Iqvoc::Concept.pref_labeling_class
.concept_published
.concept_not_expired.
label_begins_with(query)
.concept_not_expired
.label_begins_with(query)
.by_label_language(I18n.locale)
.includes(:target)
.order(Arel.sql("LOWER(#{Label::Base.table_name}.value)"))
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/concepts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def nested_list(hash, options={})
end

def letter_selector(letters = ('A'..'Z').to_a, &block)
highlighted_letter = params[:prefix] || letters.first || 'a'
fallback = (@letters.include?('A')) ? 'a' : @letters.first
highlighted_letter = params[:prefix] || fallback || 'a'
content_tag :ul, class: 'letter-selector list-unstyled' do
letters.map do |letter|
content_tag :li, link_to(letter, yield(letter)),
Expand Down

0 comments on commit 4c368dc

Please sign in to comment.