Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
feat(DataTable): add ability to disable row selection, and sync colum…
Browse files Browse the repository at this point in the history
…n grouping fix
  • Loading branch information
tewshi committed Feb 9, 2024
1 parent ba256bb commit a4ab88e
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 120 deletions.
16 changes: 16 additions & 0 deletions example/src/views/DataTableView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ const emptyTables = ref<
collapsed: [],
},
},
{
title: 'Selection with disabled rows',
table: {
rowAttr: 'id',
rows: fixedRows,
cols: fixedColumns,
value: [9, 5],
disabledRows: fixedRows.slice(0, 3),
outlined: true,
sort: [{ column: 'name', direction: 'asc' }],
pagination: { limit: 5, page: 1, total: 5 },
stickyHeader: true,
group: ['username'],
collapsed: [],
},
},
]);
const expandableTables = ref<
Expand Down
27 changes: 26 additions & 1 deletion src/components/tables/DataTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import TablePagination from '@/components/tables/TablePagination.vue';
import { RuiButton, RuiCheckbox, RuiSimpleSelect } from '~/src';
import type { TableColumn } from '@/components/tables/TableHead.vue';

interface User {
id: number;
name: string;
title: string;
email: string;
}

function createWrapper(options?: any) {
return mount(DataTable, {
...options,
Expand All @@ -19,7 +26,7 @@ function createWrapper(options?: any) {
}

describe('dataTable', () => {
const data = [
const data: User[] = [
...[...new Array(50)].map((_, index) => ({
email: `lindsay.walton${index}@example.com`,
id: index + 1,
Expand Down Expand Up @@ -143,6 +150,24 @@ describe('dataTable', () => {
.find('tbody tr:nth-child(2) div[data-cy=expanded-content]')
.exists(),
).toBeTruthy();

expect(
wrapper
.find('div[data-cy=table-pagination] div[class*=limit]')
.exists(),
).toBeTruthy();

expect(
wrapper
.find('div[data-cy=table-pagination] div[class*=ranges]')
.exists(),
).toBeTruthy();

expect(
wrapper
.find('div[data-cy=table-pagination] div[class*=navigation]')
.exists(),
).toBeTruthy();
});

it('multiple expand toggles correctly', async () => {
Expand Down
11 changes: 10 additions & 1 deletion src/components/tables/DataTable.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import DataTable, { type Props } from './DataTable.vue';
import type { TableColumn } from './TableHead.vue';
import type { Meta, StoryFn, StoryObj } from '@storybook/vue';

interface User {
id: number;
name: string;
title: string;
email: string;
role: string;
date: string;
}

const render: StoryFn<Props> = args => ({
components: { Button, Card, DataTable, Icon, TextField },
provide: {
Expand Down Expand Up @@ -148,7 +157,7 @@ const render: StoryFn<Props> = args => ({
</div>`,
});

const data = [
const data: User[] = [
{
date: '10.09.2023',
email: 'Lefteris@example.com',
Expand Down
Loading

0 comments on commit a4ab88e

Please sign in to comment.