@applica-software-guru/react-admin 1.1.90 → 1.1.92
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-forms/Create.d.ts.map +1 -1
- package/dist/components/ra-forms/Edit.d.ts.map +1 -1
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts +2 -0
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts.map +1 -1
- package/dist/components/ra-inputs/AutocompleteArrayInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/AutocompleteInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/SelectArrayInput.d.ts.map +1 -1
- package/dist/components/ra-lists/List.d.ts.map +1 -1
- package/dist/hooks/useMenu.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +37 -37
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +6350 -6329
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +44 -44
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ra-forms/Create.tsx +4 -1
- package/src/components/ra-forms/Edit.jsx +3 -0
- package/src/components/ra-forms/TableForm/TableFormIterator.tsx +27 -18
- package/src/components/ra-forms/TableForm/TableFormIteratorItem.tsx +1 -1
- package/src/components/ra-inputs/AutocompleteArrayInput.jsx +4 -0
- package/src/components/ra-inputs/AutocompleteInput.jsx +7 -0
- package/src/components/ra-inputs/SelectArrayInput.jsx +3 -4
- package/src/components/ra-lists/List.tsx +15 -5
- package/src/hooks/useMenu.jsx +2 -1
- package/src/playground/components/ra-forms/UserForm.jsx +4 -4
package/package.json
CHANGED
|
@@ -6,7 +6,10 @@ const StyledCreate = styled(RaCreate, {
|
|
|
6
6
|
slot: 'root'
|
|
7
7
|
})(({ theme }) => ({
|
|
8
8
|
'& .RaCreate-card, & > div > div > form': {
|
|
9
|
-
backgroundColor: theme.palette.background.default
|
|
9
|
+
backgroundColor: theme.palette.background.default,
|
|
10
|
+
'& .RaToolbar-mobileToolbar': {
|
|
11
|
+
backgroundColor: 'yellow'
|
|
12
|
+
}
|
|
10
13
|
},
|
|
11
14
|
'& .RaCreate-main>.MuiPaper-root:first-of-type': {
|
|
12
15
|
overflow: 'visible'
|
|
@@ -8,6 +8,9 @@ const StyledEdit = styled(RaEdit, {
|
|
|
8
8
|
'& .RaEdi-card, & > div > div > form': {
|
|
9
9
|
backgroundColor: theme.palette.background.default
|
|
10
10
|
},
|
|
11
|
+
'& .RaToolbar-mobileToolbar': {
|
|
12
|
+
borderTop: `1px solid ${theme.palette.divider}`
|
|
13
|
+
},
|
|
11
14
|
'& .RaEdit-main>.MuiPaper-root:first-of-type': {
|
|
12
15
|
// Ci ho messo 4 ore per scrivere questa riga di codice e risolvere un problema con react-sticky-box ed i Long Form.
|
|
13
16
|
// L'overflow è di default 'hidden', a noi serve visibile per consentire a react-sticky-box di funzionare e gestire la visiblità con ancore
|
|
@@ -15,16 +15,15 @@ import {
|
|
|
15
15
|
TableRow,
|
|
16
16
|
Typography
|
|
17
17
|
} from '@mui/material';
|
|
18
|
-
import { RaRecord, useRecordContext, useTranslate } from 'ra-core';
|
|
18
|
+
import { RaRecord, useRecordContext, useTranslate, useTranslateLabel } from 'ra-core';
|
|
19
|
+
import { styled, useTheme } from '@mui/material/styles';
|
|
19
20
|
|
|
20
|
-
import { MoreHoriz } from '@mui/icons-material';
|
|
21
21
|
import { PlusCircleOutlined } from '@ant-design/icons';
|
|
22
22
|
import PropTypes from 'prop-types';
|
|
23
23
|
import { TableFormIteratorContext } from './TableFormIteratorContext';
|
|
24
24
|
import { TableFormIteratorItem } from './TableFormIteratorItem';
|
|
25
25
|
import { UseFieldArrayReturn } from 'react-hook-form';
|
|
26
26
|
import get from 'lodash/get';
|
|
27
|
-
import { styled } from '@mui/material/styles';
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
*
|
|
@@ -45,12 +44,14 @@ import { styled } from '@mui/material/styles';
|
|
|
45
44
|
* @returns
|
|
46
45
|
*/
|
|
47
46
|
const TableFormIterator = (props: TableFormIteratorProps) => {
|
|
48
|
-
const { children, resource, source, label, disableActions = false, disableAdd = false, disableRemove = false, className } = props;
|
|
47
|
+
const { children, resource, source, label, disableActions = false, disableAdd = false, disableRemove = false, className, empty } = props;
|
|
49
48
|
const [confirmIsOpen, setConfirmIsOpen] = useState<boolean>(false);
|
|
50
49
|
const { fields, remove, replace } = useArrayInput(props);
|
|
50
|
+
const theme = useTheme();
|
|
51
51
|
const translate = useTranslate();
|
|
52
52
|
const record = useRecordContext(props);
|
|
53
53
|
const initialDefaultValue = useRef({});
|
|
54
|
+
const translateLabel = useTranslateLabel();
|
|
54
55
|
const removeField = useCallback(
|
|
55
56
|
(index: number) => {
|
|
56
57
|
remove(index);
|
|
@@ -82,7 +83,8 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
|
|
|
82
83
|
[fields.length, removeField, source]
|
|
83
84
|
);
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
const tableBorderColor = theme.palette.mode === 'dark' ? theme.palette.grey.A400 : theme.palette.grey.A800;
|
|
86
88
|
|
|
87
89
|
return fields ? (
|
|
88
90
|
// @ts-ignore
|
|
@@ -100,21 +102,18 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
|
|
|
100
102
|
if (!React.isValidElement<any>(input)) {
|
|
101
103
|
return null;
|
|
102
104
|
}
|
|
103
|
-
const { source, label = '' } = input.props;
|
|
104
105
|
return (
|
|
105
106
|
<TableCell key={index}>
|
|
106
107
|
<Typography display={'flex'} variant="subtitle1" fontWeight={500} color="text.primary" textTransform="none">
|
|
107
|
-
{
|
|
108
|
+
{translateLabel({ ...input.props, resource })}
|
|
108
109
|
</Typography>
|
|
109
110
|
</TableCell>
|
|
110
111
|
);
|
|
111
112
|
})}
|
|
112
113
|
|
|
113
114
|
{!disableActions && (
|
|
114
|
-
<TableCell sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }} key={'actions'}>
|
|
115
|
-
<Typography display={'flex'} variant="subtitle1" fontWeight={500} color="text.primary" textTransform="none"
|
|
116
|
-
<MoreHoriz />
|
|
117
|
-
</Typography>
|
|
115
|
+
<TableCell sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', verticalAlign: 'top' }} key={'actions'}>
|
|
116
|
+
<Typography display={'flex'} variant="subtitle1" fontWeight={500} color="text.primary" textTransform="none" />
|
|
118
117
|
</TableCell>
|
|
119
118
|
)}
|
|
120
119
|
</TableRow>
|
|
@@ -123,10 +122,14 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
|
|
|
123
122
|
<TableBody>
|
|
124
123
|
{fields.length === 0 && (
|
|
125
124
|
<TableRow sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
|
|
126
|
-
<TableCell colSpan={4} align="center">
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
<TableCell colSpan={4 + (disableActions ? 0 : 1)} align="center">
|
|
126
|
+
{empty ? (
|
|
127
|
+
empty
|
|
128
|
+
) : (
|
|
129
|
+
<Typography variant="body1" color="text.secondary">
|
|
130
|
+
-
|
|
131
|
+
</Typography>
|
|
132
|
+
)}
|
|
130
133
|
</TableCell>
|
|
131
134
|
</TableRow>
|
|
132
135
|
)}
|
|
@@ -171,13 +174,17 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
|
|
|
171
174
|
const AddTableRow = (props: any) => {
|
|
172
175
|
const { label, disableAdd } = props;
|
|
173
176
|
const { append } = useArrayInput(props);
|
|
177
|
+
const theme = useTheme();
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
const tableBorderColor = theme.palette.mode === 'dark' ? theme.palette.grey.A400 : theme.palette.grey.A800;
|
|
180
|
+
const iconColor = theme.palette.mode === 'light' ? '#000000' : '#FFFFFF';
|
|
174
181
|
|
|
175
182
|
return (
|
|
176
183
|
<Stack justifyContent={'space-between'} alignItems={'center'} flexDirection={'row'}>
|
|
177
184
|
<Typography>{label}</Typography>
|
|
178
185
|
{!disableAdd && (
|
|
179
|
-
<IconButton size="small" color="secondary" sx={{ border:
|
|
180
|
-
<PlusCircleOutlined style={{ color:
|
|
186
|
+
<IconButton size="small" color="secondary" sx={{ border: `1px solid ${tableBorderColor}` }} onClick={() => append({})}>
|
|
187
|
+
<PlusCircleOutlined style={{ color: iconColor }} />
|
|
181
188
|
</IconButton>
|
|
182
189
|
)}
|
|
183
190
|
</Stack>
|
|
@@ -216,7 +223,8 @@ TableFormIterator.propTypes = {
|
|
|
216
223
|
translate: PropTypes.func,
|
|
217
224
|
disableAdd: PropTypes.bool,
|
|
218
225
|
disableRemove: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
219
|
-
TransitionProps: PropTypes.shape({})
|
|
226
|
+
TransitionProps: PropTypes.shape({}),
|
|
227
|
+
empty: PropTypes.oneOfType([PropTypes.node, PropTypes.string])
|
|
220
228
|
};
|
|
221
229
|
|
|
222
230
|
export interface TableFormIteratorProps extends Partial<UseFieldArrayReturn> {
|
|
@@ -236,6 +244,7 @@ export interface TableFormIteratorProps extends Partial<UseFieldArrayReturn> {
|
|
|
236
244
|
resource?: string;
|
|
237
245
|
source?: string;
|
|
238
246
|
sx?: SxProps;
|
|
247
|
+
empty: ReactNode | string;
|
|
239
248
|
}
|
|
240
249
|
|
|
241
250
|
export default StyledTableFormIterator;
|
|
@@ -40,7 +40,7 @@ export const TableFormIteratorItem = React.forwardRef((props: TableFormIteratorI
|
|
|
40
40
|
}
|
|
41
41
|
const { source, ...inputProps } = input.props;
|
|
42
42
|
return (
|
|
43
|
-
<TableCell sx={{ border: 0 }}>
|
|
43
|
+
<TableCell sx={{ border: 0, verticalAlign: 'top' }}>
|
|
44
44
|
{cloneElement(input, {
|
|
45
45
|
source: source ? `${member}.${source}` : member,
|
|
46
46
|
index: source ? undefined : index2,
|
|
@@ -8,6 +8,10 @@ const StyledAutocompleteArrayInput = styled(RaAutocompleteArrayInput, {
|
|
|
8
8
|
})(({ label }) => ({
|
|
9
9
|
'& legend': {
|
|
10
10
|
width: label === false ? 0 : 'auto'
|
|
11
|
+
},
|
|
12
|
+
'& .MuiAutocomplete-inputRoot': {
|
|
13
|
+
// Serve ad allineare l'altezza di un input di tipo Autocomplete a quella degli altri campi utilizzati.
|
|
14
|
+
padding: `0px 9px`
|
|
11
15
|
}
|
|
12
16
|
}));
|
|
13
17
|
|
|
@@ -8,6 +8,13 @@ const StyledAutocompleteInput = styled(RaAutocompleteInput, {
|
|
|
8
8
|
})(({ label }) => ({
|
|
9
9
|
'& legend': {
|
|
10
10
|
width: label === false ? 0 : 'auto'
|
|
11
|
+
},
|
|
12
|
+
'& .MuiAutocomplete-inputRoot': {
|
|
13
|
+
// Serve ad allineare l'altezza di un input di tipo Autocomplete a quella degli altri campi utilizzati.
|
|
14
|
+
padding: `0px 9px`
|
|
15
|
+
},
|
|
16
|
+
'& .MuiOutlinedInput-root.MuiInputBase-sizeSmall': {
|
|
17
|
+
paddingTop: '4px'
|
|
11
18
|
}
|
|
12
19
|
}));
|
|
13
20
|
|
|
@@ -9,10 +9,9 @@ const ApplicaStyledSelectArrayInput = styled(RaSelectArrayInput, {
|
|
|
9
9
|
'& legend': {
|
|
10
10
|
width: label === false ? 0 : 'auto'
|
|
11
11
|
},
|
|
12
|
-
'& .RaSelectArrayInput-chips': {
|
|
13
|
-
'
|
|
14
|
-
|
|
15
|
-
}
|
|
12
|
+
'& .RaSelectArrayInput-chips > .RaSelectArrayInput-chip': {
|
|
13
|
+
marginTop: '-2px',
|
|
14
|
+
marginBottom: '-2px'
|
|
16
15
|
}
|
|
17
16
|
}));
|
|
18
17
|
|
|
@@ -9,6 +9,7 @@ const ApplicaStyledList = styled(RaList, {
|
|
|
9
9
|
})(({ theme }) => ({
|
|
10
10
|
'& .RaList-main': {
|
|
11
11
|
overflowX: 'auto',
|
|
12
|
+
|
|
12
13
|
'& .RaBulkActionsToolbar-toolbar': {
|
|
13
14
|
// La barra delle operazioni massive di react-admin non è perfettamente
|
|
14
15
|
// compatibile con il tema mantis, peratnto ho dovuto apportare una serie
|
|
@@ -37,16 +38,23 @@ const ApplicaStyledList = styled(RaList, {
|
|
|
37
38
|
|
|
38
39
|
'& .RaList-actions': {
|
|
39
40
|
padding: theme.spacing(2),
|
|
40
|
-
paddingTop:
|
|
41
|
+
paddingTop: theme.spacing(1),
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
'& form': {
|
|
44
|
+
alignItems: 'center'
|
|
45
|
+
},
|
|
41
46
|
'& .RaFilterForm-filterFormInput': {
|
|
42
|
-
|
|
47
|
+
'& .MuiFormControl-root': {
|
|
48
|
+
marginTop: 0
|
|
49
|
+
},
|
|
43
50
|
'& .ra-input': {
|
|
44
|
-
alignSelf: 'center'
|
|
51
|
+
alignSelf: 'center',
|
|
52
|
+
marginTop: 0
|
|
45
53
|
},
|
|
46
54
|
[theme.breakpoints.down('sm')]: {
|
|
47
55
|
// Quando lo schermo è piccolo, il filtro viene visualizzato in una colonna.
|
|
48
56
|
// Diamo un margine maggiore in basso per evitare che siano troppo vicini.
|
|
49
|
-
marginBottom: theme.spacing(1)
|
|
57
|
+
marginBottom: theme.spacing(1.5)
|
|
50
58
|
}
|
|
51
59
|
},
|
|
52
60
|
'& .RaFilterFormInput-hideButton': {
|
|
@@ -56,7 +64,9 @@ const ApplicaStyledList = styled(RaList, {
|
|
|
56
64
|
},
|
|
57
65
|
'& > .MuiToolbar-root': {
|
|
58
66
|
flex: 'unset',
|
|
59
|
-
padding: 0
|
|
67
|
+
padding: 0,
|
|
68
|
+
alignSelf: 'flex-end',
|
|
69
|
+
minHeight: 'fit-content'
|
|
60
70
|
}
|
|
61
71
|
},
|
|
62
72
|
|
package/src/hooks/useMenu.jsx
CHANGED
|
@@ -154,7 +154,8 @@ const createNodes = ({ userGroups, resources, permissions, translate, roles }) =
|
|
|
154
154
|
const resourceExists = resourceGroup?.children?.some((c) => c.id === resource.name);
|
|
155
155
|
const resourceRoles = resourceMenu?.roles || resource.options?.roles || [];
|
|
156
156
|
const hasRoles = !resourceRoles || resourceRoles.length === 0 || resourceRoles.some((role) => roles.includes(role));
|
|
157
|
-
|
|
157
|
+
const hasPerms = hasPermission(resource, permissions);
|
|
158
|
+
if (!hasPerms || !resource.hasList || !hasRoles) {
|
|
158
159
|
if (resourceExists && resourceGroup?.children?.length > 0) {
|
|
159
160
|
resourceGroup.children = resourceGroup.children.filter((c) => c.id !== resource.name);
|
|
160
161
|
}
|
|
@@ -34,10 +34,10 @@ const UserForm = ({ configuredRoles }) => {
|
|
|
34
34
|
</Grid>
|
|
35
35
|
<Grid item lg={12} xs={12}>
|
|
36
36
|
<ArrayInput source="items" label={false}>
|
|
37
|
-
<TableFormIterator label="
|
|
38
|
-
<TextInput source="name" label="
|
|
39
|
-
<TextInput source="surname" label="
|
|
40
|
-
<SelectArrayInput source="roles" choices={configuredRoles} />
|
|
37
|
+
<TableFormIterator label="Informazioni utente">
|
|
38
|
+
<TextInput source="name" label="Name" sx={{ minWidth: 200 }} />
|
|
39
|
+
<TextInput source="surname" label="Surname" sx={{ minWidth: 150 }} />
|
|
40
|
+
<SelectArrayInput source="roles" label="Ruoli" choices={configuredRoles} />
|
|
41
41
|
</TableFormIterator>
|
|
42
42
|
</ArrayInput>
|
|
43
43
|
</Grid>
|