Skip to content

Commit 4a2e126

Browse files
authored
Merge pull request #526 from appuniversum/au-data-table-optional-pagination
Add support for hiding the pagination in the `AuDataTable` component
2 parents ce33d50 + f125db4 commit 4a2e126

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

addon/components/au-data-table.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}}
4343
{{/if}}
4444

45-
{{#if this.content}}
45+
{{#if this.showPagination}}
4646
<div class="au-c-data-table__actions au-c-data-table__actions--bottom">
4747
{{au-data-table-number-pagination
4848
page=this.page

addon/components/au-data-table.js

+3
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,7 @@ const DataTable = Component.extend({
6363

6464
export default DataTable.extend({
6565
tagName: '',
66+
showPagination: computed('content', 'hidePagination', function () {
67+
return Boolean(this.content) && !this.hidePagination;
68+
}),
6669
});

stories/5-components/Tables/AuDataTable.stories.js

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const Template = (args) => ({
1616
@fields="title description"
1717
@noDataMessage="Geen documenten"
1818
@sort={{this.sort}}
19+
@hidePagination={{this.hidePagination}}
1920
as |t|
2021
>
2122
<t.menu as |menu|>
@@ -107,4 +108,5 @@ Component.args = {
107108
page: 0,
108109
itemsPerPage: 5,
109110
totalItems: 100,
111+
hidePagination: false,
110112
};

tests/integration/components/au-data-table-test.gjs

+36
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,40 @@ module('Integration | Component | au-data-table', function (hooks) {
2626

2727
assert.dom('.au-c-data-table').exists({ count: 1 });
2828
});
29+
30+
test('it conditionally shows a pagination bar', async function (assert) {
31+
const content = [{ name: 'foo' }, { name: 'bar' }];
32+
content.meta = {
33+
pagination: {
34+
first: { number: 1 },
35+
last: { number: 10 },
36+
},
37+
};
38+
39+
await render(
40+
<template>
41+
<AuDataTable @fields="name" @content={{content}} @enableSizes="false" />
42+
</template>,
43+
);
44+
45+
assert
46+
.dom('.au-c-pagination')
47+
.exists({ count: 1 }, 'the pagination bar is shown by default');
48+
49+
await render(
50+
<template>
51+
<AuDataTable
52+
@fields="name"
53+
@content={{content}}
54+
@hidePagination={{true}}
55+
/>
56+
</template>,
57+
);
58+
59+
assert
60+
.dom('.au-c-pagination')
61+
.doesNotExist(
62+
'the pagination bar is hidden when `@hidePagination` is true',
63+
);
64+
});
2965
});

0 commit comments

Comments
 (0)