Skip to content

Conversation

@JPrevost
Copy link
Member

@JPrevost JPrevost commented Nov 14, 2025

NOTE: you can see the end state logic using the search rails in the timdex tab

Why are these changes being introduced:

  • UX design includes showing the number of results that will be shown when clicking the Next or Previous pagination buttons.
  • Previous page should always be the same number of results as per_page so it is simpler to say "Previous 20 results" rather than trying to calculate how many results remain before the start index.
  • Next page should show the remaining results if fewer than per_page results remain.
  • Also introduces a disabled state via a span for the next and previous buttons when there are no more results in that direction.

Relevant ticket(s):

How does this address that need:

  • Mathed out the new pagination button text requirements
  • Updated PaginationHelper methods to calculate remaining results
  • Updated PaginationHelper methods to render disabled span when no more results in that direction

Developer

Accessibility
  • ANDI or WAVE has been run in accordance to our guide.
  • This PR contains no changes to the view layer.
  • New issues flagged by ANDI or WAVE have been resolved.
  • New issues flagged by ANDI or WAVE have been ticketed (link in the Pull Request details above).
  • No new accessibility issues have been flagged.
New ENV
  • All new ENV is documented in README.
  • All new ENV has been added to Heroku Pipeline, Staging and Prod.
  • ENV has not changed.
Approval beyond code review
  • UXWS/stakeholder approval has been confirmed.
  • UXWS/stakeholder review will be completed retroactively.
  • UXWS/stakeholder review is not needed.
Additional context needed to review

E.g., if the PR includes updated dependencies and/or data
migration, or how to confirm the feature is working.

Code Reviewer

Code
  • I have confirmed that the code works as intended.
  • Any CodeClimate issues have been fixed or confirmed as
    added technical debt.
Documentation
  • The commit message is clear and follows our guidelines
    (not just this pull request message).
  • The documentation has been updated or is unnecessary.
  • New dependencies are appropriate or there were no changes.
Testing
  • There are appropriate tests covering any new functionality.
  • No additional test coverage is required.

Why are these changes being introduced:

* UX design includes showing the number of results that will be shown
  when clicking the Next or Previous pagination buttons.
* Previous page should always be the same number of results as per_page
  so it is simpler to say "Previous 20 results" rather than trying to
  calculate how many results remain before the start index.
* Next page should show the remaining results if fewer than per_page
  results remain.
* Also introduces a disabled state via a span for the next and previous
  buttons when there are no more results in that direction.

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/USE-184

How does this address that need:

* Mathed out the new pagination button text requirements
* Updated PaginationHelper methods to calculate remaining results
* Updated PaginationHelper methods to render disabled span when no
  more results in that direction
@mitlib mitlib temporarily deployed to timdex-ui-pi-use-184-pa-ii8w2z November 14, 2025 14:05 Inactive
@coveralls
Copy link

coveralls commented Nov 14, 2025

Pull Request Test Coverage Report for Build 19371564204

Details

  • 26 of 26 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 97.992%

Totals Coverage Status
Change from base Build 19342635433: 0.04%
Covered Lines: 927
Relevant Lines: 946

💛 - Coveralls

@jazairi jazairi self-assigned this Nov 14, 2025
Copy link
Contributor

@jazairi jazairi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and works as intended. I'm a bit reticent to to hardcode the number of previous results in the helper, since it's possible that value could change over time. If you wouldn't mind making that change, then I think this is :shipit:

Also, I noticed that the spinner weirdly isn't showing up anymore, but it's unrelated to this changeset because it's also happening in staging. I'll check in on Slack before ticketing.

end

def prev_page_label
'Previous 20 results'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this be set to @pagination[:per_page], as the actual value will vary depending on what RESULTS_PER_PAGE is set to in the Analyzer model. (We should probably make that an env var, but that's neither here nor there.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh. Fully agree!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks for catching that! Also incorporated a change requested by Dave to use Previous 0 for the first page results.

@JPrevost JPrevost temporarily deployed to timdex-ui-pi-use-184-pa-ii8w2z November 14, 2025 16:53 Inactive
@JPrevost JPrevost requested a review from jazairi November 14, 2025 16:55
@JPrevost JPrevost merged commit cef6b49 into main Nov 14, 2025
5 checks passed
@JPrevost JPrevost deleted the use-184-pagination-counts branch November 14, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants