roadmap icon indicating copy to clipboard operation
roadmap copied to clipboard

Refactor pagination logic

Open briri opened this issue 3 years ago • 0 comments

The pagination logic within the codebase is needlessly complex. The majority of what the paginable concern is trying to do is propagate parameters/state (e.g. search term, page number, etc.) as the user traverses the results in the table. The methods for helping the views and the controllers have also been conflated and placed inside the paginable concern which makes the logic hard to understand since its a mix of logic for rendering HTML and deciphering request parameters for the controller context.

I recently built an new public DMPs page for the DMPTool that needed the pagination and search functionality but also needed to introduce faceting. Rather than trying to add further complexity to the current paginable architecture, I decided to look at the Kaminari gem's latest documentation and build out a new approach.

The result is much simpler and does not require the maintenance of 2 controller methods and 2 views for every scenario. The following examples could be used as the basis of new pagination concern and helper modules (with some refactoring to genericize them a bit):

briri avatar Apr 07 '22 14:04 briri