Skip to content
Merged
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
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/detail/EditGuesser.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('<EditGuesser />', () => {
score: 3,
body: "Queen, tossing her head through the wood. 'If it had lost something; and she felt sure it.",
created_at: new Date('2012-08-02'),
tags_ids: [1, 2],
},
}),
getMany: () => Promise.resolve({ data: [] }),
Expand All @@ -35,7 +36,7 @@ describe('<EditGuesser />', () => {
});
expect(logSpy).toHaveBeenCalledWith(`Guessed Edit:

import { DateInput, Edit, NumberInput, ReferenceInput, SimpleForm, TextInput } from 'react-admin';
import { DateInput, Edit, NumberInput, ReferenceArrayInput, ReferenceInput, SimpleForm, TextInput } from 'react-admin';

export const CommentEdit = () => (
<Edit>
Expand All @@ -46,6 +47,7 @@ export const CommentEdit = () => (
<NumberInput source="score" />
<TextInput source="body" />
<DateInput source="created_at" />
<ReferenceArrayInput source="tags_ids" reference="tags" />
</SimpleForm>
</Edit>
);`);
Expand Down
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/detail/ShowGuesser.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('<ShowGuesser />', () => {
score: 3,
body: "Queen, tossing her head through the wood. 'If it had lost something; and she felt sure it.",
created_at: new Date('2012-08-02'),
tags_ids: [1, 2],
},
}),
};
Expand All @@ -34,7 +35,7 @@ describe('<ShowGuesser />', () => {
});
expect(logSpy).toHaveBeenCalledWith(`Guessed Show:

import { DateField, NumberField, ReferenceField, Show, SimpleShowLayout, TextField } from 'react-admin';
import { DateField, NumberField, ReferenceArrayField, ReferenceField, Show, SimpleShowLayout, TextField } from 'react-admin';

export const CommentShow = () => (
<Show>
Expand All @@ -45,6 +46,7 @@ export const CommentShow = () => (
<NumberField source="score" />
<TextField source="body" />
<DateField source="created_at" />
<ReferenceArrayField source="tags_ids" reference="tags" />
</SimpleShowLayout>
</Show>
);`);
Expand Down
16 changes: 10 additions & 6 deletions packages/ra-ui-materialui/src/detail/showFieldTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import {
RichTextField,
TextField,
UrlField,
ChipField,
} from '../field';
import { SimpleShowLayout, SimpleShowLayoutProps } from './SimpleShowLayout';
import { InferredElement, InferredTypeMap, InputProps } from 'ra-core';
import { SingleFieldList } from '../list';

export const showFieldTypes: InferredTypeMap = {
show: {
Expand Down Expand Up @@ -81,14 +83,16 @@ ${children.map(child => ` ${child.getRepresentation()}`).join('\n')}
referenceArray: {
component: ReferenceArrayField,
representation: (props: ReferenceArrayFieldProps) =>
`<ReferenceArrayField source="${props.source}" reference="${props.reference}"><TextField source="id" /></ReferenceArrayField>`,
`<ReferenceArrayField source="${props.source}" reference="${props.reference}" />`,
},
referenceArrayChild: {
component: (
props: { children: ReactNode } & Omit<InputProps, 'source'> &
Partial<Pick<InputProps, 'source'>>
) => <TextField source="id" {...props} />,
representation: () => `<TextField source="id" />`,
component: () => (
<SingleFieldList>
<ChipField source="id" />
</SingleFieldList>
),
representation: () =>
`<SingleFieldList><ChipField source="id" /></SingleFieldList>`,
Comment on lines +89 to +95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you remove the referenceArrayChild key altogether? I'm worried the rendered JSX does not match the JSX code printed in the console.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be used by guessers we don't maintain so I'd rather keep it

},
richText: {
component: RichTextField,
Expand Down
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/list/ListGuesser.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('<ListGuesser />', () => {
score: 3,
body: "Queen, tossing her head through the wood. 'If it had lost something; and she felt sure it.",
created_at: new Date('2012-08-02'),
tags_ids: [1, 2],
},
],
total: 1,
Expand All @@ -38,7 +39,7 @@ describe('<ListGuesser />', () => {
});
expect(logSpy).toHaveBeenCalledWith(`Guessed List:

import { Datagrid, DateField, List, NumberField, ReferenceField, TextField } from 'react-admin';
import { Datagrid, DateField, List, NumberField, ReferenceArrayField, ReferenceField, TextField } from 'react-admin';

export const CommentList = () => (
<List>
Expand All @@ -49,6 +50,7 @@ export const CommentList = () => (
<NumberField source="score" />
<TextField source="body" />
<DateField source="created_at" />
<ReferenceArrayField source="tags_ids" reference="tags" />
</Datagrid>
</List>
);`);
Expand Down
Loading