@defra/lis-infra-ui-services 0.20.0-lreg-596.alpha.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -245,13 +245,13 @@ test('renders the summary above the pagination by default', () => {
|
|
|
245
245
|
assert.doesNotMatch(html, /govuk-grid-row/)
|
|
246
246
|
})
|
|
247
247
|
|
|
248
|
-
test('
|
|
248
|
+
test('renders the summary text the caller supplies instead of the results count', () => {
|
|
249
249
|
const html = render({
|
|
250
250
|
caption: 'Animals',
|
|
251
251
|
columns,
|
|
252
252
|
rows,
|
|
253
253
|
baseHref: '/animals',
|
|
254
|
-
|
|
254
|
+
summary: { text: 'Showing 1 to 7 of 7 <cattle>' },
|
|
255
255
|
pagination: {
|
|
256
256
|
currentPage: 1,
|
|
257
257
|
totalPages: 1,
|
|
@@ -260,17 +260,35 @@ test('always states the range, without "results", in the range summary format',
|
|
|
260
260
|
}
|
|
261
261
|
})
|
|
262
262
|
|
|
263
|
-
assert.match(html, /Showing 1 to 7 of 7
|
|
263
|
+
assert.match(html, /Showing 1 to 7 of 7 <cattle></)
|
|
264
264
|
assert.doesNotMatch(html, /results/)
|
|
265
265
|
})
|
|
266
266
|
|
|
267
|
+
test('renders summary html the caller supplies unescaped', () => {
|
|
268
|
+
const html = render({
|
|
269
|
+
caption: 'Animals',
|
|
270
|
+
columns,
|
|
271
|
+
rows,
|
|
272
|
+
baseHref: '/animals',
|
|
273
|
+
summary: { html: 'Showing <strong>7</strong> cattle' },
|
|
274
|
+
pagination: {
|
|
275
|
+
currentPage: 1,
|
|
276
|
+
totalPages: 1,
|
|
277
|
+
totalItems: 7,
|
|
278
|
+
itemsPerPage: 25
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
assert.match(html, /Showing <strong>7<\/strong> cattle</)
|
|
283
|
+
})
|
|
284
|
+
|
|
267
285
|
test('puts the summary beside the pagination, below the table, when positioned below', () => {
|
|
268
286
|
const html = render({
|
|
269
287
|
caption: 'Animals',
|
|
270
288
|
columns,
|
|
271
289
|
rows,
|
|
272
290
|
baseHref: '/animals',
|
|
273
|
-
|
|
291
|
+
summary: { position: 'below' },
|
|
274
292
|
pagination: {
|
|
275
293
|
currentPage: 1,
|
|
276
294
|
totalPages: 2,
|
|
@@ -295,7 +313,7 @@ test('puts the summary alone below the table when positioned below with a single
|
|
|
295
313
|
columns,
|
|
296
314
|
rows,
|
|
297
315
|
baseHref: '/animals',
|
|
298
|
-
|
|
316
|
+
summary: { position: 'below' },
|
|
299
317
|
pagination: {
|
|
300
318
|
currentPage: 1,
|
|
301
319
|
totalPages: 1,
|
|
@@ -66,14 +66,20 @@
|
|
|
66
66
|
{%- set lastItemOnPage = currentPage * itemsPerPage -%}
|
|
67
67
|
{%- set endItem = totalItems if lastItemOnPage > totalItems else lastItemOnPage -%}
|
|
68
68
|
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{%-
|
|
73
|
-
{%-
|
|
74
|
-
|
|
75
|
-
{%-
|
|
76
|
-
|
|
69
|
+
{%- set summary = params.summary or {} -%}
|
|
70
|
+
|
|
71
|
+
{#- the caller may supply the summary wording; otherwise it is the results count -#}
|
|
72
|
+
{%- set summaryContent -%}
|
|
73
|
+
{%- if summary.html -%}
|
|
74
|
+
{{ summary.html | safe }}
|
|
75
|
+
{%- elif summary.text -%}
|
|
76
|
+
{{ summary.text }}
|
|
77
|
+
{%- elif totalPages > 1 -%}
|
|
78
|
+
Showing {{ startItem }} to {{ endItem }} of {{ totalItems }} results
|
|
79
|
+
{%- else -%}
|
|
80
|
+
Showing {{ totalItems }} result{{ "s" if totalItems != 1 else "" }}
|
|
81
|
+
{%- endif -%}
|
|
82
|
+
{%- endset -%}
|
|
77
83
|
|
|
78
84
|
{%- if totalPages > 1 -%}
|
|
79
85
|
{%- set items = [] -%}
|
|
@@ -95,21 +101,21 @@
|
|
|
95
101
|
{%- endif -%}
|
|
96
102
|
|
|
97
103
|
{#- "below" puts the summary under the table, beside the page links when there are any -#}
|
|
98
|
-
{%- if
|
|
104
|
+
{%- if summary.position == "below" -%}
|
|
99
105
|
{%- if totalPages > 1 -%}
|
|
100
106
|
<div class="govuk-grid-row">
|
|
101
107
|
<div class="govuk-grid-column-two-thirds">
|
|
102
108
|
{{ paginationHtml | safe }}
|
|
103
109
|
</div>
|
|
104
110
|
<div class="govuk-grid-column-one-third govuk-!-text-align-right">
|
|
105
|
-
<p class="govuk-body govuk-!-margin-top-2">{{
|
|
111
|
+
<p class="govuk-body govuk-!-margin-top-2">{{ summaryContent | safe }}</p>
|
|
106
112
|
</div>
|
|
107
113
|
</div>
|
|
108
114
|
{%- else -%}
|
|
109
|
-
<p class="govuk-body">{{
|
|
115
|
+
<p class="govuk-body">{{ summaryContent | safe }}</p>
|
|
110
116
|
{%- endif -%}
|
|
111
117
|
{%- else -%}
|
|
112
|
-
<p class="govuk-body">{{
|
|
118
|
+
<p class="govuk-body">{{ summaryContent | safe }}</p>
|
|
113
119
|
{%- if totalPages > 1 -%}
|
|
114
120
|
{{ paginationHtml | safe }}
|
|
115
121
|
{%- endif -%}
|