@applica-software-guru/react-admin 1.3.174 → 1.3.176
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/Layout/Header/Notification/Notification.d.ts.map +1 -1
- package/dist/components/Layout/Header/Notification/NotificationItem.d.ts.map +1 -1
- package/dist/components/ra-fields/DateAgoField.d.ts.map +1 -1
- package/dist/components/ra-inputs/SelectInput.d.ts +1 -24
- package/dist/components/ra-inputs/SelectInput.d.ts.map +1 -1
- package/dist/contexts/ThemeConfigContext.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +49 -49
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +5583 -5524
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +52 -52
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Layout/Header/Notification/Notification.tsx +28 -4
- package/src/components/Layout/Header/Notification/NotificationItem.tsx +18 -2
- package/src/components/ra-fields/DateAgoField.jsx +2 -0
- package/src/components/ra-inputs/AutocompleteArrayInput.jsx +3 -3
- package/src/components/ra-inputs/AutocompleteInput.jsx +3 -3
- package/src/components/ra-inputs/LabeledInput.tsx +1 -1
- package/src/components/ra-inputs/SelectArrayInput.jsx +3 -3
- package/src/components/ra-inputs/SelectInput.tsx +4 -9
- package/src/contexts/ThemeConfigContext.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BellOutlined, CheckCircleOutlined } from '@ant-design/icons';
|
|
2
2
|
import { useLayoutMediaState, useLayoutNotificationsState } from '../../Provider';
|
|
3
3
|
import { HeaderToggleButton } from '../Buttons';
|
|
4
|
-
import { useGetList, useTranslate } from 'ra-core';
|
|
4
|
+
import { useGetList, useNotify, useRefresh, useTranslate, useUpdateMany } from 'ra-core';
|
|
5
5
|
import { HeaderNotificationItem, INotification } from './NotificationItem';
|
|
6
|
-
import { useEffect, useState } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
7
7
|
import {
|
|
8
8
|
Badge,
|
|
9
9
|
ClickAwayListener,
|
|
@@ -21,6 +21,7 @@ import { usePopoverState } from '../../../../hooks';
|
|
|
21
21
|
import { IconButton, Transitions } from '../../../@extended';
|
|
22
22
|
import MainCard from '../../../MainCard';
|
|
23
23
|
import { Link } from 'react-router-dom';
|
|
24
|
+
import dayjs from 'dayjs';
|
|
24
25
|
|
|
25
26
|
const avatarSx = {
|
|
26
27
|
width: 36,
|
|
@@ -45,6 +46,8 @@ function HeaderNotification() {
|
|
|
45
46
|
function HeaderNotificationButton() {
|
|
46
47
|
const translate = useTranslate(),
|
|
47
48
|
theme = useTheme(),
|
|
49
|
+
refresh = useRefresh(),
|
|
50
|
+
notify = useNotify(),
|
|
48
51
|
{ downMd } = useLayoutMediaState(),
|
|
49
52
|
{ resource } = useLayoutNotificationsState(),
|
|
50
53
|
[notifications, setNotifications] = useState<Array<INotification>>([]),
|
|
@@ -64,6 +67,27 @@ function HeaderNotificationButton() {
|
|
|
64
67
|
}
|
|
65
68
|
}, [data, isLoading]);
|
|
66
69
|
|
|
70
|
+
const unreadNotificationIds = notifications.filter((notification) => !notification.readed).map((notification) => notification.id);
|
|
71
|
+
|
|
72
|
+
const [updateMany] = useUpdateMany(
|
|
73
|
+
resource,
|
|
74
|
+
{
|
|
75
|
+
ids: unreadNotificationIds,
|
|
76
|
+
data: { readed: dayjs().format('YYYY-MM-DD HH:mm:ss') }
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
onSuccess: () => {
|
|
80
|
+
refresh();
|
|
81
|
+
notify('resources.notifications.messages.readed.done');
|
|
82
|
+
},
|
|
83
|
+
onError: () => notify('ra.notification.readed_error')
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const handleUpdateMany = useCallback(() => {
|
|
88
|
+
updateMany();
|
|
89
|
+
}, [updateMany]);
|
|
90
|
+
|
|
67
91
|
return (
|
|
68
92
|
<>
|
|
69
93
|
<HeaderToggleButton value="notifications" selected={open} onChange={handleToggle}>
|
|
@@ -90,14 +114,14 @@ function HeaderNotificationButton() {
|
|
|
90
114
|
>
|
|
91
115
|
<ClickAwayListener onClickAway={handleClose}>
|
|
92
116
|
<MainCard
|
|
93
|
-
title=
|
|
117
|
+
title={translate('ra.notification.title')}
|
|
94
118
|
elevation={0}
|
|
95
119
|
border={false}
|
|
96
120
|
content={false}
|
|
97
121
|
secondary={
|
|
98
122
|
<>
|
|
99
123
|
{read > 0 && (
|
|
100
|
-
<Tooltip title=
|
|
124
|
+
<Tooltip title={translate('ra.notification.mark-as-read')} onClick={handleUpdateMany}>
|
|
101
125
|
{/*@ts-ignore*/}
|
|
102
126
|
<IconButton color="success" size="small">
|
|
103
127
|
<CheckCircleOutlined style={{ fontSize: '1.15rem' }} />
|
|
@@ -74,9 +74,25 @@ function HeaderNotificationItem(props: IHeaderNotificationItemProps) {
|
|
|
74
74
|
<MessageOutlined />
|
|
75
75
|
</Avatar>
|
|
76
76
|
</ListItemAvatar>
|
|
77
|
-
<ListItemText
|
|
77
|
+
<ListItemText
|
|
78
|
+
sx={{
|
|
79
|
+
overflow: 'hidden',
|
|
80
|
+
wordBreak: 'break-word',
|
|
81
|
+
width: '90%'
|
|
82
|
+
}}
|
|
83
|
+
primary={notification.title}
|
|
84
|
+
secondary={notification.content}
|
|
85
|
+
/>
|
|
78
86
|
<Box flexGrow={1} flexShrink={1} minWidth={theme.spacing(2)} />
|
|
79
|
-
<ListItemText
|
|
87
|
+
<ListItemText
|
|
88
|
+
sx={{
|
|
89
|
+
overflow: 'hidden',
|
|
90
|
+
whiteSpace: 'pre-wrap',
|
|
91
|
+
wordBreak: 'break-word'
|
|
92
|
+
}}
|
|
93
|
+
primary={ago}
|
|
94
|
+
primaryTypographyProps={{ variant: 'caption' }}
|
|
95
|
+
/>
|
|
80
96
|
</ListItemButton>
|
|
81
97
|
</ListItem>
|
|
82
98
|
);
|
|
@@ -11,10 +11,10 @@ const StyledAutocompleteArrayInput = styled(RaAutocompleteArrayInput, {
|
|
|
11
11
|
},
|
|
12
12
|
'& .MuiAutocomplete-inputRoot': {
|
|
13
13
|
padding: `0px 9px`
|
|
14
|
-
},
|
|
15
|
-
'& label.MuiFormLabel-root[data-shrink="false"]': {
|
|
16
|
-
minHeight: '18px'
|
|
17
14
|
}
|
|
15
|
+
// '& label.MuiFormLabel-root[data-shrink="false"]': {
|
|
16
|
+
// minHeight: '18px'
|
|
17
|
+
// }
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -9,9 +9,9 @@ const StyledAutocompleteInput = styled(RaAutocompleteInput, {
|
|
|
9
9
|
'& legend': {
|
|
10
10
|
width: label === false ? 0 : 'auto'
|
|
11
11
|
},
|
|
12
|
-
'& label.MuiFormLabel-root[data-shrink="false"]': {
|
|
13
|
-
|
|
14
|
-
},
|
|
12
|
+
// '& label.MuiFormLabel-root[data-shrink="false"]': {
|
|
13
|
+
// minHeight: '18px'
|
|
14
|
+
// },
|
|
15
15
|
'& .MuiAutocomplete-inputRoot': {
|
|
16
16
|
// Serve ad allineare l'altezza di un input di tipo Autocomplete a quella degli altri campi utilizzati.
|
|
17
17
|
padding: `0px 9px`
|
|
@@ -4,7 +4,7 @@ import { FormHelperText, InputLabel, Stack } from '@mui/material';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { useAppConfig } from '../../hooks';
|
|
7
|
-
import { useTheme } from '@
|
|
7
|
+
import { useTheme } from '@mui/material/styles';
|
|
8
8
|
|
|
9
9
|
export type LabeledInputProps = InputProps & {
|
|
10
10
|
sx?: any;
|
|
@@ -12,10 +12,10 @@ const ApplicaStyledSelectArrayInput = styled(RaSelectArrayInput, {
|
|
|
12
12
|
'& .RaSelectArrayInput-chips > .RaSelectArrayInput-chip': {
|
|
13
13
|
marginTop: '-2px',
|
|
14
14
|
marginBottom: '-2px'
|
|
15
|
-
},
|
|
16
|
-
'& label.MuiFormLabel-root[data-shrink="false"]': {
|
|
17
|
-
marginTop: '2px'
|
|
18
15
|
}
|
|
16
|
+
// '& label.MuiFormLabel-root[data-shrink="false"]': {
|
|
17
|
+
// marginTop: '2px'
|
|
18
|
+
// }
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
21
|
ApplicaStyledSelectArrayInput.propTypes = {
|
|
@@ -8,11 +8,11 @@ const ApplicaStyledSelectInput = styled(RaSelectInput, {
|
|
|
8
8
|
slot: 'Root'
|
|
9
9
|
})(({ label }) => ({
|
|
10
10
|
'& legend': {
|
|
11
|
-
width: label === false ? 0 : 'auto'
|
|
12
|
-
},
|
|
13
|
-
'& label.MuiFormLabel-root[data-shrink="false"]': {
|
|
14
|
-
marginTop: '2px'
|
|
11
|
+
width: label === false || label === null ? 0 : 'auto'
|
|
15
12
|
}
|
|
13
|
+
// '& label.MuiFormLabel-root[data-shrink="false"]': {
|
|
14
|
+
// marginTop: '2px'
|
|
15
|
+
// }
|
|
16
16
|
}));
|
|
17
17
|
export type SelectInputProps = LabeledInputProps & RaSelectInputProps;
|
|
18
18
|
const SelectInput = (props: SelectInputProps) => (
|
|
@@ -21,9 +21,4 @@ const SelectInput = (props: SelectInputProps) => (
|
|
|
21
21
|
</LabeledInput>
|
|
22
22
|
);
|
|
23
23
|
|
|
24
|
-
SelectInput.propTypes = {
|
|
25
|
-
...RaSelectInput.propTypes,
|
|
26
|
-
...LabeledInput.propTypes
|
|
27
|
-
};
|
|
28
|
-
|
|
29
24
|
export default SelectInput;
|