Skip to content

Commit ea92743

Browse files
committed
Improve ReferenceManyField full app story
1 parent a6e5977 commit ea92743

1 file changed

Lines changed: 52 additions & 20 deletions

File tree

packages/ra-ui-materialui/src/field/ReferenceManyField.stories.tsx

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import {
1111
} from 'ra-core';
1212
import { Admin, ListGuesser, Resource } from 'react-admin';
1313
import type { AdminProps } from 'react-admin';
14-
import { Alert, ThemeProvider, Box, Stack } from '@mui/material';
15-
import { createTheme } from '@mui/material/styles';
16-
import fakeDataProvider from 'ra-data-fakerest';
1714
import polyglotI18nProvider from 'ra-i18n-polyglot';
1815
import englishMessages from 'ra-language-english';
16+
import fakeDataProvider from 'ra-data-fakerest';
17+
import { onlineManager } from '@tanstack/react-query';
18+
import { Alert, ThemeProvider, Box, Stack } from '@mui/material';
19+
import { createTheme } from '@mui/material/styles';
1920

2021
import { TextField } from '../field';
2122
import { ReferenceManyField } from './ReferenceManyField';
@@ -32,7 +33,6 @@ import { TextInput } from '../input';
3233
import { Edit } from '../detail';
3334
import { SimpleForm } from '../form';
3435
import { ExportButton, SelectAllButton, BulkDeleteButton } from '../button';
35-
import { onlineManager } from '@tanstack/react-query';
3636

3737
export default { title: 'ra-ui-materialui/fields/ReferenceManyField' };
3838

@@ -44,26 +44,57 @@ const authors = [
4444
{ id: 4, name: 'J.K. Rowling' },
4545
];
4646
let books = [
47-
{ id: 1, title: 'War and Peace', author_id: 1 },
48-
{ id: 2, title: 'Les Misérables', author_id: 2 },
49-
{ id: 3, title: 'Anna Karenina', author_id: 1 },
50-
{ id: 4, title: 'The Count of Monte Cristo', author_id: 3 },
51-
{ id: 5, title: 'Resurrection', author_id: 1 },
52-
{ id: 6, title: 'The Three Musketeers', author_id: 3 },
53-
{ id: 7, title: 'The Idiot', author_id: 1 },
54-
{ id: 8, title: 'The Last Day of a Condemned', author_id: 1 },
55-
{ id: 9, title: 'The Queen Margot', author_id: 3 },
56-
{ id: 10, title: "Harry Potter and the Philosopher's Stone", author_id: 4 },
57-
{ id: 11, title: 'Harry Potter and the Chamber of Secrets', author_id: 4 },
58-
{ id: 12, title: 'Harry Potter and the Prisoner of Azkaban', author_id: 4 },
59-
{ id: 13, title: 'Harry Potter and the Goblet of Fire', author_id: 4 },
47+
{ id: 1, title: 'War and Peace', author_id: 1, year: 1869 },
48+
{ id: 2, title: 'Les Misérables', author_id: 2, year: 1862 },
49+
{ id: 3, title: 'Anna Karenina', author_id: 1, year: 1877 },
50+
{ id: 4, title: 'The Count of Monte Cristo', author_id: 3, year: 1844 },
51+
{ id: 5, title: 'Resurrection', author_id: 1, year: 1899 },
52+
{ id: 6, title: 'The Three Musketeers', author_id: 3, year: 1844 },
53+
{ id: 7, title: 'The Idiot', author_id: 1, year: 1869 },
54+
{ id: 8, title: 'The Last Day of a Condemned', author_id: 1, year: 1869 },
55+
{ id: 9, title: 'The Queen Margot', author_id: 3, year: 1844 },
56+
{
57+
id: 10,
58+
title: "Harry Potter and the Philosopher's Stone",
59+
author_id: 4,
60+
year: 1997,
61+
},
62+
{
63+
id: 11,
64+
title: 'Harry Potter and the Chamber of Secrets',
65+
author_id: 4,
66+
year: 1998,
67+
},
68+
{
69+
id: 12,
70+
title: 'Harry Potter and the Prisoner of Azkaban',
71+
author_id: 4,
72+
year: 1999,
73+
},
74+
{
75+
id: 13,
76+
title: 'Harry Potter and the Goblet of Fire',
77+
author_id: 4,
78+
year: 2000,
79+
},
6080
{
6181
id: 14,
6282
title: 'Harry Potter and the Order of the Phoenix',
6383
author_id: 4,
84+
year: 2003,
85+
},
86+
{
87+
id: 15,
88+
title: 'Harry Potter and the Half-Blood Prince',
89+
author_id: 4,
90+
year: 2005,
91+
},
92+
{
93+
id: 16,
94+
title: 'Harry Potter and the Deathly Hallows',
95+
author_id: 4,
96+
year: 2007,
6497
},
65-
{ id: 15, title: 'Harry Potter and the Half-Blood Prince', author_id: 4 },
66-
{ id: 16, title: 'Harry Potter and the Deathly Hallows', author_id: 4 },
6798
];
6899

69100
const fullDataProvider = fakeDataProvider(
@@ -286,16 +317,17 @@ export const WithPaginationAndSelectAllLimit = ({
286317
const AuthorEdit = () => (
287318
<Edit>
288319
<SimpleForm>
289-
<TextField source="id" />
290320
<TextInput source="name" />
291321
<ReferenceManyField
292322
reference="books"
293323
target="author_id"
294324
pagination={<Pagination />}
295325
perPage={5}
296326
>
327+
<ExportButton />
297328
<DataTable>
298329
<DataTable.Col source="title" />
330+
<DataTable.Col source="year" />
299331
</DataTable>
300332
</ReferenceManyField>
301333
</SimpleForm>

0 commit comments

Comments
 (0)