@applica-software-guru/react-admin 1.0.32 → 1.0.34
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/.eslintrc.json +43 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.prettierrc +8 -0
- package/bitbucket-pipelines.yml +30 -0
- package/dist/Admin.d.ts +1 -1
- package/dist/ApplicaAdmin.d.ts +3 -3
- package/dist/ApplicaAdmin.d.ts.map +1 -1
- package/dist/components/@extended/AnimateButton.d.ts +5 -5
- package/dist/components/@extended/Avatar.d.ts +3 -3
- package/dist/components/@extended/Breadcrumbs.d.ts +5 -5
- package/dist/components/@extended/Dot.d.ts +1 -1
- package/dist/components/@extended/Tooltip.d.ts +1 -1
- package/dist/components/ActionsMenu.d.ts +1 -1
- package/dist/components/ActionsMenu.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.d.ts +1 -1
- package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.d.ts +5 -5
- package/dist/components/Layout/Header/AppBarStyled.d.ts +13 -13
- package/dist/components/Layout/Header/HeaderContent/NotificationItem.d.ts +3 -3
- package/dist/components/Logo.d.ts +2 -2
- package/dist/components/MenuPopover/MenuPopover.d.ts +1 -1
- package/dist/components/Notification.d.ts +5 -1
- package/dist/components/Notification.d.ts.map +1 -1
- package/dist/components/ra-buttons/CreateInDialogButton.d.ts +16 -1
- package/dist/components/ra-buttons/CreateInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-buttons/ImpersonateUserButton.d.ts +1 -1
- package/dist/components/ra-fields/ActionsField.d.ts +1 -1
- package/dist/components/ra-fields/ActionsField.d.ts.map +1 -1
- package/dist/components/ra-fields/AttachmentField.d.ts +19 -1
- package/dist/components/ra-fields/AttachmentField.d.ts.map +1 -1
- package/dist/components/ra-fields/BaseAttachmentField.d.ts +2 -2
- package/dist/components/ra-fields/CoverField.d.ts +19 -1
- package/dist/components/ra-fields/CoverField.d.ts.map +1 -1
- package/dist/components/ra-fields/EmailField.d.ts +12 -1
- package/dist/components/ra-fields/FileField.d.ts +19 -1
- package/dist/components/ra-fields/FileField.d.ts.map +1 -1
- package/dist/components/ra-fields/ImageField.d.ts +15 -1
- package/dist/components/ra-fields/ImageField.d.ts.map +1 -1
- package/dist/components/ra-fields/ReadonlyField.d.ts +1 -1
- package/dist/components/ra-fields/ReferenceManyField.d.ts +32 -2
- package/dist/components/ra-fields/ReferenceManyField.d.ts.map +1 -1
- package/dist/components/ra-forms/Edit.d.ts +24 -1
- package/dist/components/ra-forms/Edit.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/LongFormHeader.d.ts +1 -1
- package/dist/components/ra-forms/LongForm/LongFormHeader.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/LongFormTab.d.ts +4 -4
- package/dist/components/ra-forms/LongForm/LongFormTab.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/LongFormTabs.d.ts +2 -2
- package/dist/components/ra-forms/SimpleForm.d.ts +13 -1
- package/dist/components/ra-forms/SimpleForm.d.ts.map +1 -1
- package/dist/components/ra-forms/TabbedForm.d.ts +9 -1
- package/dist/components/ra-forms/TabbedForm.d.ts.map +1 -1
- package/dist/components/ra-forms/Toolbar.d.ts +5 -1
- package/dist/components/ra-inputs/AttachmentInput.d.ts +20 -1
- package/dist/components/ra-inputs/AttachmentInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/AutocompleteArrayInput.d.ts +1 -2
- package/dist/components/ra-inputs/AutocompleteArrayInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/AutocompleteInput.d.ts +1 -2
- package/dist/components/ra-inputs/AutocompleteInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/BooleanInput.d.ts +19 -2
- package/dist/components/ra-inputs/BooleanInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/DateInput.d.ts +11 -1
- package/dist/components/ra-inputs/FileInput.d.ts +21 -1
- package/dist/components/ra-inputs/FileInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/LabeledInput.d.ts +2 -2
- package/dist/components/ra-inputs/NumberInput.d.ts +19 -2
- package/dist/components/ra-inputs/RecordInput.d.ts +1 -1
- package/dist/components/ra-inputs/ReferenceArrayInput.d.ts +25 -2
- package/dist/components/ra-inputs/ReferenceArrayInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/ReferenceInput.d.ts +26 -2
- package/dist/components/ra-inputs/ReferenceInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/ReferenceManyInput.d.ts +34 -2
- package/dist/components/ra-inputs/ReferenceManyInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/SelectArrayInput.d.ts +18 -1
- package/dist/components/ra-inputs/SelectInput.d.ts +21 -1
- package/dist/components/ra-inputs/SmartTextInput.d.ts +17 -1
- package/dist/components/ra-inputs/SmartTextInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/TextInput.d.ts +16 -2
- package/dist/components/ra-inputs/TimeInput.d.ts +11 -1
- package/dist/components/ra-lists/Datagrid.d.ts +616 -2
- package/dist/components/ra-lists/List.d.ts +28 -2
- package/dist/contexts/AppConfigContext.d.ts +1 -1
- package/dist/contexts/MenuConfigContext.d.ts +4 -4
- package/dist/dev/useCliErrorCatcher.d.ts +5 -5
- package/dist/hooks/useAppConfig.d.ts +1 -1
- package/dist/hooks/useBreadcrumbs.d.ts +2 -2
- package/dist/hooks/useMenu.d.ts +2 -2
- package/dist/hooks/useMenu.d.ts.map +1 -1
- package/dist/hooks/useMenuConfig.d.ts +2 -2
- package/dist/i18n/createI18nProvider.d.ts +1 -1
- package/dist/i18n/useI18nCatcher.d.ts +4 -4
- package/dist/i18n/useI18nLanguages.d.ts +4 -4
- package/dist/i18n/useI18nProvider.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/react-admin.cjs.js +25 -25
- package/dist/react-admin.es.js +304 -315
- package/dist/react-admin.umd.js +25 -25
- package/dist/themes/overrides/PaginationItem.d.ts +72 -72
- package/jsconfig.json +31 -0
- package/jsconfig.node.json +10 -0
- package/package.json +6 -5
- package/playground/config-overrides.js +31 -0
- package/playground/jsconfig.json +9 -0
- package/playground/package-lock.json +17764 -0
- package/playground/package.json +69 -0
- package/playground/public/favicon-dark.png +0 -0
- package/playground/public/favicon-light.png +0 -0
- package/playground/public/index.html +46 -0
- package/playground/src/App.js +49 -0
- package/playground/src/build.json +1 -0
- package/playground/src/components/index.js +5 -0
- package/playground/src/components/pages/CustomPage.jsx +7 -0
- package/playground/src/components/pages/index.jsx +2 -0
- package/playground/src/components/ra-buttons/index.js +1 -0
- package/playground/src/components/ra-fields/UserPictureField.js +20 -0
- package/playground/src/components/ra-fields/index.js +2 -0
- package/playground/src/components/ra-forms/DeviceForm.js +36 -0
- package/playground/src/components/ra-forms/I18nMessageForm.js +24 -0
- package/playground/src/components/ra-forms/UserForm.js +51 -0
- package/playground/src/components/ra-forms/index.js +5 -0
- package/playground/src/components/ra-inputs/LangSelectInput.js +4 -0
- package/playground/src/components/ra-inputs/YesOrNoSelectInput.js +14 -0
- package/playground/src/components/ra-inputs/index.js +3 -0
- package/playground/src/components/ra-lists/DeviceList.js +33 -0
- package/playground/src/components/ra-lists/I18nMessageList.js +20 -0
- package/playground/src/components/ra-lists/UserList.js +96 -0
- package/playground/src/components/ra-lists/index.js +4 -0
- package/playground/src/config.js +19 -0
- package/playground/src/contexts/index.js +1 -0
- package/playground/src/hooks/index.js +1 -0
- package/playground/src/index.js +10 -0
- package/playground/src/menu.js +72 -0
- package/playground/src/react-app-env.d.js +1 -0
- package/playground/src/reportWebVitals.js +13 -0
- package/playground/src/resource/device.js +23 -0
- package/playground/src/resource/i18n-message.js +29 -0
- package/playground/src/resource/index.js +4 -0
- package/playground/src/resource/notification.js +18 -0
- package/playground/src/resource/user.js +28 -0
- package/playground/src/theme.js +3 -0
- package/src/Admin.jsx +67 -0
- package/src/AdminContext.jsx +26 -0
- package/src/ApplicaAdmin.jsx +210 -0
- package/src/assets/README.md +7 -0
- package/src/assets/logo-icon.png +0 -0
- package/src/assets/logo-main.png +0 -0
- package/src/components/@extended/AnimateButton.jsx +96 -0
- package/src/components/@extended/Avatar.jsx +125 -0
- package/src/components/@extended/Breadcrumbs.jsx +324 -0
- package/src/components/@extended/Dot.jsx +35 -0
- package/src/components/@extended/IconButton.jsx +166 -0
- package/src/components/@extended/LoadingButton.jsx +228 -0
- package/src/components/@extended/Tooltip.jsx +67 -0
- package/src/components/@extended/Transitions.jsx +125 -0
- package/src/components/@extended/index.jsx +11 -0
- package/src/components/@extended/progress/CircularWithLabel.jsx +34 -0
- package/src/components/@extended/progress/CircularWithPath.jsx +74 -0
- package/src/components/@extended/progress/LinearWithIcon.jsx +22 -0
- package/src/components/@extended/progress/LinearWithLabel.jsx +23 -0
- package/src/components/@extended/progress/index.jsx +6 -0
- package/src/components/ActionsMenu.jsx +77 -0
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavCollapse.jsx +440 -0
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.jsx +359 -0
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavItem.jsx +259 -0
- package/src/components/Layout/Drawer/DrawerContent/Navigation/index.jsx +73 -0
- package/src/components/Layout/Drawer/DrawerContent/index.jsx +19 -0
- package/src/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.jsx +20 -0
- package/src/components/Layout/Drawer/DrawerHeader/index.jsx +44 -0
- package/src/components/Layout/Drawer/HorizontalBar.jsx +55 -0
- package/src/components/Layout/Drawer/MiniDrawerStyled.jsx +47 -0
- package/src/components/Layout/Drawer/index.jsx +63 -0
- package/src/components/Layout/Footer.jsx +23 -0
- package/src/components/Layout/Header/AppBarStyled.jsx +34 -0
- package/src/components/Layout/Header/HeaderContent/MobileSection.jsx +91 -0
- package/src/components/Layout/Header/HeaderContent/Notification.jsx +179 -0
- package/src/components/Layout/Header/HeaderContent/NotificationItem.jsx +109 -0
- package/src/components/Layout/Header/HeaderContent/Profile.jsx +181 -0
- package/src/components/Layout/Header/HeaderContent/index.jsx +38 -0
- package/src/components/Layout/Header/index.jsx +99 -0
- package/src/components/Layout/index.jsx +119 -0
- package/src/components/Loadable.jsx +11 -0
- package/src/components/Loader.jsx +21 -0
- package/src/components/Logo.jsx +29 -0
- package/src/components/MainCard.jsx +111 -0
- package/src/components/MainIcon.jsx +20 -0
- package/src/components/MenuPopover/MenuPopover.jsx +61 -0
- package/src/components/MenuPopover/getPosition.jsx +98 -0
- package/src/components/MenuPopover/index.jsx +3 -0
- package/src/components/MenuPopover/styles.jsx +87 -0
- package/src/components/Notification.jsx +13 -0
- package/src/components/ScrollTop.jsx +24 -0
- package/src/components/ScrollX.jsx +10 -0
- package/src/components/SmallIcon.jsx +14 -0
- package/src/components/index.jsx +36 -0
- package/src/components/ra-buttons/CreateInDialogButton.jsx +203 -0
- package/src/components/ra-buttons/EditInDialogButton.jsx +108 -0
- package/src/components/ra-buttons/ImpersonateUserButton.jsx +41 -0
- package/src/components/ra-buttons/index.jsx +4 -0
- package/src/components/ra-fields/ActionsField.jsx +33 -0
- package/src/components/ra-fields/AttachmentField.jsx +82 -0
- package/src/components/ra-fields/BaseAttachmentField.jsx +72 -0
- package/src/components/ra-fields/CoverField.jsx +83 -0
- package/src/components/ra-fields/DateAgoField.jsx +35 -0
- package/src/components/ra-fields/DateField.jsx +27 -0
- package/src/components/ra-fields/EmailField.jsx +27 -0
- package/src/components/ra-fields/FileField.jsx +40 -0
- package/src/components/ra-fields/FunctionField.jsx +9 -0
- package/src/components/ra-fields/ImageField.jsx +20 -0
- package/src/components/ra-fields/ReadonlyField.jsx +107 -0
- package/src/components/ra-fields/ReferenceManyField.jsx +63 -0
- package/src/components/ra-fields/SizeField.jsx +32 -0
- package/src/components/ra-fields/TextField.jsx +27 -0
- package/src/components/ra-fields/index.jsx +28 -0
- package/src/components/ra-forms/CardForm.jsx +113 -0
- package/src/components/ra-forms/Edit.jsx +13 -0
- package/src/components/ra-forms/FormHeader.jsx +42 -0
- package/src/components/ra-forms/LongForm/DispositionProps.jsx +10 -0
- package/src/components/ra-forms/LongForm/LongForm.jsx +38 -0
- package/src/components/ra-forms/LongForm/LongFormHeader.jsx +24 -0
- package/src/components/ra-forms/LongForm/LongFormTab.jsx +121 -0
- package/src/components/ra-forms/LongForm/LongFormTabs.jsx +63 -0
- package/src/components/ra-forms/LongForm/LongFormView.jsx +129 -0
- package/src/components/ra-forms/LongForm/index.jsx +2 -0
- package/src/components/ra-forms/LongForm/useFormRootPath.jsx +22 -0
- package/src/components/ra-forms/SimpleForm.jsx +69 -0
- package/src/components/ra-forms/TabbedForm.jsx +19 -0
- package/src/components/ra-forms/Toolbar.jsx +36 -0
- package/src/components/ra-forms/index.jsx +8 -0
- package/src/components/ra-inputs/ArrayInput.jsx +29 -0
- package/src/components/ra-inputs/AttachmentInput.jsx +57 -0
- package/src/components/ra-inputs/AutocompleteArrayInput.jsx +25 -0
- package/src/components/ra-inputs/AutocompleteInput.jsx +24 -0
- package/src/components/ra-inputs/BooleanInput.jsx +54 -0
- package/src/components/ra-inputs/DateInput.jsx +30 -0
- package/src/components/ra-inputs/FileInput.jsx +98 -0
- package/src/components/ra-inputs/ImageInput.jsx +44 -0
- package/src/components/ra-inputs/LabeledInput.jsx +80 -0
- package/src/components/ra-inputs/NumberInput.jsx +28 -0
- package/src/components/ra-inputs/RecordInput.jsx +102 -0
- package/src/components/ra-inputs/ReferenceArrayInput.jsx +23 -0
- package/src/components/ra-inputs/ReferenceInput.jsx +23 -0
- package/src/components/ra-inputs/ReferenceManyInput.jsx +44 -0
- package/src/components/ra-inputs/SearchInput.jsx +14 -0
- package/src/components/ra-inputs/SelectArrayInput.jsx +45 -0
- package/src/components/ra-inputs/SelectInput.jsx +24 -0
- package/src/components/ra-inputs/SmartTextInput.jsx +52 -0
- package/src/components/ra-inputs/TextInput.jsx +20 -0
- package/src/components/ra-inputs/TimeInput.jsx +46 -0
- package/src/components/ra-inputs/index.jsx +42 -0
- package/src/components/ra-lists/Datagrid.jsx +42 -0
- package/src/components/ra-lists/Empty.jsx +94 -0
- package/src/components/ra-lists/List.jsx +81 -0
- package/src/components/ra-lists/NotificationList/NotificationList.jsx +41 -0
- package/src/components/ra-lists/NotificationList/button/MarkAsReadedButton.jsx +57 -0
- package/src/components/ra-lists/NotificationList/button/MarkAsUnreadedButton.jsx +56 -0
- package/src/components/ra-lists/NotificationList/button/index.jsx +2 -0
- package/src/components/ra-lists/NotificationList/field/NotificationField.jsx +80 -0
- package/src/components/ra-lists/NotificationList/field/index.jsx +1 -0
- package/src/components/ra-lists/NotificationList/index.jsx +2 -0
- package/src/components/ra-lists/index.jsx +5 -0
- package/src/components/third-party/SimpleBar.jsx +61 -0
- package/src/components/third-party/index.jsx +3 -0
- package/src/contexts/AppConfigContext.jsx +54 -0
- package/src/contexts/MenuConfigContext.jsx +93 -0
- package/src/contexts/MenuPropTypes.jsx +19 -0
- package/src/contexts/ThemeConfigContext.jsx +138 -0
- package/src/contexts/index.jsx +5 -0
- package/src/dev/index.jsx +2 -0
- package/src/dev/useCliErrorCatcher.jsx +86 -0
- package/src/hooks/index.jsx +16 -0
- package/src/hooks/useAppConfig.jsx +6 -0
- package/src/hooks/useBreadcrumbs.jsx +68 -0
- package/src/hooks/useLocalStorage.jsx +31 -0
- package/src/hooks/useMenu.jsx +223 -0
- package/src/hooks/useMenuConfig.jsx +6 -0
- package/src/hooks/useResourceTitle.jsx +25 -0
- package/src/hooks/useThemeConfig.jsx +6 -0
- package/src/i18n/createI18nProvider.jsx +15 -0
- package/src/i18n/index.jsx +4 -0
- package/src/i18n/useI18nCatcher.jsx +71 -0
- package/src/i18n/useI18nLanguages.jsx +22 -0
- package/src/i18n/useI18nProvider.jsx +5 -0
- package/src/index.jsx +67 -0
- package/src/themes/getColors.jsx +18 -0
- package/src/themes/getShadow.jsx +37 -0
- package/src/themes/index.jsx +70 -0
- package/src/themes/overrides/Accordion.jsx +27 -0
- package/src/themes/overrides/AccordionDetails.jsx +14 -0
- package/src/themes/overrides/AccordionSummary.jsx +33 -0
- package/src/themes/overrides/Alert.jsx +72 -0
- package/src/themes/overrides/AlertTitle.jsx +15 -0
- package/src/themes/overrides/Autocomplete.jsx +23 -0
- package/src/themes/overrides/Badge.jsx +36 -0
- package/src/themes/overrides/Button.jsx +229 -0
- package/src/themes/overrides/ButtonBase.jsx +12 -0
- package/src/themes/overrides/ButtonGroup.jsx +11 -0
- package/src/themes/overrides/CardContent.jsx +16 -0
- package/src/themes/overrides/Checkbox.jsx +125 -0
- package/src/themes/overrides/Chip.jsx +75 -0
- package/src/themes/overrides/Dialog.jsx +18 -0
- package/src/themes/overrides/DialogContentText.jsx +14 -0
- package/src/themes/overrides/DialogTitle.jsx +14 -0
- package/src/themes/overrides/Fab.jsx +77 -0
- package/src/themes/overrides/IconButton.jsx +28 -0
- package/src/themes/overrides/InputBase.jsx +13 -0
- package/src/themes/overrides/InputLabel.jsx +25 -0
- package/src/themes/overrides/LinearProgress.jsx +17 -0
- package/src/themes/overrides/Link.jsx +11 -0
- package/src/themes/overrides/ListItemButton.jsx +18 -0
- package/src/themes/overrides/ListItemIcon.jsx +14 -0
- package/src/themes/overrides/LoadingButton.jsx +17 -0
- package/src/themes/overrides/OutlinedInput.jsx +54 -0
- package/src/themes/overrides/Pagination.jsx +11 -0
- package/src/themes/overrides/PaginationItem.jsx +211 -0
- package/src/themes/overrides/Popover.jsx +13 -0
- package/src/themes/overrides/Radio.jsx +121 -0
- package/src/themes/overrides/Slider.jsx +66 -0
- package/src/themes/overrides/Switch.jsx +88 -0
- package/src/themes/overrides/Tab.jsx +24 -0
- package/src/themes/overrides/TableBody.jsx +27 -0
- package/src/themes/overrides/TableCell.jsx +44 -0
- package/src/themes/overrides/TableFooter.jsx +15 -0
- package/src/themes/overrides/TableHead.jsx +15 -0
- package/src/themes/overrides/TablePagination.jsx +16 -0
- package/src/themes/overrides/TableRow.jsx +25 -0
- package/src/themes/overrides/Tabs.jsx +13 -0
- package/src/themes/overrides/ToggleButton.jsx +20 -0
- package/src/themes/overrides/Tooltip.jsx +13 -0
- package/src/themes/overrides/TreeItem.jsx +18 -0
- package/src/themes/overrides/Typography.jsx +13 -0
- package/src/themes/overrides/index.jsx +98 -0
- package/src/themes/palette.jsx +78 -0
- package/src/themes/shadows.jsx +27 -0
- package/src/themes/theme/default.jsx +98 -0
- package/src/themes/theme/index.jsx +44 -0
- package/src/themes/theme/theme1.jsx +128 -0
- package/src/themes/theme/theme2.jsx +128 -0
- package/src/themes/theme/theme3.jsx +128 -0
- package/src/themes/theme/theme4.jsx +128 -0
- package/src/themes/theme/theme5.jsx +128 -0
- package/src/themes/theme/theme6.jsx +128 -0
- package/src/themes/theme/theme7.jsx +128 -0
- package/src/themes/theme/theme8.jsx +128 -0
- package/src/themes/typography.jsx +71 -0
- package/src/utils/index.js +2 -0
- package/src/utils/lang.js +12 -0
- package/src/utils/time.js +13 -0
- package/tsconfig.json +28 -0
- package/vite.config.js +74 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ListToolbar, Pagination, ResourceContextProvider } from 'react-admin'
|
|
2
|
+
|
|
3
|
+
import { Fragment } from 'react'
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
import { ReferenceManyField } from '../ra-fields'
|
|
6
|
+
|
|
7
|
+
const ReferenceManyInput = ({ reference, target, children, filters, actions, ...props }) => {
|
|
8
|
+
return (
|
|
9
|
+
<ResourceContextProvider value={reference}>
|
|
10
|
+
<ReferenceManyField
|
|
11
|
+
perPage={5}
|
|
12
|
+
pagination={<Pagination />}
|
|
13
|
+
{...props}
|
|
14
|
+
reference={reference}
|
|
15
|
+
target={target}
|
|
16
|
+
>
|
|
17
|
+
<Fragment>
|
|
18
|
+
<ListToolbar filters={filters} actions={actions} />
|
|
19
|
+
{children}
|
|
20
|
+
</Fragment>
|
|
21
|
+
</ReferenceManyField>
|
|
22
|
+
</ResourceContextProvider>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
ReferenceManyInput.propTypes = {
|
|
27
|
+
...ReferenceManyField.propTypes,
|
|
28
|
+
children: PropTypes.node.isRequired,
|
|
29
|
+
reference: PropTypes.string.isRequired,
|
|
30
|
+
target: PropTypes.string.isRequired,
|
|
31
|
+
filters: PropTypes.oneOfType([
|
|
32
|
+
PropTypes.element,
|
|
33
|
+
PropTypes.func,
|
|
34
|
+
PropTypes.element,
|
|
35
|
+
PropTypes.arrayOf(PropTypes.node),
|
|
36
|
+
]),
|
|
37
|
+
actions: PropTypes.oneOfType([PropTypes.element, PropTypes.func, PropTypes.element]),
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ReferenceManyInput.defaultProps = {
|
|
41
|
+
...ReferenceManyField.defaultProps,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default ReferenceManyInput
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SearchInput as RaSearchInput } from 'react-admin'
|
|
2
|
+
import { styled } from '@mui/material/styles'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @return {React.Component}
|
|
6
|
+
*/
|
|
7
|
+
const ApplicaStyledSearchInput = styled(RaSearchInput, {
|
|
8
|
+
name: 'RaApplicaSearchInput',
|
|
9
|
+
slot: 'root',
|
|
10
|
+
})(() => ({}))
|
|
11
|
+
|
|
12
|
+
const SearchInput = (props) => <ApplicaStyledSearchInput {...props} />
|
|
13
|
+
|
|
14
|
+
export default SearchInput
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import LabeledInput from './LabeledInput'
|
|
2
|
+
import { SelectArrayInput as RaSelectArrayInput } from 'react-admin'
|
|
3
|
+
import { styled } from '@mui/material/styles'
|
|
4
|
+
|
|
5
|
+
const ApplicaStyledSelectArrayInput = styled(RaSelectArrayInput, {
|
|
6
|
+
name: 'RaApplicaSelectArrayInput',
|
|
7
|
+
slot: 'Root',
|
|
8
|
+
})(({ label }) => ({
|
|
9
|
+
'& legend': {
|
|
10
|
+
width: label === false ? 0 : 'auto',
|
|
11
|
+
},
|
|
12
|
+
'& .RaSelectArrayInput-chips': {
|
|
13
|
+
'& .RaSelectArrayInput-chip': {
|
|
14
|
+
marginTop: 0,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}))
|
|
18
|
+
|
|
19
|
+
ApplicaStyledSelectArrayInput.propTypes = {
|
|
20
|
+
...RaSelectArrayInput.propTypes,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const SelectArrayInput = (props) => {
|
|
24
|
+
return (
|
|
25
|
+
<LabeledInput {...props}>
|
|
26
|
+
<ApplicaStyledSelectArrayInput
|
|
27
|
+
options={{
|
|
28
|
+
autoWidth: false,
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
</LabeledInput>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
SelectArrayInput.defaultProps = {
|
|
36
|
+
optionText: 'name',
|
|
37
|
+
optionValue: 'id',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
SelectArrayInput.propTypes = {
|
|
41
|
+
...RaSelectArrayInput.propTypes,
|
|
42
|
+
...LabeledInput.propTypes,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default SelectArrayInput
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import LabeledInput from './LabeledInput'
|
|
2
|
+
import { SelectInput as RaSelectInput } from 'react-admin'
|
|
3
|
+
import { styled } from '@mui/material/styles'
|
|
4
|
+
|
|
5
|
+
const ApplicaStyledSelectInput = styled(RaSelectInput, {
|
|
6
|
+
name: 'RaApplicaSelectArrayInput',
|
|
7
|
+
slot: 'Root',
|
|
8
|
+
})(({ label }) => ({
|
|
9
|
+
'& legend': {
|
|
10
|
+
width: label === false ? 0 : 'auto',
|
|
11
|
+
},
|
|
12
|
+
}))
|
|
13
|
+
const SelectInput = (props) => (
|
|
14
|
+
<LabeledInput {...props}>
|
|
15
|
+
<ApplicaStyledSelectInput />
|
|
16
|
+
</LabeledInput>
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
SelectInput.propTypes = {
|
|
20
|
+
...RaSelectInput.propTypes,
|
|
21
|
+
...LabeledInput.propTypes,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default SelectInput
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { maxLength as maxLengthValidator, useTranslate } from 'react-admin'
|
|
2
|
+
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import TextInput from './TextInput'
|
|
6
|
+
import { useController } from 'react-hook-form'
|
|
7
|
+
|
|
8
|
+
const SmartTextInput = ({ ...props }) => {
|
|
9
|
+
const translate = useTranslate()
|
|
10
|
+
const validationFn = maxLengthValidator(props?.maxLength, 'app.input.max_length_error')
|
|
11
|
+
const value = useController({ name: props?.source })?.field?.value
|
|
12
|
+
|
|
13
|
+
let helperText = props.helperText
|
|
14
|
+
let validate = props.validate
|
|
15
|
+
|
|
16
|
+
if (!validate) {
|
|
17
|
+
validate = [validationFn]
|
|
18
|
+
} else if (Array.isArray(validate)) {
|
|
19
|
+
if (validate.indexOf(validationFn) === -1) {
|
|
20
|
+
validate.push(validationFn)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const usedCharsInfo = translate('app.input.max_length_info', {
|
|
25
|
+
count: value?.length || 0,
|
|
26
|
+
max: props?.maxLength,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
if (props?.maxLength) {
|
|
30
|
+
helperText =
|
|
31
|
+
helperText && helperText.length > 0
|
|
32
|
+
? `${usedCharsInfo} - ${translate(helperText)}`
|
|
33
|
+
: usedCharsInfo
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return <TextInput {...props} validate={validate} helperText={helperText} />
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
SmartTextInput.displayName = 'SmartTextInput'
|
|
40
|
+
|
|
41
|
+
SmartTextInput.defaultProps = {
|
|
42
|
+
multiline: false,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
SmartTextInput.propTypes = {
|
|
46
|
+
...TextInput.propTypes,
|
|
47
|
+
maxLength: PropTypes.number,
|
|
48
|
+
multiline: PropTypes.bool,
|
|
49
|
+
rows: PropTypes.number,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default SmartTextInput
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import LabeledInput from './LabeledInput'
|
|
2
|
+
import { TextInput as RaTextInput } from 'react-admin'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
const TextInput = (props) => (
|
|
6
|
+
<LabeledInput {...props}>
|
|
7
|
+
<RaTextInput />
|
|
8
|
+
</LabeledInput>
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
TextInput.defaultProps = {
|
|
12
|
+
...RaTextInput.defaultProps,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
TextInput.propTypes = {
|
|
16
|
+
...RaTextInput.propTypes,
|
|
17
|
+
...LabeledInput.propTypes,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default TextInput
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import LabeledInput from './LabeledInput'
|
|
2
|
+
import { TimeInput as RaTimeInput } from 'react-admin'
|
|
3
|
+
import { parseTime } from '../../utils'
|
|
4
|
+
import { styled } from '@mui/material/styles'
|
|
5
|
+
|
|
6
|
+
const defaultFormatter = (v) => {
|
|
7
|
+
if (!v) {
|
|
8
|
+
return ''
|
|
9
|
+
}
|
|
10
|
+
const time = parseTime(v)
|
|
11
|
+
if (time) {
|
|
12
|
+
return time.format('HH:mm')
|
|
13
|
+
}
|
|
14
|
+
return ''
|
|
15
|
+
}
|
|
16
|
+
const defaultParser = (v) => {
|
|
17
|
+
return v
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ApplicaStyledTimeInput = styled(RaTimeInput, {
|
|
21
|
+
name: 'RaApplicaTimeInput',
|
|
22
|
+
slot: 'root',
|
|
23
|
+
})(({ label }) => ({
|
|
24
|
+
'& legend': {
|
|
25
|
+
width: label === false ? 0 : 'auto',
|
|
26
|
+
},
|
|
27
|
+
}))
|
|
28
|
+
|
|
29
|
+
const TimeInput = (props) => (
|
|
30
|
+
<LabeledInput {...props}>
|
|
31
|
+
<ApplicaStyledTimeInput />
|
|
32
|
+
</LabeledInput>
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
TimeInput.defaultProps = {
|
|
36
|
+
...RaTimeInput.defaultProps,
|
|
37
|
+
format: defaultFormatter,
|
|
38
|
+
parse: defaultParser,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
TimeInput.propTypes = {
|
|
42
|
+
...RaTimeInput.propTypes,
|
|
43
|
+
...LabeledInput.propTypes,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default TimeInput
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import ArrayInput from './ArrayInput'
|
|
2
|
+
import AttachmentInput from './AttachmentInput'
|
|
3
|
+
import AutocompleteArrayInput from './AutocompleteArrayInput'
|
|
4
|
+
import AutocompleteInput from './AutocompleteInput'
|
|
5
|
+
import BooleanInput from './BooleanInput'
|
|
6
|
+
import DateInput from './DateInput'
|
|
7
|
+
import FileInput from './FileInput'
|
|
8
|
+
import ImageInput from './ImageInput'
|
|
9
|
+
import LabeledInput from './LabeledInput'
|
|
10
|
+
import NumberInput from './NumberInput'
|
|
11
|
+
import RecordInput from './RecordInput'
|
|
12
|
+
import ReferenceArrayInput from './ReferenceArrayInput'
|
|
13
|
+
import ReferenceInput from './ReferenceInput'
|
|
14
|
+
import ReferenceManyInput from './ReferenceManyInput'
|
|
15
|
+
import SearchInput from './SearchInput'
|
|
16
|
+
import SelectArrayInput from './SelectArrayInput'
|
|
17
|
+
import SelectInput from './SelectInput'
|
|
18
|
+
import SmartTextInput from './SmartTextInput'
|
|
19
|
+
import TextInput from './TextInput'
|
|
20
|
+
import TimeInput from './TimeInput'
|
|
21
|
+
export {
|
|
22
|
+
ArrayInput,
|
|
23
|
+
AttachmentInput,
|
|
24
|
+
AutocompleteArrayInput,
|
|
25
|
+
AutocompleteInput,
|
|
26
|
+
BooleanInput,
|
|
27
|
+
DateInput,
|
|
28
|
+
FileInput,
|
|
29
|
+
ImageInput,
|
|
30
|
+
LabeledInput,
|
|
31
|
+
NumberInput,
|
|
32
|
+
RecordInput,
|
|
33
|
+
ReferenceArrayInput,
|
|
34
|
+
ReferenceInput,
|
|
35
|
+
ReferenceManyInput,
|
|
36
|
+
SearchInput,
|
|
37
|
+
SelectArrayInput,
|
|
38
|
+
SelectInput,
|
|
39
|
+
SmartTextInput,
|
|
40
|
+
TextInput,
|
|
41
|
+
TimeInput,
|
|
42
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Datagrid as RaDatagrid } from 'react-admin'
|
|
2
|
+
import { styled } from '@mui/material/styles'
|
|
3
|
+
|
|
4
|
+
const ApplicaStyledDatagrid = styled(RaDatagrid, {
|
|
5
|
+
name: 'RaApplicaDatagrid',
|
|
6
|
+
slot: 'root'
|
|
7
|
+
})(() => ({
|
|
8
|
+
// Resolve an issue related to the visualization of the bulk actions toolbar.
|
|
9
|
+
// Padding and margin create a non empty space that allows the toolbar to be displayed when
|
|
10
|
+
// the selection is empty.
|
|
11
|
+
'& .RaBulkActionsToolbar-collapsed': {
|
|
12
|
+
height: 0,
|
|
13
|
+
paddingTop: 0,
|
|
14
|
+
paddingBottom: 0
|
|
15
|
+
},
|
|
16
|
+
'& .RaBulkActionsToolbar-topToolbar': {
|
|
17
|
+
backgroundColor: 'transparent'
|
|
18
|
+
},
|
|
19
|
+
// Resolve a defect related to the usage of AntDesin icons with Mantis and React-Admin.
|
|
20
|
+
// These two lines are not needed if you are not using AntDesign icons.
|
|
21
|
+
'& .icon span': {
|
|
22
|
+
top: -1,
|
|
23
|
+
left: -1
|
|
24
|
+
},
|
|
25
|
+
'& th': {
|
|
26
|
+
backgroundColor: 'yellow',
|
|
27
|
+
textOverflow: 'ellipsis',
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
whiteSpace: 'nowrap'
|
|
30
|
+
}
|
|
31
|
+
}))
|
|
32
|
+
|
|
33
|
+
const Datagrid = (props) => <ApplicaStyledDatagrid {...props} />
|
|
34
|
+
|
|
35
|
+
Datagrid.propTypes = {
|
|
36
|
+
...RaDatagrid.propTypes
|
|
37
|
+
}
|
|
38
|
+
Datagrid.defaultProps = {
|
|
39
|
+
...RaDatagrid.defaultProps
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default Datagrid
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
useGetResourceLabel,
|
|
6
|
+
useResourceContext,
|
|
7
|
+
useResourceDefinition,
|
|
8
|
+
useTranslate,
|
|
9
|
+
} from 'ra-core'
|
|
10
|
+
|
|
11
|
+
import { Inbox } from '@mui/icons-material'
|
|
12
|
+
import PropTypes from 'prop-types'
|
|
13
|
+
import { Typography } from '@mui/material'
|
|
14
|
+
import { styled } from '@mui/material/styles'
|
|
15
|
+
|
|
16
|
+
const StyledToolbar = styled('div')(({ theme }) => ({
|
|
17
|
+
padding: theme.spacing(2),
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
const Empty = ({ actions, className, ...props }) => {
|
|
21
|
+
const { hasCreate } = useResourceDefinition(props)
|
|
22
|
+
const resource = useResourceContext(props)
|
|
23
|
+
|
|
24
|
+
const translate = useTranslate()
|
|
25
|
+
|
|
26
|
+
const getResourceLabel = useGetResourceLabel()
|
|
27
|
+
const resourceName = translate(`resources.${resource}.forcedCaseName`, {
|
|
28
|
+
smart_count: 0,
|
|
29
|
+
_: getResourceLabel(resource, 0),
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const emptyMessage = translate('ra.page.empty', { name: resourceName })
|
|
33
|
+
const inviteMessage = translate('ra.page.invite')
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Root className={className}>
|
|
37
|
+
<div className={EmptyClasses.message}>
|
|
38
|
+
<Inbox className={EmptyClasses.icon} />
|
|
39
|
+
<Typography variant="h4" paragraph>
|
|
40
|
+
{translate(`resources.${resource}.empty`, {
|
|
41
|
+
_: emptyMessage,
|
|
42
|
+
})}
|
|
43
|
+
</Typography>
|
|
44
|
+
{hasCreate && (
|
|
45
|
+
<Typography variant="body1">
|
|
46
|
+
{translate(`resources.${resource}.invite`, {
|
|
47
|
+
_: inviteMessage,
|
|
48
|
+
})}
|
|
49
|
+
</Typography>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<StyledToolbar className={EmptyClasses.toolbar}>{actions}</StyledToolbar>
|
|
54
|
+
</Root>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const PREFIX = 'RaApplicaEmpty'
|
|
59
|
+
|
|
60
|
+
export const EmptyClasses = {
|
|
61
|
+
message: `${PREFIX}-message`,
|
|
62
|
+
icon: `${PREFIX}-icon`,
|
|
63
|
+
toolbar: `${PREFIX}-toolbar`,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const Root = styled('span', {
|
|
67
|
+
name: PREFIX,
|
|
68
|
+
overridesResolver: (props, styles) => styles.root,
|
|
69
|
+
})(({ theme }) => ({
|
|
70
|
+
flex: 1,
|
|
71
|
+
[`& .${EmptyClasses.message}`]: {
|
|
72
|
+
textAlign: 'center',
|
|
73
|
+
opacity: theme.palette.mode === 'light' ? 0.5 : 0.8,
|
|
74
|
+
margin: '0 1em',
|
|
75
|
+
color: theme.palette.mode === 'light' ? 'inherit' : theme.palette.text.primary,
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
[`& .${EmptyClasses.icon}`]: {
|
|
79
|
+
width: '9em',
|
|
80
|
+
height: '9em',
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
[`& .${EmptyClasses.toolbar}`]: {
|
|
84
|
+
textAlign: 'center',
|
|
85
|
+
marginTop: '2em',
|
|
86
|
+
},
|
|
87
|
+
}))
|
|
88
|
+
|
|
89
|
+
Empty.propTypes = {
|
|
90
|
+
actions: PropTypes.element,
|
|
91
|
+
className: PropTypes.string,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default Empty
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import MainCard from '../MainCard'
|
|
2
|
+
import { List as RaList } from 'react-admin'
|
|
3
|
+
import { styled } from '@mui/system'
|
|
4
|
+
|
|
5
|
+
const ApplicaStyledList = styled(RaList, {
|
|
6
|
+
name: 'RaApplicaList',
|
|
7
|
+
slot: 'root'
|
|
8
|
+
})(({ theme }) => ({
|
|
9
|
+
'& .RaList-main': {
|
|
10
|
+
overflowX: 'auto',
|
|
11
|
+
'& .RaBulkActionsToolbar-toolbar': {
|
|
12
|
+
// La barra delle operazioni massive di react-admin non è perfettamente
|
|
13
|
+
// compatibile con il tema mantis, peratnto ho dovuto apportare una serie
|
|
14
|
+
// di correzioni per allinearla correttamente e consentirne l'utilizzo anche
|
|
15
|
+
// su tabelle con scorrimento orizontale (sopratutto su mobile).
|
|
16
|
+
height: 36,
|
|
17
|
+
top: 42,
|
|
18
|
+
paddingTop: 16,
|
|
19
|
+
'& .RaBulkActionsToolbar-title': {
|
|
20
|
+
alignItems: 'end',
|
|
21
|
+
'& .MuiTypography-root': {
|
|
22
|
+
alignSelf: 'center'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
'& .MuiToolbar-root': {
|
|
27
|
+
'& form': {
|
|
28
|
+
padding: theme.spacing(2),
|
|
29
|
+
paddingBottom: theme.spacing(2),
|
|
30
|
+
alignItems: 'flex-start'
|
|
31
|
+
},
|
|
32
|
+
'& .MuiButton-root': {
|
|
33
|
+
margin: theme.spacing(2)
|
|
34
|
+
},
|
|
35
|
+
'& .RaFilterForm-filterFormInput > .ra-input': {
|
|
36
|
+
alignSelf: 'center'
|
|
37
|
+
},
|
|
38
|
+
'& .RaFilterFormInput-hideButton': {
|
|
39
|
+
marginTop: theme.spacing(1),
|
|
40
|
+
marginBottom: theme.spacing(0.5),
|
|
41
|
+
marginRight: theme.spacing(1)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
'& .RaList-content': {
|
|
46
|
+
// Resolve an issue related to the visualization of the bulk actions toolbar.
|
|
47
|
+
// Padding and margin create a non empty space that allows the toolbar to be displayed when
|
|
48
|
+
// the selection is empty.
|
|
49
|
+
'& .RaBulkActionsToolbar-collapsed': {
|
|
50
|
+
height: 0,
|
|
51
|
+
paddingTop: 0,
|
|
52
|
+
paddingBottom: 0
|
|
53
|
+
},
|
|
54
|
+
// Resolve a defect related to the usage of AntDesin icons with Mantis and React-Admin.
|
|
55
|
+
// These two lines are not needed if you are not using AntDesign icons.
|
|
56
|
+
'& .icon span': {
|
|
57
|
+
top: -1,
|
|
58
|
+
left: -1
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
'& .RaEmpty-toolbar': {
|
|
62
|
+
margin: theme.spacing(2)
|
|
63
|
+
}
|
|
64
|
+
}))
|
|
65
|
+
|
|
66
|
+
const List = (props) => {
|
|
67
|
+
return (
|
|
68
|
+
<MainCard content={false}>
|
|
69
|
+
<ApplicaStyledList {...RaList.defaultProps} {...props} />
|
|
70
|
+
</MainCard>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
List.defaultProps = {
|
|
74
|
+
...RaList.defaultProps
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
List.propTypes = {
|
|
78
|
+
...RaList.propTypes
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default List
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MarkAsReadedButton, MarkAsUnreadedButton } from './button'
|
|
2
|
+
import React, { useCallback, useMemo } from 'react'
|
|
3
|
+
import { darken, lighten, useTheme } from '@mui/material'
|
|
4
|
+
|
|
5
|
+
import ActionsMenu from '../../ActionsMenu'
|
|
6
|
+
import { Datagrid } from 'react-admin'
|
|
7
|
+
import { DateAgoField } from '../../ra-fields'
|
|
8
|
+
import { NotificationField } from './field'
|
|
9
|
+
|
|
10
|
+
const NotificationList = ({ ...props }) => {
|
|
11
|
+
const theme = useTheme()
|
|
12
|
+
const { mode, colorize, density } = useMemo(
|
|
13
|
+
() => ({
|
|
14
|
+
mode: theme.palette.mode,
|
|
15
|
+
colorize: theme.palette.mode === 'dark' ? darken : lighten,
|
|
16
|
+
density: theme.palette.mode === 'dark' ? 0.5 : 0.9
|
|
17
|
+
}),
|
|
18
|
+
[theme.palette.mode]
|
|
19
|
+
)
|
|
20
|
+
const handleRowStyle = useCallback(
|
|
21
|
+
(record) => ({
|
|
22
|
+
backgroundColor: record?.readed
|
|
23
|
+
? colorize(theme.palette.primary[mode], density)
|
|
24
|
+
: colorize(theme.palette.secondary[mode], density)
|
|
25
|
+
}),
|
|
26
|
+
[theme, mode, colorize, density]
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Datagrid {...props} rowStyle={handleRowStyle}>
|
|
31
|
+
<NotificationField source="notification" sortable={false} label="ra.notification" />
|
|
32
|
+
<DateAgoField source="created" label="ra.notification.created" />
|
|
33
|
+
<ActionsMenu>
|
|
34
|
+
<MarkAsReadedButton />
|
|
35
|
+
<MarkAsUnreadedButton />
|
|
36
|
+
</ActionsMenu>
|
|
37
|
+
</Datagrid>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default NotificationList
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
useListContext,
|
|
4
|
+
useNotify,
|
|
5
|
+
useRecordContext,
|
|
6
|
+
useRefresh,
|
|
7
|
+
useResourceContext,
|
|
8
|
+
useUnselectAll,
|
|
9
|
+
useUpdateMany
|
|
10
|
+
} from 'react-admin'
|
|
11
|
+
|
|
12
|
+
import { Email } from '@mui/icons-material'
|
|
13
|
+
import dayjs from 'dayjs'
|
|
14
|
+
import { useCallback } from 'react'
|
|
15
|
+
|
|
16
|
+
const MarkAsReadedButton = () => {
|
|
17
|
+
const refresh = useRefresh()
|
|
18
|
+
const notify = useNotify()
|
|
19
|
+
const unselectAll = useUnselectAll()
|
|
20
|
+
const resource = useResourceContext()
|
|
21
|
+
const { selectedIds, data: tableRows } = useListContext()
|
|
22
|
+
const record = useRecordContext()
|
|
23
|
+
const rows = selectedIds.map((id) => tableRows.find((d) => d.id === id))
|
|
24
|
+
const [updateMany, { isLoading }] = useUpdateMany(
|
|
25
|
+
resource,
|
|
26
|
+
{
|
|
27
|
+
ids: selectedIds.length > 0 ? selectedIds : [record?.id],
|
|
28
|
+
data: { readed: dayjs().format('YYYY-MM-DD HH:mm:ss') },
|
|
29
|
+
rows
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
onSuccess: () => {
|
|
33
|
+
refresh()
|
|
34
|
+
notify('resources.notifications.messages.readed.done')
|
|
35
|
+
unselectAll(resource)
|
|
36
|
+
},
|
|
37
|
+
onError: () => notify('ra.notification.readed_error', 'warning'),
|
|
38
|
+
|
|
39
|
+
onFailure: () => notify('ra.notification.readed_error', 'warning')
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
const handleUpdateMany = useCallback(() => {
|
|
43
|
+
updateMany()
|
|
44
|
+
}, [updateMany])
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Button
|
|
48
|
+
label="ra.notification.mark_as_readed"
|
|
49
|
+
disabled={isLoading || record?.readed !== null}
|
|
50
|
+
onClick={handleUpdateMany}
|
|
51
|
+
>
|
|
52
|
+
<Email />
|
|
53
|
+
</Button>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default MarkAsReadedButton
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
useListContext,
|
|
4
|
+
useNotify,
|
|
5
|
+
useRecordContext,
|
|
6
|
+
useRefresh,
|
|
7
|
+
useResourceContext,
|
|
8
|
+
useUnselectAll,
|
|
9
|
+
useUpdateMany
|
|
10
|
+
} from 'react-admin'
|
|
11
|
+
|
|
12
|
+
import { Drafts } from '@mui/icons-material'
|
|
13
|
+
import { useCallback } from 'react'
|
|
14
|
+
|
|
15
|
+
const MarkAsUnreadedButton = () => {
|
|
16
|
+
const refresh = useRefresh()
|
|
17
|
+
const notify = useNotify()
|
|
18
|
+
const unselectAll = useUnselectAll()
|
|
19
|
+
const { selectedIds, data: tableRows } = useListContext()
|
|
20
|
+
const record = useRecordContext()
|
|
21
|
+
const resource = useResourceContext()
|
|
22
|
+
const rows = selectedIds.map((id) => tableRows.find((d) => d.id === id)).concat([record])
|
|
23
|
+
const [updateMany, { isLoading }] = useUpdateMany(
|
|
24
|
+
resource,
|
|
25
|
+
{
|
|
26
|
+
ids: selectedIds.length > 0 ? selectedIds : [record?.id],
|
|
27
|
+
data: { readed: null },
|
|
28
|
+
rows
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
onSuccess: () => {
|
|
32
|
+
refresh()
|
|
33
|
+
notify('resources.notifications.messages.unreaded.done')
|
|
34
|
+
unselectAll('notifications')
|
|
35
|
+
},
|
|
36
|
+
onFailure: () => notify('resources.notifications.messages.unreaded.error', 'warning')
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const handleUpdateMany = useCallback(() => {
|
|
41
|
+
updateMany()
|
|
42
|
+
}, [updateMany])
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Button
|
|
46
|
+
color="secondary"
|
|
47
|
+
label="ra.notification.mark_as_unreaded"
|
|
48
|
+
disabled={isLoading || (record && !record?.readed)}
|
|
49
|
+
onClick={handleUpdateMany}
|
|
50
|
+
>
|
|
51
|
+
<Drafts />
|
|
52
|
+
</Button>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default MarkAsUnreadedButton
|