@@ -82,13 +82,11 @@ import parseHydraDocumentation from 'api-doc-parser/lib/hydra/parseHydraDocument
82
82
83
83
const entrypoint = ' https://demo.api-platform.com' ;
84
84
85
- class Admin extends Component {
86
- state = {api: null };
85
+ export default class extends Component {
86
+ state = {api: null , resources : null };
87
87
88
88
componentDidMount () {
89
- parseHydraDocumentation (entrypoint).then (api => {
90
- const r = api .resources ;
91
-
89
+ parseHydraDocumentation (entrypoint).then ({api, resources} => {
92
90
const books = r .find (r => ' books' === r .name );
93
91
94
92
// Set the field in the list and the show views
@@ -107,19 +105,17 @@ class Admin extends Component {
107
105
< / ReferenceArrayInput>
108
106
;
109
107
110
- this .setState ({api: api });
108
+ this .setState ({api, resources });
111
109
}
112
110
)
113
111
}
114
112
115
113
render () {
116
114
if (null === this .state .api ) return < div> Loading... < / div> ;
117
115
118
- return < AdminBuilder api= {this .state .api } restClient= {hydraClient (entrypoint)}/ >
116
+ return < AdminBuilder api= {this .state .api } restClient= {hydraClient ({ entrypoint: entrypoint, resources : this . state . resources } )}/ >
119
117
}
120
118
}
121
-
122
- export default Admin ;
123
119
```
124
120
125
121
The admin now properly handles this ` to-many ` relation!
@@ -131,7 +127,7 @@ We'll make one last improvement to our admin: transforming the relation selector
131
127
Start by adding a "partial search" filter on the ` name ` property of the ` Book ` resource class.
132
128
133
129
``` yaml
134
- # etc/packages/api_platform.yaml
130
+ # config/api_filters.yml
135
131
136
132
services :
137
133
person.search_filter :
0 commit comments