@applica-software-guru/react-admin 1.5.273 → 1.5.274
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.map +1 -1
- package/dist/react-admin.cjs.js +31 -31
- package/dist/react-admin.cjs.js.gz +0 -0
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +1517 -1517
- package/dist/react-admin.es.js.gz +0 -0
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +31 -31
- package/dist/react-admin.umd.js.gz +0 -0
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ra-fields/AttachmentField.tsx +6 -3
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { Box, Typography } from '@mui/material';
|
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import { get } from 'lodash';
|
|
5
5
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
-
import { useDataProvider, useRecordContext, useResourceContext, useTranslate } from 'react-admin';
|
|
6
|
+
import { useDataProvider, useNotify, useRecordContext, useResourceContext, useTranslate } from 'react-admin';
|
|
7
7
|
|
|
8
8
|
function AttachmentField({
|
|
9
9
|
entityId: _entityId,
|
|
@@ -18,12 +18,15 @@ function AttachmentField({
|
|
|
18
18
|
const record = useRecordContext(props);
|
|
19
19
|
const dataProvider = useDataProvider();
|
|
20
20
|
const resource = useResourceContext();
|
|
21
|
+
const notify = useNotify();
|
|
21
22
|
const handleClick = useCallback(
|
|
22
23
|
async (e: any) => {
|
|
23
24
|
e.preventDefault();
|
|
24
25
|
e.stopPropagation();
|
|
26
|
+
notify('ra.notification.download', { type: 'info' });
|
|
27
|
+
|
|
25
28
|
const item = get(record, props?.source);
|
|
26
|
-
const entity = _resource || resource.replace('entities/', '');
|
|
29
|
+
const entity = (_resource || resource).replace('entities/', '');
|
|
27
30
|
const entityId = _entityId || record?.id;
|
|
28
31
|
const attachment = await dataProvider.getFile(
|
|
29
32
|
`/attachments/${entity}/${entityId}/${property || props?.source}/${item?.id || record?.id}`
|
|
@@ -33,7 +36,7 @@ function AttachmentField({
|
|
|
33
36
|
link.download = get(record, props?.title || props?.source);
|
|
34
37
|
link.click();
|
|
35
38
|
},
|
|
36
|
-
[dataProvider, record, _entityId, resource, _resource, property, props?.source, props?.title]
|
|
39
|
+
[dataProvider, record, _entityId, resource, _resource, property, props?.source, props?.title, notify]
|
|
37
40
|
);
|
|
38
41
|
const _record = useMemo(
|
|
39
42
|
() => ({
|