-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add paginator presenter #924
Conversation
https://eaflood.atlassian.net/browse/WATER-4445 > Part of a series of changes to migrate the legacy view bill runs page into this project The legacy view bill runs page has its own custom pagination control. We understand why, the [pagination component](https://design-system.service.gov.uk/components/pagination/) didn't exist in the design system at the time. But now we have the component there is no need to migrate the custom one built. We wouldn't want to! One of the key reasons to look at migrating the bill runs page is because we have other pages that need updating that also use some form of custom pagination. If we can crack how to implement the GOV.UK component we have a solution for all of them. This `PaginatorPresenter` we're adding will build the 'object' that has to be passed to `govukPagination()` in the view. There are a number of scenarios it has to consider, for example - when there are not enough results to warrant pagination - whether to show the previous or next controls - when to show the ellipsis to highlight skipped pages To do this all it needs are - the total number of records for the thing being paginated - how many results to show per page - what page of results is selected The presenter we've built is intended to be used by all pages that need the component, not just bill runs. Because of this we've tried to make sure the testing and documentation covers all possible scenarios.
const component = { items } | ||
|
||
if (selectedPageNumber !== 1) { | ||
component.previous = { href: `/system/bill-runs?page=${selectedPageNumber - 1}` } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More of a question really. If the intention is to reuse this presenter on other pages that require this component, should we be hardcoding the URL /system/bill-runs
? I guess currently it's fine as it is the only page that uses this presenter. But is it worth setting up the URL as an additional parameter now, or is that something to do if/when we need to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Brilliant spot. Yes, I should be making this a param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default is now 25 plus there was a typo in the example.
Thanks to a great spot by @Jozzey we realised that the paginator, though intended for reuse, had hard code the links to be `/system/bill-runs`. If other pages are to be able to reuse it that path must be provided as an arg. This change updates the presenter. The tests will fail but we wanted to confirm that before fixing them.
0033599
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://eaflood.atlassian.net/browse/WATER-4445
The legacy view bill runs page has a custom pagination control. We understand why, the pagination component didn't exist in the design system at the time it was built. But now we have the component there is no need to migrate the custom one.
One of the key reasons to look at migrating the bill runs page is because we have other pages that need updating that also use a form of custom pagination. If we can crack how to implement the GOV.UK component we have a solution for all of them.
This
PaginatorPresenter
we're adding will build the 'object' that has to be passed togovukPagination()
in the nunjucks view. There are several scenarios it has to consider, for exampleTo do this all it needs are
The presenter we've built is intended to be used by all pages that need the component, not just bill runs. Because of this, we've tried to ensure the testing and documentation cover all possible scenarios.