@applica-software-guru/react-admin 1.1.91 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applica-software-guru/react-admin",
3
- "version": "1.1.91",
3
+ "version": "1.1.92",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -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, useTheme } from '@mui/material/styles';
28
27
 
29
28
  /**
30
29
  *
@@ -45,13 +44,14 @@ import { styled, useTheme } 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);
51
- const theme = useTheme()
50
+ const theme = useTheme();
52
51
  const translate = useTranslate();
53
52
  const record = useRecordContext(props);
54
53
  const initialDefaultValue = useRef({});
54
+ const translateLabel = useTranslateLabel();
55
55
  const removeField = useCallback(
56
56
  (index: number) => {
57
57
  remove(index);
@@ -83,6 +83,7 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
83
83
  [fields.length, removeField, source]
84
84
  );
85
85
 
86
+ // @ts-ignore
86
87
  const tableBorderColor = theme.palette.mode === 'dark' ? theme.palette.grey.A400 : theme.palette.grey.A800;
87
88
 
88
89
  return fields ? (
@@ -101,21 +102,18 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
101
102
  if (!React.isValidElement<any>(input)) {
102
103
  return null;
103
104
  }
104
- const { source, label = '' } = input.props;
105
105
  return (
106
106
  <TableCell key={index}>
107
107
  <Typography display={'flex'} variant="subtitle1" fontWeight={500} color="text.primary" textTransform="none">
108
- {label || source}
108
+ {translateLabel({ ...input.props, resource })}
109
109
  </Typography>
110
110
  </TableCell>
111
111
  );
112
112
  })}
113
113
 
114
114
  {!disableActions && (
115
- <TableCell sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }} key={'actions'}>
116
- <Typography display={'flex'} variant="subtitle1" fontWeight={500} color="text.primary" textTransform="none">
117
- <MoreHoriz />
118
- </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" />
119
117
  </TableCell>
120
118
  )}
121
119
  </TableRow>
@@ -124,10 +122,14 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
124
122
  <TableBody>
125
123
  {fields.length === 0 && (
126
124
  <TableRow sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
127
- <TableCell colSpan={4} align="center">
128
- <Typography variant="body1" color="text.secondary">
129
- -
130
- </Typography>
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
+ )}
131
133
  </TableCell>
132
134
  </TableRow>
133
135
  )}
@@ -173,6 +175,7 @@ const AddTableRow = (props: any) => {
173
175
  const { label, disableAdd } = props;
174
176
  const { append } = useArrayInput(props);
175
177
  const theme = useTheme();
178
+ // @ts-ignore
176
179
  const tableBorderColor = theme.palette.mode === 'dark' ? theme.palette.grey.A400 : theme.palette.grey.A800;
177
180
  const iconColor = theme.palette.mode === 'light' ? '#000000' : '#FFFFFF';
178
181
 
@@ -220,7 +223,8 @@ TableFormIterator.propTypes = {
220
223
  translate: PropTypes.func,
221
224
  disableAdd: PropTypes.bool,
222
225
  disableRemove: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
223
- TransitionProps: PropTypes.shape({})
226
+ TransitionProps: PropTypes.shape({}),
227
+ empty: PropTypes.oneOfType([PropTypes.node, PropTypes.string])
224
228
  };
225
229
 
226
230
  export interface TableFormIteratorProps extends Partial<UseFieldArrayReturn> {
@@ -240,6 +244,7 @@ export interface TableFormIteratorProps extends Partial<UseFieldArrayReturn> {
240
244
  resource?: string;
241
245
  source?: string;
242
246
  sx?: SxProps;
247
+ empty: ReactNode | string;
243
248
  }
244
249
 
245
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
- '& .RaSelectArrayInput-chip': {
14
- marginTop: 0
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: 0,
41
+ paddingTop: theme.spacing(1),
42
+ alignItems: 'center',
43
+ '& form': {
44
+ alignItems: 'center'
45
+ },
41
46
  '& .RaFilterForm-filterFormInput': {
42
- marginTop: theme.spacing(1),
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
 
@@ -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
- if (!hasPermission(resource, permissions) || !resource.hasList || !hasRoles) {
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
  }