Skip to content

Commit bb66163

Browse files
authored
Merge pull request #10681 from marmelab/doc/AutoPersistInStore
[doc] Add `AutoPersistInStore` doc page
2 parents 185097f + e23b3db commit bb66163

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+141
-66
lines changed

docs/AccordionForm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "AccordionForm"
55

66
# `<AccordionForm>`
77

8-
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" /> component offers an alternative layout for Edit and Create forms, where Inputs are grouped into expandable panels.
8+
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> component offers an alternative layout for Edit and Create forms, where Inputs are grouped into expandable panels.
99

1010
<video controls autoplay playsinline muted loop>
1111
<source src="https://react-admin-ee.marmelab.com/assets/ra-accordion-form-overview.mp4" type="video/mp4" />

docs/AuthRBAC.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Building up on react-admin's [Access Control features](./Permissions.md#access-c
1111
<source src="./img/ra-rbac.mp4" type="video/mp4" />
1212
</video>
1313

14-
The RBAC features are part of [ra-rbac](https://react-admin-ee.marmelab.com/documentation/ra-rbac), an [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" /> package. Test them live in the [Enterprise Edition Storybook](https://react-admin.github.io/ra-enterprise/?path=/story/ra-rbac-full-app--full-app).
14+
The RBAC features are part of [ra-rbac](https://react-admin-ee.marmelab.com/documentation/ra-rbac), an [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> package. Test them live in the [Enterprise Edition Storybook](https://react-admin.github.io/ra-enterprise/?path=/story/ra-rbac-full-app--full-app).
1515

1616
## At a Glance
1717

docs/AutoPersistInStore.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
layout: default
3+
title: "The AutoPersistInStore Component"
4+
---
5+
6+
# `<AutoPersistInStore>`
7+
8+
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> component saves a form data in the store on unmount (e.g. when users leave the page) and reapplies it on mount.
9+
It's ideal to ensure users don't loose their already filled data in an edit or a create form when they navigate to another page.
10+
11+
<video controls autoplay playsinline muted loop>
12+
<source src="./img/AutoPersistInStore.mp4" type="video/mp4"/>
13+
Your browser does not support the video tag.
14+
</video>
15+
16+
## Usage
17+
18+
Add `<AutoPersistInStore>` inside a react-admin form (`<SimpleForm>`, `<TabbedForm>`, `<LongForm>`, etc.):
19+
20+
```tsx
21+
import { AutoPersistInStore } from '@react-admin/ra-form-layout';
22+
import { Edit, SimpleForm, TextInput } from 'react-admin';
23+
24+
const PostEdit = () => (
25+
<Edit>
26+
<SimpleForm>
27+
<TextInput source="title" />
28+
<TextInput source="teaser" />
29+
<AutoPersistInStore />
30+
</SimpleForm>
31+
</Edit>
32+
);
33+
```
34+
35+
## Props
36+
37+
| Prop | Required | Type | Default | Description |
38+
| --------------------- | -------- | ---------- | -------------------------------------------------------- | ------------------------------------------------------------- |
39+
| `getStoreKey` | - | `function` | - | Function to use your own store key. |
40+
| `notificationMessage` | - | `string` | `"ra-form-layout.` `auto_persist_ in_store` `.applied_changes"` | Notification message to inform users that their previously saved changes have been applied. |
41+
42+
## `getStoreKey`
43+
44+
To save the current form data in the [store](./useStoreContext.md), `<AutoPersistInStore>` uses a default key that can be overridden with the `getStoreKey` prop.
45+
It accepts a function with two parameters:
46+
47+
- `resource`: The current resource.
48+
- `record`: The current record if you are in an [edit context](./useEditContext.md).
49+
50+
```tsx
51+
<AutoPersistInStore
52+
getStoreKey={
53+
(resource: ResourceContextValue, record: RaRecord<Identifier> | undefined) =>
54+
`my-custom-persist-key-${resource}-${record && record.hasOwnProperty('id') ? record.id : 'create'}`
55+
}
56+
/>
57+
```
58+
59+
The default key is `ra-persist-YOUR_RESOURCE-RECORD_ID` (in case of a create form, the record `id` is replaced by `"create"`), e.g. `ra-persist-customers-5`.
60+
61+
## `notificationMessage`
62+
63+
When `<AutoPersistInStore>` component applies the changes from the store to a form, react-admin's inform users with a notification. You can customize it with the `notificationMessage` prop:
64+
65+
```tsx
66+
<AutoPersistInStore notificationMessage="Modifications applied" />
67+
```
68+
69+
**Tip:** You can pass a translation key as well:
70+
71+
```tsx
72+
<AutoPersistInStore notificationMessage="myroot.message.auto_persist_applied" />
73+
```

docs/AutoSave.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "The AutoSave Component"
55

66
# `<AutoSave>`
77

8-
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" /> component enables autosaving of the form. Alternative to [`<SaveButton>`](./SaveButton.md), it's ideal for long data entry tasks, and reduces the risk of data loss.
8+
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> component enables autosaving of the form. Alternative to [`<SaveButton>`](./SaveButton.md), it's ideal for long data entry tasks, and reduces the risk of data loss.
99

1010
<video controls autoplay playsinline muted loop>
1111
<source src="./img/AutoSave.webm" type="video/webm"/>

docs/Breadcrumb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "The Breadcrumb Component"
55

66
# `<Breadcrumb>`
77

8-
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" /> component renders a breadcrumb path that automatically adapts to the page location. It helps users navigate large web applications.
8+
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> component renders a breadcrumb path that automatically adapts to the page location. It helps users navigate large web applications.
99

1010
<video controls autoplay playsinline muted loop width="100%">
1111
<source src="https://react-admin-ee.marmelab.com/assets/ra-navigation/latest/breadcumb-nested-resource.mp4" type="video/mp4" />

docs/Buttons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Alternately, pass a `successMessage` prop:
234234

235235
## `<BulkUpdateFormButton>`
236236

237-
This component, part of the [enterprise edition](https://react-admin-ee.marmelab.com/documentation/ra-form-layout)<img class="icon" src="./img/premium.svg" />, lets users edit multiple records at once. To be used inside [the `<Datagrid bulkActionButtons>` prop](./Datagrid.md#bulkactionbuttons).
237+
This component, part of the [enterprise edition](https://react-admin-ee.marmelab.com/documentation/ra-form-layout)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" />, lets users edit multiple records at once. To be used inside [the `<Datagrid bulkActionButtons>` prop](./Datagrid.md#bulkactionbuttons).
238238

239239
<video controls autoplay playsinline muted loop>
240240
<source src="./img/BulkUpdateButton-SimpleForm.webm" type="video/webm"/>

docs/Calendar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "The Calendar Component"
55

66
# `<Calendar>`
77

8-
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" /> component, part of [the `ra-calendar` module](https://react-admin-ee.marmelab.com/documentation/ra-calendar), renders a list of events as a calendar.
8+
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> component, part of [the `ra-calendar` module](https://react-admin-ee.marmelab.com/documentation/ra-calendar), renders a list of events as a calendar.
99

1010
<video controls autoplay playsinline muted loop>
1111
<source src="https://react-admin-ee.marmelab.com/assets/ra-calendar.mp4" type="video/mp4" />

docs/ContainerLayout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "ContainerLayout"
55

66
# `<ContainerLayout>`
77

8-
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" /> component offers an alternative to react-admin's `<Layout>` for applications with a limited number of resources. It displays the content in a centered container, has no sidebar, and uses the top bar for navigation.
8+
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> component offers an alternative to react-admin's `<Layout>` for applications with a limited number of resources. It displays the content in a centered container, has no sidebar, and uses the top bar for navigation.
99

1010
![Container layout](https://react-admin-ee.marmelab.com/assets/ra-navigation/latest/container-layout.png)
1111

docs/CreateDialog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "CreateDialog"
55

66
# `<CreateDialog>`
77

8-
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" /> component offers a replacement to [the `<Create>` component](./Create.md) allowing users to create records without leaving the context of the list page.
8+
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> component offers a replacement to [the `<Create>` component](./Create.md) allowing users to create records without leaving the context of the list page.
99

1010
<video controls autoplay playsinline muted loop>
1111
<source src="https://react-admin-ee.marmelab.com/assets/create-dialog.mp4" type="video/mp4" />

docs/CreateInDialogButton.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: "CreateInDialogButton"
55

66
# `<CreateInDialogButton>`
77

8-
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" /> component offers a way to open a `<Create>` view inside a dialog, hence allowing to create a new record without leaving the current view.
8+
This [Enterprise Edition](https://react-admin-ee.marmelab.com)<img class="icon" src="./img/premium.svg" alt="React Admin Enterprise Edition icon" /> component offers a way to open a `<Create>` view inside a dialog, hence allowing to create a new record without leaving the current view.
99

1010
<video controls autoplay playsinline muted loop>
1111
<source src="https://react-admin-ee.marmelab.com/assets/ra-form-layout/latest/CreateInDialogButton.mp4" type="video/mp4" />

0 commit comments

Comments
 (0)