Skip to content

Commit

Permalink
default sorting options for different report types
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Jan 13, 2025
1 parent e54a9fa commit 5dd53db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/desktop-client/src/components/reports/disabledList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type graphOptions = {
defaultSplit: string;
disabledType: string[];
defaultType: string;
defaultSort: string;
disableLegend?: boolean;
disableLabel?: boolean;
disableSort?: boolean;
Expand All @@ -61,13 +62,15 @@ const totalGraphOptions: graphOptions[] = [
defaultType: 'Payment',
disableLegend: true,
disableLabel: true,
defaultSort: 'Budget',
},
{
description: 'BarGraph',
disabledSplit: [],
defaultSplit: 'Category',
disabledType: [],
defaultType: 'Payment',
defaultSort: 'Descending',
},
{
description: 'AreaGraph',
Expand All @@ -77,13 +80,15 @@ const totalGraphOptions: graphOptions[] = [
defaultType: 'Payment',
disableLegend: true,
disableSort: true,
defaultSort: 'Descending',
},
{
description: 'DonutGraph',
disabledSplit: [],
defaultSplit: 'Category',
disabledType: ['Net'],
defaultType: 'Payment',
defaultSort: 'Descending',
},
];

Expand All @@ -97,6 +102,7 @@ const timeGraphOptions: graphOptions[] = [
disableLegend: true,
disableLabel: true,
disableSort: true,
defaultSort: 'Descending',
},
{
description: 'StackedBarGraph',
Expand All @@ -105,6 +111,7 @@ const timeGraphOptions: graphOptions[] = [
disabledType: [],
defaultType: 'Payment',
disableSort: true,
defaultSort: 'Descending',
},
{
description: 'LineGraph',
Expand All @@ -115,6 +122,7 @@ const timeGraphOptions: graphOptions[] = [
disableLegend: false,
disableLabel: true,
disableSort: true,
defaultSort: 'Descending',
},
];

Expand Down Expand Up @@ -174,7 +182,7 @@ export function disabledLegendLabel(
export function defaultsGraphList(
item: string,
newGraph: string,
type: 'defaultSplit' | 'defaultType',
type: 'defaultSplit' | 'defaultType' | 'defaultSort',
) {
const graphList = modeOptions.find(d => d.description === item);
if (!graphList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ function CustomReportInner({ report: initialReport }: CustomReportInnerProps) {
setSessionReport('balanceType', cond);
setBalanceType(cond);
}

const defaultSort = defaultsGraphList(mode, chooseGraph, 'defaultSort');
if (defaultSort) {
setSessionReport('sortBy', defaultSort);
setSortBy(defaultSort);
}
};

const isItemDisabled = (type: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ BEGIN TRANSACTION;

ALTER TABLE custom_reports ADD COLUMN sort_by TEXT DEFAULT 'Descending';
UPDATE custom_reports SET sort_by = 'Descending';
UPDATE custom_reports SET sort_by = 'Budget' where graph_type = 'TableGraph';

COMMIT;

0 comments on commit 5dd53db

Please sign in to comment.