Skip to content
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

Remove mojPagination and replace with govukPagination #795

Merged
merged 5 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/assets/sass/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ $govuk-assets-path: "/dist/govuk/assets/";
@import "overrides/govuk-tag";
@import "overrides/moj-button-menu";
@import "overrides/moj-filter";
@import "overrides/moj-pagination";
@import "overrides/moj-primary-navigation";
@import "overrides/status-grid";
@import "overrides/summary-card";
Expand Down
26 changes: 0 additions & 26 deletions app/assets/sass/overrides/_moj-pagination.scss

This file was deleted.

6 changes: 6 additions & 0 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ router.all('*', (req, res, next) => {
res.locals.referrer = req.query.referrer.split(',')
}

if (req.query?.page) {
res.locals.page = req.query.page
res.locals.nextPage = parseInt(req.query.page) + 1
res.locals.prevPage = parseInt(req.query.page) - 1
}

// Only search by the query if there is one
// (and get "undefined" instead of "{}" if there is no query)
const hasQuery = !_.isEmpty(req.query)
Expand Down
61 changes: 30 additions & 31 deletions app/views/_includes/pagination.njk
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
{# TODO: make pagination dynamic #}
<p class="govuk-body">
Showing 1 to 100 of 346 results
</p>

{% if not page %}
{% set page = 1 %}
{% endif %}

{% set pagination = {
from: 1,
to: 100,
count: count or 346,
{{ govukPagination({
previous: {
href: "?page=" + prevPage
} if page > 1,
next: {
text: 'Next',
href: '?page=' + 2
},
items: [{
text: '1',
href: '?page=1',
selected: true
}, {
text: '2',
href: '?page=2',
selected: false
}, {
text: '3',
href: '?page=3'
}]
} %}

{{ mojPagination({
results: {
from: pagination.from,
to: pagination.to,
count: pagination.count
},
previous: pagination.previous,
next: pagination.next,
items: pagination.items,
classes: 'govuk-!-margin-bottom-3'
href: "?page=" + nextPage
} if page < 3,
items: [
{
number: 1,
href: "?page=1",
current: true if page == 1
},
{
number: 2,
href: "?page=2",
current: true if page == 2
},
{
number: 3,
href: "?page=3",
current: true if page == 3
}
]
}) }}
2 changes: 1 addition & 1 deletion app/views/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{% from "govuk/components/inset-text/macro.njk" import govukInsetText %}
{% from "govuk/components/notification-banner/macro.njk" import govukNotificationBanner %}
{% from "govuk/components/panel/macro.njk" import govukPanel %}
{% from "govuk/components/pagination/macro.njk" import govukPagination %}
{% from "govuk/components/phase-banner/macro.njk" import govukPhaseBanner %}
{% from "govuk/components/radios/macro.njk" import govukRadios %}
{% from "govuk/components/select/macro.njk" import govukSelect %}
Expand Down Expand Up @@ -52,7 +53,6 @@
{# moj components #}
{%- from "moj/components/filter/macro.njk" import mojFilter -%}
{%- from "moj/components/button-menu/macro.njk" import mojButtonMenu -%}
{%- from "moj/components/pagination/macro.njk" import mojPagination -%}
{%- from "moj/components/primary-navigation/macro.njk" import mojPrimaryNavigation -%}

{% block head %}
Expand Down
Loading