-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: remove PropertyInEdit from the docs
fixes: #599
- Loading branch information
Wojciech Krysiak
authored and
Wojciech Krysiak
committed
Sep 23, 2020
1 parent
fd6a3b1
commit 3e8c540
Showing
2 changed files
with
42 additions
and
50 deletions.
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
41 changes: 41 additions & 0 deletions
41
src/frontend/components/property-type/docs/on-property-change.doc.md
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,41 @@ | ||
On change callback - It can take: | ||
|
||
* one argument which is an entire {@link RecordJSON} | ||
* 2 arguments - one __property.name__ and the second one: __value__. | ||
|
||
* Used by the __edit__ and __filter__ components. | ||
|
||
Let's take a look at an example of the edit component | ||
|
||
It has one button: "Set Name". When this button is clicked - it triggers `onChange` callback | ||
function. In this case we are passing an updated record, so that we can change value of another | ||
property: `name`. | ||
|
||
```javascript | ||
import React from 'react' | ||
import { unflatten } from 'admin-bro' | ||
import { Button, Box } from '@admin-bro/design-system' | ||
|
||
const ValueTrigger = (props) => { | ||
const { onChange, record } = props | ||
|
||
const handleClick = (): void => { | ||
onChange({ | ||
...record, | ||
params: { | ||
...record.params, | ||
name: 'my new name', | ||
}, | ||
}) | ||
} | ||
|
||
return ( | ||
<Box mb="xxl"> | ||
<Button type="button" onClick={handleClick}>Set Name</Button> | ||
</Box> | ||
) | ||
} | ||
|
||
export default ValueTrigger | ||
|
||
``` |