diff --git a/packages/desktop-client/src/components/reports/ReportSidebar.jsx b/packages/desktop-client/src/components/reports/ReportSidebar.jsx
index 3cb165203c8..e7945b0768b 100644
--- a/packages/desktop-client/src/components/reports/ReportSidebar.jsx
+++ b/packages/desktop-client/src/components/reports/ReportSidebar.jsx
@@ -44,6 +44,7 @@ export function ReportSidebar({
}) {
const [menuOpen, setMenuOpen] = useState(false);
const onSelectRange = cond => {
+ onReportChange(null, 'modify');
setDateRange(cond);
switch (cond) {
case 'All time':
@@ -77,6 +78,7 @@ export function ReportSidebar({
};
const onChangeMode = cond => {
+ onReportChange(null, 'modify');
setMode(cond);
if (cond === 'time') {
if (customReportItems.graphType === 'TableGraph') {
@@ -107,6 +109,7 @@ export function ReportSidebar({
};
const onChangeSplit = cond => {
+ onReportChange(null, 'modify');
setGroupBy(cond);
if (customReportItems.mode === 'total') {
if (customReportItems.graphType !== 'TableGraph') {
@@ -124,7 +127,7 @@ export function ReportSidebar({
};
const onChangeBalanceType = cond => {
- onReportChange('modify');
+ onReportChange(null, 'modify');
setBalanceType(cond);
};
diff --git a/packages/desktop-client/src/components/reports/ReportTopbar.jsx b/packages/desktop-client/src/components/reports/ReportTopbar.jsx
index 56f6d522da7..d8944ae8c14 100644
--- a/packages/desktop-client/src/components/reports/ReportTopbar.jsx
+++ b/packages/desktop-client/src/components/reports/ReportTopbar.jsx
@@ -18,6 +18,7 @@ import { SaveReportMenuButton } from './SaveReport';
export function ReportTopbar({
customReportItems,
+ savedStatus,
setGraphType,
setTypeDisabled,
setBalanceType,
@@ -169,7 +170,7 @@ export function ReportTopbar({
}}
/>
-
+
);
}
diff --git a/packages/desktop-client/src/components/reports/SaveReport.tsx b/packages/desktop-client/src/components/reports/SaveReport.tsx
index 3d1328e5742..acab9c22669 100644
--- a/packages/desktop-client/src/components/reports/SaveReport.tsx
+++ b/packages/desktop-client/src/components/reports/SaveReport.tsx
@@ -38,7 +38,7 @@ function SaveReportMenu({ setMenuOpen }) {
);
}
-export function SaveReportMenuButton() {
+export function SaveReportMenuButton(savedStatus: string) {
const [menuOpen, setMenuOpen] = useState(false);
return (
@@ -65,6 +65,7 @@ export function SaveReportMenuButton() {
>
Unsaved Report
+ {savedStatus === 'modified' && (modified) }
{menuOpen && }
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.jsx b/packages/desktop-client/src/components/reports/reports/CustomReport.jsx
index accfdeca2d1..ff4385c665e 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReport.jsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.jsx
@@ -82,6 +82,9 @@ export function CustomReport() {
const dateRangeLine = ReportOptions.dateRange.length - 3;
const [report, setReport] = useState(loadReport);
+ const [savedStatus, setSavedStatus] = useState(
+ location.state ? (location.state.report ? 'saved' : 'new') : 'new',
+ );
const months = monthUtils.rangeInclusive(startDate, endDate);
useEffect(() => {
@@ -221,6 +224,7 @@ export function CustomReport() {
const onChangeDates = (startDate, endDate) => {
setStartDate(startDate);
setEndDate(endDate);
+ setSavedStatus('modified');
};
const onChangeViews = (viewType, status) => {
@@ -236,26 +240,26 @@ export function CustomReport() {
};
const onChangeAppliedFilter = (filter, changedElement) => {
- onReportChange('reload');
+ onReportChange(null, 'modify');
return changedElement(filter);
};
- const onReportChange = type => {
+ const onReportChange = (savedReport, type) => {
switch (type) {
+ case 'add-update':
+ setSavedStatus('saved');
+ setReport(savedReport);
+ break;
+ case 'rename':
+ setReport({ ...report, name: savedReport.name });
+ break;
case 'modify':
if (report.name) {
- if (report.name.substr(report.name.length - 10) !== '(modified)') {
- setReport({ ...report, name: report.name + ' (modified)' });
- }
+ setSavedStatus('modified');
}
break;
case 'reload':
- if (report.name.substr(report.name.length - 10) === '(modified)') {
- setReport({
- ...report,
- name: report.name.substr(0, report.name.length - 11),
- });
- }
+ setSavedStatus('saved');
setStartDate(report.startDate);
setEndDate(report.endDate);
@@ -317,6 +321,7 @@ export function CustomReport() {
>