-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom id generation #69
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a71f625
Add support for custom id generation
djhi 8bea60f
Fix RegExp for identifier matching
djhi 1c5b4f0
Fix MSW
djhi f5e2506
[no ci] Apply suggestions from code review
slax57 3520e97
change definition of Server and Collection constructors to use objects
slax57 f0d2880
Add more views to the example
djhi b14b188
Fix MSW integration
djhi 1756048
Add upgrade guide
djhi a879f47
Apply suggestions from code review
djhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Upgrading to 4.0.0 | ||
|
||
## Constructors Of `FetchServer` and `Server` Take An Object | ||
|
||
For `Server`: | ||
|
||
```diff | ||
import { Server } from 'fakerest'; | ||
import { data } from './data'; | ||
|
||
-const server = new Server('http://myapi.com'); | ||
+const server = new Server({ baseUrl: 'http://myapi.com' }); | ||
server.init(data); | ||
``` | ||
|
||
For `FetchServer`: | ||
|
||
```diff | ||
import { FetchServer } from 'fakerest'; | ||
import { data } from './data'; | ||
|
||
-const server = new FetchServer('http://myapi.com'); | ||
+const server = new FetchServer({ baseUrl: 'http://myapi.com' }); | ||
server.init(data); | ||
``` | ||
|
||
## Constructor Of `Collection` Takes An Object | ||
|
||
```diff | ||
-const posts = new Collection([ | ||
- { id: 1, title: 'baz' }, | ||
- { id: 2, title: 'biz' }, | ||
- { id: 3, title: 'boz' }, | ||
-]); | ||
+const posts = new Collection({ | ||
+ items: [ | ||
+ { id: 1, title: 'baz' }, | ||
+ { id: 2, title: 'biz' }, | ||
+ { id: 3, title: 'boz' }, | ||
+ ], | ||
+}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,41 @@ | ||
import React from 'react'; | ||
import { Admin, ListGuesser, Resource } from 'react-admin'; | ||
import { | ||
Admin, | ||
Create, | ||
EditGuesser, | ||
ListGuesser, | ||
Resource, | ||
ShowGuesser, | ||
} from 'react-admin'; | ||
import { dataProvider } from './dataProvider'; | ||
|
||
export const App = () => { | ||
return ( | ||
<Admin dataProvider={dataProvider}> | ||
<Resource name="books" list={ListGuesser} /> | ||
<Resource name="authors" list={ListGuesser} /> | ||
<Resource | ||
name="books" | ||
list={ListGuesser} | ||
create={BookCreate} | ||
edit={EditGuesser} | ||
show={ShowGuesser} | ||
/> | ||
<Resource | ||
name="authors" | ||
list={ListGuesser} | ||
edit={EditGuesser} | ||
show={ShowGuesser} | ||
/> | ||
</Admin> | ||
); | ||
}; | ||
|
||
import { Edit, ReferenceInput, SimpleForm, TextInput } from 'react-admin'; | ||
|
||
export const BookCreate = () => ( | ||
<Create> | ||
<SimpleForm> | ||
<ReferenceInput source="author_id" reference="authors" /> | ||
<TextInput source="title" /> | ||
</SimpleForm> | ||
</Create> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this may break things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't noticed any and I don't see any other way to support custom ids