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

Feature: Add prop to hide items index in footer #383

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion src/components/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@
:rows-items="rowsItemsComputed"
/>
</div>
<div class="pagination__items-index">
<div
v-if="!hideItemsIndex"
class="pagination__items-index"
>
{{ `${currentPageFirstIndex}–${currentPageLastIndex}` }}
{{ rowsOfPageSeparatorMessage }} {{ totalItemsLength }}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/propsWithDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export default {
type: Boolean,
default: false,
},
hideItemsIndex: {
type: Boolean,
default: false,
},
hideRowsPerPage: {
type: Boolean,
default: false,
Expand Down
20 changes: 11 additions & 9 deletions test/DataTable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Button Pagination', () => {
rowsPerPage: 5,
},
});
expect(wrapper.find('.data-table').exists()).toBe(true);
expect(wrapper.find('.vue3-easy-data-table').exists()).toBe(true);
});

/**
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Button Pagination', () => {

// Multiple selecting
describe('Multiple selecting', () => {
it('Gather data of the the top two row items', async () => {
it('Gather data of the top two row items', async () => {
const mockItems = mockClientItems(200);
const wrapper = mount(DataTable, {
props: {
Expand All @@ -86,9 +86,9 @@ describe('Multiple selecting', () => {
rowsPerPage: 5,
},
});
const singleCheckboxArr = wrapper.findAll('.single-select__checkbox');
const firstSingleCheckbox = singleCheckboxArr.at(0);
const secondSingleCheckbox = singleCheckboxArr.at(1);
const singleCheckboxArr = wrapper.findAll('.easy-checkbox');
const firstSingleCheckbox = singleCheckboxArr.at(1);
const secondSingleCheckbox = singleCheckboxArr.at(2);
await firstSingleCheckbox.trigger('click');
await secondSingleCheckbox.trigger('click');
const updateItemsSelecedEvent = wrapper.emitted('update:itemsSelected');
Expand All @@ -106,18 +106,20 @@ describe('Multiple selecting', () => {
rowsPerPage: 5,
},
});
const singleCheckboxArr = wrapper.findAll('.single-select__checkbox');
const firstSingleCheckbox = singleCheckboxArr.at(0);
const singleCheckboxArr = wrapper.findAll('.easy-checkbox');
const firstSingleCheckbox = singleCheckboxArr.at(1);
await firstSingleCheckbox.trigger('click');

const nextPageButton = wrapper.find('.next-page__click-button');
await nextPageButton.trigger('click');

const singleCheckboxArrInSecondPage = wrapper.findAll('.single-select__checkbox');
const firstSingleCheckboxInSecondPage = singleCheckboxArrInSecondPage.at(0);
const singleCheckboxArrInSecondPage = wrapper.findAll('.easy-checkbox');
const firstSingleCheckboxInSecondPage = singleCheckboxArrInSecondPage.at(1);
await firstSingleCheckboxInSecondPage.trigger('click');

const updateItemsSelecedEvent = wrapper.emitted('update:itemsSelected');
console.log(updateItemsSelecedEvent[1]);

expect(updateItemsSelecedEvent).toHaveLength(2);
expect(updateItemsSelecedEvent[1]).toEqual([[mockItems[5], mockItems[0]]]);
});
Expand Down