@applica-software-guru/react-admin 1.5.255 → 1.5.257
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ra-buttons/CreateInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-buttons/EditInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-fields/AttachmentField.d.ts +6 -1
- package/dist/components/ra-fields/AttachmentField.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +54 -56
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +5238 -5287
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +53 -55
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ra-buttons/CreateInDialogButton.tsx +21 -19
- package/src/components/ra-buttons/EditInDialogButton.tsx +35 -24
- package/src/components/ra-fields/AttachmentField.tsx +8 -2
- package/src/playground/components/ra-forms/CategoryForm.jsx +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button as RaButton } from './Button';
|
|
2
2
|
import { Toolbar } from '@/components/ra-forms';
|
|
3
3
|
import { PlusCircleOutlined } from '@ant-design/icons';
|
|
4
|
-
import { Breakpoint, Button, Dialog } from '@mui/material';
|
|
4
|
+
import { Breakpoint, Button, Dialog, DialogContent } from '@mui/material';
|
|
5
5
|
import { CreateBase, UseCreateMutateParams, useResourceContext, useTranslate } from 'ra-core';
|
|
6
6
|
import { ButtonProps, CreateButton, CreateButtonProps, CreateProps, SaveButton } from 'ra-ui-materialui';
|
|
7
7
|
import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
|
|
@@ -158,24 +158,26 @@ function CreateInDialogButton(props: CreateInDialogButtonProps) {
|
|
|
158
158
|
fullWidth={fullWidth}
|
|
159
159
|
fullScreen={fullScreen}
|
|
160
160
|
>
|
|
161
|
-
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
161
|
+
<DialogContent sx={{ m: 0, p: 0 }}>
|
|
162
|
+
{React.isValidElement(Child)
|
|
163
|
+
? React.cloneElement(Child, {
|
|
164
|
+
...Child.props,
|
|
165
|
+
modal: true,
|
|
166
|
+
toolbar: (
|
|
167
|
+
<Toolbar>
|
|
168
|
+
<Button variant="text" size="medium" onClick={handleClose}>
|
|
169
|
+
{translate('ra.action.cancel')}
|
|
170
|
+
</Button>
|
|
171
|
+
{onSubmit ? (
|
|
172
|
+
<SubmitButton onSubmit={onSubmit!} closeDialog={handleClose} />
|
|
173
|
+
) : (
|
|
174
|
+
<SaveButton type="button" />
|
|
175
|
+
)}
|
|
176
|
+
</Toolbar>
|
|
177
|
+
)
|
|
178
|
+
})
|
|
179
|
+
: null}
|
|
180
|
+
</DialogContent>
|
|
179
181
|
</Dialog>
|
|
180
182
|
</CreateBase>
|
|
181
183
|
</>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Button } from './Button';
|
|
2
2
|
import { Toolbar } from '@/components/ra-forms';
|
|
3
|
-
import { Breakpoint, Dialog } from '@mui/material';
|
|
3
|
+
import { Breakpoint, Dialog, DialogContent } from '@mui/material';
|
|
4
4
|
import { EditBase, UseUpdateMutateParams, useRecordContext } from 'ra-core';
|
|
5
5
|
import { EditButton, EditProps, SaveButton } from 'ra-ui-materialui';
|
|
6
6
|
import React, { Children, PropsWithChildren, useCallback, useState } from 'react';
|
|
@@ -76,7 +76,16 @@ type EditInDialogButtonProps = PropsWithChildren &
|
|
|
76
76
|
onSubmit?: SubmitFunction;
|
|
77
77
|
};
|
|
78
78
|
function EditInDialogButton(props: EditInDialogButtonProps): JSX.Element {
|
|
79
|
-
const {
|
|
79
|
+
const {
|
|
80
|
+
children,
|
|
81
|
+
maxWidth = 'md',
|
|
82
|
+
fullWidth = true,
|
|
83
|
+
fullScreen,
|
|
84
|
+
mutationOptions,
|
|
85
|
+
onSubmit,
|
|
86
|
+
scroll = 'paper',
|
|
87
|
+
...rest
|
|
88
|
+
} = props;
|
|
80
89
|
const [open, setOpen] = useState(false);
|
|
81
90
|
const Child = Children.only(children);
|
|
82
91
|
const handleOpen = useCallback(() => setOpen(true), []);
|
|
@@ -110,28 +119,30 @@ function EditInDialogButton(props: EditInDialogButtonProps): JSX.Element {
|
|
|
110
119
|
fullScreen={fullScreen}
|
|
111
120
|
keepMounted={false}
|
|
112
121
|
>
|
|
113
|
-
{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
<DialogContent sx={{ m: 0, p: 0 }}>
|
|
123
|
+
{React.isValidElement(Child)
|
|
124
|
+
? React.cloneElement(Child, {
|
|
125
|
+
...Child.props,
|
|
126
|
+
modal: true,
|
|
127
|
+
toolbar: (
|
|
128
|
+
<Toolbar>
|
|
129
|
+
<Button
|
|
130
|
+
disableIconOnly
|
|
131
|
+
variant="text"
|
|
132
|
+
size="medium"
|
|
133
|
+
onClick={handleClose}
|
|
134
|
+
label="ra.action.cancel"
|
|
135
|
+
/>
|
|
136
|
+
{onSubmit ? (
|
|
137
|
+
<SubmitButton onSubmit={onSubmit!} closeDialog={handleClose} />
|
|
138
|
+
) : (
|
|
139
|
+
<SaveButton type="button" />
|
|
140
|
+
)}
|
|
141
|
+
</Toolbar>
|
|
142
|
+
)
|
|
143
|
+
})
|
|
144
|
+
: null}
|
|
145
|
+
</DialogContent>
|
|
135
146
|
</Dialog>
|
|
136
147
|
</EditBase>
|
|
137
148
|
</>
|
|
@@ -11,6 +11,7 @@ function AttachmentField({
|
|
|
11
11
|
disabled,
|
|
12
12
|
showUser = false,
|
|
13
13
|
userResource = 'entities/user',
|
|
14
|
+
rootEntity = undefined,
|
|
14
15
|
...props
|
|
15
16
|
}: AttachmentFieldProps): JSX.Element {
|
|
16
17
|
const [user, setUser] = useState<any>(null);
|
|
@@ -22,7 +23,7 @@ function AttachmentField({
|
|
|
22
23
|
e.preventDefault();
|
|
23
24
|
e.stopPropagation();
|
|
24
25
|
const item = get(record, props?.source);
|
|
25
|
-
const entity = resource.replace('entities/', '');
|
|
26
|
+
const entity = rootEntity || resource.replace('entities/', '');
|
|
26
27
|
const attachment = await dataProvider.getFile(
|
|
27
28
|
`/attachments/${entity}/${entityId || record?.id}/${property || props?.source}/${item?.id || record?.id}`
|
|
28
29
|
);
|
|
@@ -31,7 +32,7 @@ function AttachmentField({
|
|
|
31
32
|
link.download = get(record, props?.title || props?.source);
|
|
32
33
|
link.click();
|
|
33
34
|
},
|
|
34
|
-
[dataProvider, record, entityId, resource, property, props?.source, props?.title]
|
|
35
|
+
[dataProvider, record, entityId, resource, rootEntity, property, props?.source, props?.title]
|
|
35
36
|
);
|
|
36
37
|
const _record = useMemo(
|
|
37
38
|
() => ({
|
|
@@ -89,6 +90,11 @@ type AttachmentFieldProps = BaseAttachmentFieldProps & {
|
|
|
89
90
|
* If true, the user data associated with the single attachment will be displayed.
|
|
90
91
|
*/
|
|
91
92
|
showUser?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* When the AttachmentInput is used inside a nested form, you can specify the root entity to use for the REST calls.
|
|
95
|
+
* If not specified, the default value is the current entity passed by context.
|
|
96
|
+
*/
|
|
97
|
+
rootEntity?: string;
|
|
92
98
|
};
|
|
93
99
|
|
|
94
100
|
export { AttachmentField };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BooleanInput, LocalizedTextInput, SimpleForm, required } from '@/';
|
|
2
|
+
import { ArrayInput, SimpleFormIterator } from 'ra-ui-materialui';
|
|
2
3
|
|
|
3
4
|
function requiredAtLeastOneTranslation(message = 'ra.validation.at_least_one_translation') {
|
|
4
5
|
return (value, values) => {
|