From ea34943121cab989e5ced540139c4fd39527cbde Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 30 Jan 2023 09:22:18 -0800 Subject: Reports split button --- modern/src/common/components/SplitButton.js | 45 +++++++++++++++++++++++++++ modern/src/reports/components/ReportFilter.js | 38 ++++++++++------------ 2 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 modern/src/common/components/SplitButton.js (limited to 'modern/src') diff --git a/modern/src/common/components/SplitButton.js b/modern/src/common/components/SplitButton.js new file mode 100644 index 00000000..bdf12870 --- /dev/null +++ b/modern/src/common/components/SplitButton.js @@ -0,0 +1,45 @@ +import React, { useRef, useState } from 'react'; +import { Button, ButtonGroup, Menu, MenuItem, Typography } from '@mui/material'; +import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; + +const SplitButton = ({ fullWidth, variant, color, disabled, onClick, options }) => { + const anchorRef = useRef(); + const [menuAnchorEl, setMenuAnchorEl] = useState(null); + const [selected, setSelected] = useState(Object.keys(options)[0]); + + return ( + <> + + + + + setMenuAnchorEl(null)} + anchorOrigin={{ + vertical: 'bottom', + horizontal: 'right', + }} + > + {Object.entries(options).map(([key, value]) => ( + { + setSelected(key); + setMenuAnchorEl(null); + }} + > + {value} + + ))} + + + ); +}; + +export default SplitButton; diff --git a/modern/src/reports/components/ReportFilter.js b/modern/src/reports/components/ReportFilter.js index 804d0d4b..67ea3d2f 100644 --- a/modern/src/reports/components/ReportFilter.js +++ b/modern/src/reports/components/ReportFilter.js @@ -7,6 +7,7 @@ import moment from 'moment'; import { useTranslation } from '../../common/components/LocalizationProvider'; import useReportStyles from '../common/useReportStyles'; import { reportsActions } from '../../store'; +import SplitButton from '../../common/components/SplitButton'; const ReportFilter = ({ children, handleSubmit, showOnly, ignoreDevice, multiDevice, includeGroups }) => { const classes = useReportStyles(); @@ -148,37 +149,30 @@ const ReportFilter = ({ children, handleSubmit, showOnly, ignoreDevice, multiDev )} {children} -
- - {!showOnly && ( +
+ {showOnly ? ( - )} - {!showOnly && ( - + onClick={handleClick} + options={{ + json: t('reportShow'), + export: t('reportExport'), + mail: t('reportEmail'), + }} + /> )}
-- cgit v1.2.3