From f0ae38653f930cec08487af14576782a5630eefe Mon Sep 17 00:00:00 2001 From: Neil <55785687+carkom@users.noreply.github.com> Date: Fri, 2 Feb 2024 23:52:35 -0800 Subject: [PATCH] Update and organize reports (#2274) * Add schema work * notes * merge fixes * Add Reports Save Menu * merge fixes * updates * notes * updates * updates * save updates fix * typecheck fixes * revert changes * notes * error fixes * update * fix * merge fixes * review changes * reportChange and savedStatus * Update packages/desktop-client/src/components/reports/SaveReport.tsx Co-authored-by: DJ Mountney * merge fixes --------- Co-authored-by: DJ Mountney --- .../src/components/reports/ReportOptions.ts | 14 +-- .../src/components/reports/ReportSidebar.jsx | 11 ++- .../src/components/reports/ReportTopbar.jsx | 13 ++- .../src/components/reports/SaveReport.tsx | 3 +- .../reports/reports/CustomReport.jsx | 86 ++++++++++++++++--- .../src/client/data-hooks/reports.ts | 1 - packages/loot-core/src/server/reports/app.ts | 7 +- .../loot-core/src/types/models/reports.d.ts | 14 +-- upcoming-release-notes/2274.md | 6 ++ 9 files changed, 119 insertions(+), 36 deletions(-) create mode 100644 upcoming-release-notes/2274.md diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts index 3a0c1fe6911..8c2d361dbe6 100644 --- a/packages/desktop-client/src/components/reports/ReportOptions.ts +++ b/packages/desktop-client/src/components/reports/ReportOptions.ts @@ -10,8 +10,13 @@ import { const startDate = monthUtils.subMonths(monthUtils.currentMonth(), 5); const endDate = monthUtils.currentMonth(); -export const defaultState: CustomReportEntity = { +export const defaultReport: CustomReportEntity = { id: undefined, + name: 'Default', + startDate, + endDate, + isDateStatic: false, + dateRange: 'Last 6 months', mode: 'total', groupBy: 'Category', balanceType: 'Payment', @@ -19,13 +24,10 @@ export const defaultState: CustomReportEntity = { showOffBudget: false, showHiddenCategories: false, showUncategorized: false, + selectedCategories: [], graphType: 'BarGraph', - startDate, - endDate, - selectedCategories: null, - isDateStatic: false, + conditions: [], conditionsOp: 'and', - name: 'Default', }; const balanceTypeOptions = [ diff --git a/packages/desktop-client/src/components/reports/ReportSidebar.jsx b/packages/desktop-client/src/components/reports/ReportSidebar.jsx index 4fba2b21781..0ccb5ef2bc9 100644 --- a/packages/desktop-client/src/components/reports/ReportSidebar.jsx +++ b/packages/desktop-client/src/components/reports/ReportSidebar.jsx @@ -41,9 +41,11 @@ export function ReportSidebar({ setSelectedCategories, onChangeDates, onChangeViews, + onReportChange, }) { const [menuOpen, setMenuOpen] = useState(false); const onSelectRange = cond => { + onReportChange(null, 'modify'); setDateRange(cond); switch (cond) { case 'All time': @@ -77,6 +79,7 @@ export function ReportSidebar({ }; const onChangeMode = cond => { + onReportChange(null, 'modify'); setMode(cond); if (cond === 'time') { if (customReportItems.graphType === 'TableGraph') { @@ -107,6 +110,7 @@ export function ReportSidebar({ }; const onChangeSplit = cond => { + onReportChange(null, 'modify'); setGroupBy(cond); if (customReportItems.mode === 'total') { if (customReportItems.graphType !== 'TableGraph') { @@ -123,6 +127,11 @@ export function ReportSidebar({ } }; + const onChangeBalanceType = cond => { + onReportChange(null, 'modify'); + setBalanceType(cond); + }; + return (