@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/package.json CHANGED
@@ -115,5 +115,5 @@
115
115
  "type": "module",
116
116
  "types": "dist/index.d.ts",
117
117
  "typings": "dist/index.d.ts",
118
- "version": "1.5.255"
118
+ "version": "1.5.257"
119
119
  }
@@ -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
- {React.isValidElement(Child)
162
- ? React.cloneElement(Child, {
163
- ...Child.props,
164
- modal: true,
165
- toolbar: (
166
- <Toolbar>
167
- <Button variant="text" size="medium" onClick={handleClose}>
168
- {translate('ra.action.cancel')}
169
- </Button>
170
- {onSubmit ? (
171
- <SubmitButton onSubmit={onSubmit!} closeDialog={handleClose} />
172
- ) : (
173
- <SaveButton type="button" />
174
- )}
175
- </Toolbar>
176
- )
177
- })
178
- : null}
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 { children, maxWidth = 'md', fullWidth = true, fullScreen, mutationOptions, onSubmit, scroll, ...rest } = props;
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
- {React.isValidElement(Child)
114
- ? React.cloneElement(Child, {
115
- ...Child.props,
116
- modal: true,
117
- toolbar: (
118
- <Toolbar>
119
- <Button
120
- disableIconOnly
121
- variant="text"
122
- size="medium"
123
- onClick={handleClose}
124
- label="ra.action.cancel"
125
- />
126
- {onSubmit ? (
127
- <SubmitButton onSubmit={onSubmit!} closeDialog={handleClose} />
128
- ) : (
129
- <SaveButton type="button" />
130
- )}
131
- </Toolbar>
132
- )
133
- })
134
- : null}
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) => {