Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
carkom committed Jan 22, 2024
1 parent e961ef6 commit be8723b
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 77 deletions.
13 changes: 7 additions & 6 deletions packages/desktop-client/src/components/reports/ReportOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ const endDate = monthUtils.currentMonth();

export const defaultReport: CustomReportEntity = {
id: undefined,
name: undefined,
startDate,
endDate,
isDateStatic: false,
dateRange: 'Last 6 months',
mode: 'total',
groupBy: 'Category',
balanceType: 'Payment',
showEmpty: false,
showOffBudgetHidden: false,
showOffBudget: false,
showUncategorized: false,
graphType: 'BarGraph',
startDate,
endDate,
selectedCategories: null,

Check failure on line 26 in packages/desktop-client/src/components/reports/ReportOptions.ts

View workflow job for this annotation

GitHub Actions / typecheck

Type 'null' is not assignable to type 'CategoryEntity[]'.
isDateStatic: false,
graphType: 'BarGraph',
conditionsOp: 'and',
name: 'Default',
};

const balanceTypeOptions = [
Expand Down
28 changes: 14 additions & 14 deletions packages/desktop-client/src/components/reports/ReportSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export function ReportSidebar({
setSelectedCategories,
onChangeDates,
onChangeViews,
setSavedStatus,
onReportChange,
}) {
const onSelectRange = cond => {
setSavedStatus('changed');
onReportChange(null, 'modify');
setDateRange(cond);
switch (cond) {
case 'All time':
Expand Down Expand Up @@ -75,7 +75,7 @@ export function ReportSidebar({
};

const onChangeMode = cond => {
setSavedStatus('changed');
onReportChange(null, 'modify');
setMode(cond);
if (cond === 'time') {
if (customReportItems.graphType === 'TableGraph') {
Expand Down Expand Up @@ -106,7 +106,7 @@ export function ReportSidebar({
};

const onChangeSplit = cond => {
setSavedStatus('changed');
onReportChange(null, 'modify');
setGroupBy(cond);
if (customReportItems.mode === 'total') {
if (customReportItems.graphType !== 'TableGraph') {
Expand All @@ -124,7 +124,7 @@ export function ReportSidebar({
};

const onChangeBalanceType = cond => {
setSavedStatus('changed');
onReportChange(null, 'modify');
setBalanceType(cond);
};

Expand Down Expand Up @@ -258,7 +258,7 @@ export function ReportSidebar({
value={customReportItems.showEmpty}
onChange={() => {
setShowEmpty(!customReportItems.showEmpty);
setSavedStatus('changed');
onReportChange(null, 'modify');
}}
/>
<label
Expand All @@ -280,11 +280,11 @@ export function ReportSidebar({

<Checkbox
id="show-hidden-columns"
checked={customReportItems.showOffBudgetHidden}
value={customReportItems.showOffBudgetHidden}
checked={customReportItems.showOffBudget}
value={customReportItems.showOffBudget}
onChange={() => {
setShowOffBudgetHidden(!customReportItems.showOffBudgetHidden);
setSavedStatus('changed');
setShowOffBudgetHidden(!customReportItems.showOffBudget);
onReportChange(null, 'modify');
}}
/>
<label
Expand All @@ -310,7 +310,7 @@ export function ReportSidebar({
value={customReportItems.showUncategorized}
onChange={() => {
setShowUncategorized(!customReportItems.showUncategorized);
setSavedStatus('changed');
onReportChange(null, 'modify');
}}
/>
<label
Expand Down Expand Up @@ -358,7 +358,7 @@ export function ReportSidebar({
customReportItems.startDate,
customReportItems.endDate,
);
setSavedStatus('changed');
onReportChange(null, 'modify');
}}
>
Static
Expand Down Expand Up @@ -408,7 +408,7 @@ export function ReportSidebar({
customReportItems.endDate,
),
);
setSavedStatus('changed');
onReportChange(null, 'modify');
}}
value={customReportItems.startDate}
defaultLabel={monthUtils.format(
Expand Down Expand Up @@ -437,7 +437,7 @@ export function ReportSidebar({
newValue,
),
);
setSavedStatus('changed');
onReportChange(null, 'modify');
}}
value={customReportItems.endDate}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
Expand Down
10 changes: 5 additions & 5 deletions packages/desktop-client/src/components/reports/ReportTopbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function ReportTopbar({
selected={customReportItems.graphType === 'TableGraph'}
title="Data Table"
onSelect={() => {
setSavedStatus('changed');
onReportChange(null, 'modify');
setGraphType('TableGraph');
onChangeViews('viewLegend', false);
setTypeDisabled([]);
Expand All @@ -64,7 +64,7 @@ export function ReportTopbar({
customReportItems.graphType === 'StackedBarGraph'
}
onSelect={() => {
setSavedStatus('changed');
onReportChange(null, 'modify');
if (customReportItems.mode === 'total') {
setGraphType('BarGraph');
if (['Net'].includes(customReportItems.balanceType)) {
Expand All @@ -89,7 +89,7 @@ export function ReportTopbar({
title="Area Graph"
selected={customReportItems.graphType === 'AreaGraph'}
onSelect={() => {
setSavedStatus('changed');
onReportChange(null, 'modify');
setGraphType('AreaGraph');
setGroupBy('Month');
onChangeViews('viewLegend', false);
Expand All @@ -104,7 +104,7 @@ export function ReportTopbar({
title="Donut Graph"
selected={customReportItems.graphType === 'DonutGraph'}
onSelect={() => {
setSavedStatus('changed');
onReportChange(null, 'modify');
setGraphType('DonutGraph');
setTypeDisabled(['Net']);
setBalanceType('Payment');
Expand All @@ -126,7 +126,7 @@ export function ReportTopbar({
<GraphButton
selected={viewLegend}
onSelect={() => {
setSavedStatus('changed');
onReportChange(null, 'modify');
onChangeViews('viewLegend');
}}
style={{ marginRight: 15 }}
Expand Down
17 changes: 13 additions & 4 deletions packages/desktop-client/src/components/reports/SaveReport.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-strict-ignore
import React, { createRef, useState } from 'react';

import { v4 as uuidv4 } from 'uuid';

import { send, sendCatch } from 'loot-core/src/platform/client/fetch';

Check warning on line 6 in packages/desktop-client/src/components/reports/SaveReport.tsx

View workflow job for this annotation

GitHub Actions / lint

'send' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 6 in packages/desktop-client/src/components/reports/SaveReport.tsx

View workflow job for this annotation

GitHub Actions / lint

'sendCatch' is defined but never used. Allowed unused vars must match /^_/u
import { type CustomReportEntity } from 'loot-core/src/types/models';

Expand Down Expand Up @@ -49,14 +51,19 @@ export function SaveReport({

if (menuItem === 'save-report') {
//create new flow
/*
res = await sendCatch('report/create', {
...savedReport,
});
*/
savedReport = {
...savedReport,
id: res.data,
id: uuidv4(),
name,
};
} else {
}

if (['rename-report', 'update-report'].includes(menuItem)) {
//rename or update flow
if (menuItem === 'rename-report') {
//rename
Expand All @@ -66,11 +73,13 @@ export function SaveReport({
};
}
//send update and rename to DB
/*
res = await sendCatch('report/update', {
...savedReport,
});
*/
}
if (res.error) {
if (res) {
setErr(res.error.message);
setNameMenuOpen(true);
} else {
Expand All @@ -93,7 +102,7 @@ export function SaveReport({
break;
case 'delete-report':
setMenuOpen(false);
await send('report/delete', id);
//await send('report/delete', id);
onResetReports();
break;
case 'update-report':
Expand Down
18 changes: 5 additions & 13 deletions packages/desktop-client/src/components/reports/SaveReportMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,50 @@ export function SaveReportMenu({
onMenuSelect(item);
}}
items={
report.id === null
report.id === undefined
? [
{
name: 'save-report',
text: 'Save new report',
disabled: true,
},
{
name: 'reset-report',
text: 'Reset to default',
disabled: true,
},
]
: savedStatus === 'saved'
? [
{ name: 'rename-report', text: 'Rename', disabled: true },
{ name: 'delete-report', text: 'Delete', disabled: true },
{ name: 'rename-report', text: 'Rename' },
{ name: 'delete-report', text: 'Delete' },
Menu.line,
{
name: 'save-report',
text: 'Save new report',
disabled: true,
},
{
name: 'reset-report',
text: 'Reset to default',
disabled: true,
},
]
: [
{ name: 'rename-report', text: 'Rename', disabled: true },
{ name: 'rename-report', text: 'Rename' },
{
name: 'update-report',
text: 'Update report',
disabled: true,
},
{
name: 'reload-report',
text: 'Revert changes',
disabled: true,
},
{ name: 'delete-report', text: 'Delete', disabled: true },
{ name: 'delete-report', text: 'Delete' },
Menu.line,
{
name: 'save-report',
text: 'Save new report',
disabled: true,
},
{
name: 'reset-report',
text: 'Reset to default',
disabled: true,
},
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function SaveReportName({
>
<FormField style={{ flex: 1 }}>
<FormLabel
title="Filter Name"
title="Report Name"
htmlFor="name-field"
style={{ userSelect: 'none' }}
/>
Expand Down
Loading

0 comments on commit be8723b

Please sign in to comment.