From c82a6dc5efcb540dd4e1ffedf18701229be9caa5 Mon Sep 17 00:00:00 2001 From: Neil <55785687+carkom@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:35:59 +0000 Subject: [PATCH] Custom Reports disabled list (#2410) * Add interval split and menu items * notes * disabledList work * notes * fix * fix balanceType * rework constants * review fixes --- .../src/components/reports/ReportOptions.ts | 2 +- .../src/components/reports/ReportSidebar.jsx | 56 ++------- .../src/components/reports/ReportTopbar.jsx | 50 +++----- .../src/components/reports/disabledList.ts | 117 ++++++++++++++++++ .../reports/reports/CustomReport.jsx | 72 +++++++++-- upcoming-release-notes/2410.md | 6 + 6 files changed, 219 insertions(+), 84 deletions(-) create mode 100644 packages/desktop-client/src/components/reports/disabledList.ts create mode 100644 upcoming-release-notes/2410.md diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts index d8eda05e91e..b62b6c367b3 100644 --- a/packages/desktop-client/src/components/reports/ReportOptions.ts +++ b/packages/desktop-client/src/components/reports/ReportOptions.ts @@ -64,7 +64,7 @@ const intervalOptions = [ ]; export const ReportOptions = { - groupBy: groupByOptions, + groupBy: groupByOptions.map(item => item.description), balanceType: balanceTypeOptions, balanceTypeMap: new Map( balanceTypeOptions.map(item => [item.description, item.format]), diff --git a/packages/desktop-client/src/components/reports/ReportSidebar.jsx b/packages/desktop-client/src/components/reports/ReportSidebar.jsx index 1c0125d39bd..2b42b4af260 100644 --- a/packages/desktop-client/src/components/reports/ReportSidebar.jsx +++ b/packages/desktop-client/src/components/reports/ReportSidebar.jsx @@ -27,8 +27,6 @@ export function ReportSidebar({ dateRangeLine, allMonths, setDateRange, - typeDisabled, - setTypeDisabled, setGraphType, setGroupBy, setInterval, @@ -41,8 +39,10 @@ export function ReportSidebar({ setShowUncategorized, setSelectedCategories, onChangeDates, - onChangeViews, onReportChange, + disabledItems, + defaultItems, + defaultModeItems, }) { const [menuOpen, setMenuOpen] = useState(false); const onSelectRange = cond => { @@ -87,50 +87,25 @@ export function ReportSidebar({ const onChangeMode = cond => { onReportChange({ type: 'modify' }); setMode(cond); + let graph; if (cond === 'time') { - if (customReportItems.graphType === 'TableGraph') { - setTypeDisabled([]); - } else { - setTypeDisabled(['Net']); - if (['Net'].includes(customReportItems.balanceType)) { - setBalanceType('Payment'); - } - } if (customReportItems.graphType === 'BarGraph') { setGraphType('StackedBarGraph'); - } - if (['AreaGraph', 'DonutGraph'].includes(customReportItems.graphType)) { - setGraphType('TableGraph'); - onChangeViews('viewLegend', false); - } - if (customReportItems.groupBy === 'Interval') { - setGroupBy('Category'); + graph = 'StackedBarGraph'; } } else { if (customReportItems.graphType === 'StackedBarGraph') { setGraphType('BarGraph'); - } else { - setTypeDisabled([]); + graph = 'BarGraph'; } } + defaultModeItems(graph, cond); }; const onChangeSplit = cond => { onReportChange({ type: 'modify' }); setGroupBy(cond); - if (customReportItems.mode === 'total') { - if (customReportItems.graphType !== 'TableGraph') { - setTypeDisabled( - customReportItems.groupBy !== 'Interval' ? [] : ['Net'], - ); - } - } - if ( - ['Net'].includes(customReportItems.balanceType) && - customReportItems.graphType !== 'TableGraph' - ) { - setBalanceType('Payment'); - } + defaultItems(cond); }; const onChangeBalanceType = cond => { @@ -196,17 +171,8 @@ export function ReportSidebar({