Skip to content

Commit

Permalink
Merge pull request #100 from identity-research-lab/HOTFIX-category-ze…
Browse files Browse the repository at this point in the history
…ro-error-2

Fix wraparound navigation on codebooks (edge case)
  • Loading branch information
CoralineAda authored Aug 26, 2024
2 parents cce6c78 + c2a2381 commit 6994c78
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/controllers/codebooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def show
@enqueued_at = params[:enqueued_at].present? ? Time.at(params[:enqueued_at].to_i).strftime("%T %Z") : nil

sections = Question::QUESTIONS.keys
@section_name = Question::QUESTIONS[@context.to_sym]
@section_name = Question::QUESTIONS[@context.gsub("class","klass").to_sym]

# These modulo gymnastics allow the previous/next arrows to wrap around
previous_index = (sections.index(@context.to_sym) - 1) % sections.length
next_index = (sections.index(@context.to_sym) + 1) % sections.length
previous_index = (sections.index(@context.gsub("class","klass").to_sym) - 1) % sections.length
next_index = (sections.index(@context.gsub("class","klass").to_sym) + 1) % sections.length
@previous_section = sections[previous_index]
@next_section = sections[next_index]

Expand Down

0 comments on commit 6994c78

Please sign in to comment.