Skip to content

Commit

Permalink
Merge pull request #70 from DigitalNZ/pm/fix-next-previous-records
Browse files Browse the repository at this point in the history
NEXT/PREVIOUS ON SJ API: As a user, I would like to be able to click through to the next page of results, so that I can keep looking at things I've found on natlib.govt.nz.
  • Loading branch information
paul-mesnilgrente authored Jan 23, 2023
2 parents 5c9f295 + daa6632 commit 8913166
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/supplejack/controllers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ def previous_record_link(links, record, options, html_options)
previous_label = previous_label.html_safe

if record.previous_record
options[:page] = record.previous_page if record.previous_page.to_i > 1
path = record_path(record.previous_record, search: options)
path = path.split('?')[0] if path.include?('?') && html_options[:include_querystring]
path = "#{path}?#{request.query_string}" if html_options[:include_querystring]
options = html_options[:include_querystring] ? request.query_parameters : { search: {} }
options[:search][:page] = record.previous_page
path = record_path(record.previous_record, options)
links += link_to(raw(previous_label), path, class: html_options[:prev_class]).html_safe
else
links += content_tag(:span, previous_label, class: html_options[:prev_class])
Expand All @@ -151,10 +150,9 @@ def next_record_link(links, record, options, html_options)
next_label = next_label.html_safe

if record.next_record
options[:page] = record.next_page if record.next_page.to_i > 1
path = record_path(record.next_record, search: options)
path = path.split('?')[0] if path.include?('?') && html_options[:include_querystring]
path = "#{path}?#{request.query_string}" if html_options[:include_querystring]
options = html_options[:include_querystring] ? request.query_parameters : { search: {} }
options[:search][:page] = record.next_page if record.next_page.to_i > 1
path = record_path(record.next_record, options)
links += link_to(raw(next_label), path, class: html_options[:next_class]).html_safe
else
links += content_tag(:span, next_label, class: html_options[:next_class])
Expand Down

0 comments on commit 8913166

Please sign in to comment.