@applica-software-guru/react-admin 1.5.256 → 1.5.258
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-fields/AttachmentField.d.ts +6 -1
- package/dist/components/ra-fields/AttachmentField.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +2 -2
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +1059 -1058
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +2 -2
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ra-fields/AttachmentField.tsx +10 -3
package/package.json
CHANGED
|
@@ -6,11 +6,12 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
6
6
|
import { useDataProvider, useRecordContext, useResourceContext, useTranslate } from 'react-admin';
|
|
7
7
|
|
|
8
8
|
function AttachmentField({
|
|
9
|
-
entityId,
|
|
9
|
+
entityId: _entityId,
|
|
10
10
|
property,
|
|
11
11
|
disabled,
|
|
12
12
|
showUser = false,
|
|
13
13
|
userResource = 'entities/user',
|
|
14
|
+
resource: _resource,
|
|
14
15
|
...props
|
|
15
16
|
}: AttachmentFieldProps): JSX.Element {
|
|
16
17
|
const [user, setUser] = useState<any>(null);
|
|
@@ -22,7 +23,8 @@ 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 = _resource || resource.replace('entities/', '');
|
|
27
|
+
const entityId = _entityId || record?.id;
|
|
26
28
|
const attachment = await dataProvider.getFile(
|
|
27
29
|
`/attachments/${entity}/${entityId || record?.id}/${property || props?.source}/${item?.id || record?.id}`
|
|
28
30
|
);
|
|
@@ -31,7 +33,7 @@ function AttachmentField({
|
|
|
31
33
|
link.download = get(record, props?.title || props?.source);
|
|
32
34
|
link.click();
|
|
33
35
|
},
|
|
34
|
-
[dataProvider, record,
|
|
36
|
+
[dataProvider, record, _entityId, resource, _resource, property, props?.source, props?.title]
|
|
35
37
|
);
|
|
36
38
|
const _record = useMemo(
|
|
37
39
|
() => ({
|
|
@@ -89,6 +91,11 @@ type AttachmentFieldProps = BaseAttachmentFieldProps & {
|
|
|
89
91
|
* If true, the user data associated with the single attachment will be displayed.
|
|
90
92
|
*/
|
|
91
93
|
showUser?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* When the AttachmentInput is used inside a nested form, you can specify the root entity to use for the REST calls.
|
|
96
|
+
* If not specified, the default value is the current entity passed by context.
|
|
97
|
+
*/
|
|
98
|
+
resource?: string;
|
|
92
99
|
};
|
|
93
100
|
|
|
94
101
|
export { AttachmentField };
|