@@ -5,6 +5,9 @@ import { AdminContext } from '../AdminContext';
5
5
import { DatagridInput } from '../input' ;
6
6
import { TextField } from '../field' ;
7
7
import { ReferenceArrayInput } from './ReferenceArrayInput' ;
8
+ import { AutocompleteArrayInput } from './AutocompleteArrayInput' ;
9
+ import { SelectArrayInput } from './SelectArrayInput' ;
10
+ import { CheckboxGroupInput } from './CheckboxGroupInput' ;
8
11
import polyglotI18nProvider from 'ra-i18n-polyglot' ;
9
12
import englishMessages from 'ra-language-english' ;
10
13
@@ -29,8 +32,136 @@ const dataProvider = testDataProvider({
29
32
30
33
const i18nProvider = polyglotI18nProvider ( ( ) => englishMessages ) ;
31
34
32
- export const WithDatagridChild = ( ) => (
35
+ export const WithAutocompleteInput = ( ) => (
33
36
< AdminContext dataProvider = { dataProvider } i18nProvider = { i18nProvider } >
37
+ < Form onSubmit = { ( ) => { } } defaultValues = { { tag_ids : [ 5 ] } } >
38
+ < ReferenceArrayInput
39
+ reference = "tags"
40
+ resource = "posts"
41
+ source = "tag_ids"
42
+ >
43
+ < AutocompleteArrayInput optionText = "name" />
44
+ </ ReferenceArrayInput >
45
+ </ Form >
46
+ </ AdminContext >
47
+ ) ;
48
+
49
+ export const ErrorAutocomplete = ( ) => (
50
+ < AdminContext
51
+ dataProvider = { {
52
+ getList : ( ) => Promise . reject ( new Error ( 'fetch error' ) ) ,
53
+ getMany : ( ) =>
54
+ Promise . resolve ( { data : [ { id : 5 , name : 'test1' } ] } ) ,
55
+ } }
56
+ i18nProvider = { i18nProvider }
57
+ >
58
+ < Form onSubmit = { ( ) => { } } defaultValues = { { tag_ids : [ 5 ] } } >
59
+ < ReferenceArrayInput
60
+ reference = "tags"
61
+ resource = "posts"
62
+ source = "tag_ids"
63
+ >
64
+ < AutocompleteArrayInput optionText = "name" />
65
+ </ ReferenceArrayInput >
66
+ </ Form >
67
+ </ AdminContext >
68
+ ) ;
69
+
70
+ export const WithSelectArrayInput = ( ) => (
71
+ < AdminContext dataProvider = { dataProvider } i18nProvider = { i18nProvider } >
72
+ < Form onSubmit = { ( ) => { } } defaultValues = { { tag_ids : [ 5 ] } } >
73
+ < ReferenceArrayInput
74
+ reference = "tags"
75
+ resource = "posts"
76
+ source = "tag_ids"
77
+ >
78
+ < SelectArrayInput optionText = "name" />
79
+ </ ReferenceArrayInput >
80
+ </ Form >
81
+ </ AdminContext >
82
+ ) ;
83
+
84
+ export const ErrorSelectArray = ( ) => (
85
+ < AdminContext
86
+ dataProvider = { {
87
+ getList : ( ) => Promise . reject ( new Error ( 'fetch error' ) ) ,
88
+ getMany : ( ) =>
89
+ Promise . resolve ( { data : [ { id : 5 , name : 'test1' } ] } ) ,
90
+ } }
91
+ i18nProvider = { i18nProvider }
92
+ >
93
+ < Form onSubmit = { ( ) => { } } defaultValues = { { tag_ids : [ 5 ] } } >
94
+ < ReferenceArrayInput
95
+ reference = "tags"
96
+ resource = "posts"
97
+ source = "tag_ids"
98
+ >
99
+ < SelectArrayInput optionText = "name" />
100
+ </ ReferenceArrayInput >
101
+ </ Form >
102
+ </ AdminContext >
103
+ ) ;
104
+
105
+ export const WithCheckboxGroupInput = ( ) => (
106
+ < AdminContext dataProvider = { dataProvider } i18nProvider = { i18nProvider } >
107
+ < Form onSubmit = { ( ) => { } } defaultValues = { { tag_ids : [ 5 ] } } >
108
+ < ReferenceArrayInput
109
+ reference = "tags"
110
+ resource = "posts"
111
+ source = "tag_ids"
112
+ >
113
+ < CheckboxGroupInput optionText = "name" />
114
+ </ ReferenceArrayInput >
115
+ </ Form >
116
+ </ AdminContext >
117
+ ) ;
118
+
119
+ export const ErrorCheckboxGroupInput = ( ) => (
120
+ < AdminContext
121
+ dataProvider = { {
122
+ getList : ( ) => Promise . reject ( new Error ( 'fetch error' ) ) ,
123
+ getMany : ( ) =>
124
+ Promise . resolve ( { data : [ { id : 5 , name : 'test1' } ] } ) ,
125
+ } }
126
+ i18nProvider = { i18nProvider }
127
+ >
128
+ < Form onSubmit = { ( ) => { } } defaultValues = { { tag_ids : [ 5 ] } } >
129
+ < ReferenceArrayInput
130
+ reference = "tags"
131
+ resource = "posts"
132
+ source = "tag_ids"
133
+ >
134
+ < CheckboxGroupInput optionText = "name" />
135
+ </ ReferenceArrayInput >
136
+ </ Form >
137
+ </ AdminContext >
138
+ ) ;
139
+
140
+ export const WithDatagridInput = ( ) => (
141
+ < AdminContext dataProvider = { dataProvider } i18nProvider = { i18nProvider } >
142
+ < Form onSubmit = { ( ) => { } } defaultValues = { { tag_ids : [ 5 ] } } >
143
+ < ReferenceArrayInput
144
+ reference = "tags"
145
+ resource = "posts"
146
+ source = "tag_ids"
147
+ >
148
+ < DatagridInput rowClick = "toggleSelection" sx = { { mt : 6 } } >
149
+ < TextField source = "name" />
150
+ </ DatagridInput >
151
+ </ ReferenceArrayInput >
152
+ </ Form >
153
+ </ AdminContext >
154
+ ) ;
155
+
156
+ export const ErrorDatagridInput = ( ) => (
157
+ < AdminContext
158
+ dataProvider = { {
159
+ getList : ( ) => Promise . reject ( new Error ( 'fetch error' ) ) ,
160
+ getMany : ( ) =>
161
+ Promise . resolve ( { data : [ { id : 5 , name : 'test1' } ] } ) ,
162
+ } }
163
+ i18nProvider = { i18nProvider }
164
+ >
34
165
< Form onSubmit = { ( ) => { } } defaultValues = { { tag_ids : [ 5 ] } } >
35
166
< ReferenceArrayInput
36
167
reference = "tags"
0 commit comments