Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add compact to custom reports #2258

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function ReportTable({
});

const renderItem = useCallback(
({ item, groupByItem, mode, style, monthsCount }) => {
({ item, groupByItem, mode, style, monthsCount, compact }) => {
return (
<ReportTableRow
item={item}
Expand All @@ -59,6 +59,7 @@ export function ReportTable({
mode={mode}
style={style}
monthsCount={monthsCount}
compact={compact}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function ReportTableHeader({
return (
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
key={index}
Expand All @@ -77,15 +77,15 @@ export function ReportTableHeader({
<>
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value="Deposits"
width="flex"
/>
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value="Payments"
Expand All @@ -95,15 +95,15 @@ export function ReportTableHeader({
)}
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value="Totals"
width="flex"
/>
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value="Average"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export function ReportTableList({
index: number;
parent_index?: number;
style?: CSSProperties;
compact: boolean;
};
function RenderRow({ index, parent_index, style }: RenderRowProps) {
function RenderRow({ index, parent_index, style, compact }: RenderRowProps) {
const item =
parent_index === undefined
? data[index]
Expand All @@ -43,6 +44,7 @@ export function ReportTableList({
mode,
style,
monthsCount,
compact,
});
}

Expand All @@ -55,6 +57,7 @@ export function ReportTableList({
<>
<RenderRow
index={index}
compact={compact}
style={
item.categories && {
color: theme.tableRowHeaderText,
Expand All @@ -71,6 +74,7 @@ export function ReportTableList({
<RenderRow
key={category.id}
index={i}
compact={compact}
parent_index={index}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ReportTableRowProps = {
mode: string;
style?: CSSProperties;
monthsCount: number;
compact: boolean;
};

export const ReportTableRow = memo(
Expand All @@ -27,6 +28,7 @@ export const ReportTableRow = memo(
mode,
style,
monthsCount,
compact,
}: ReportTableRowProps) => {
const average = amountToInteger(item[balanceTypeOp]) / monthsCount;
return (
Expand Down Expand Up @@ -54,7 +56,7 @@ export const ReportTableRow = memo(
<Cell
key={amountToCurrency(month[balanceTypeOp])}
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={amountToCurrency(month[balanceTypeOp])}
Expand All @@ -80,7 +82,7 @@ export const ReportTableRow = memo(
width="flex"
privacyFilter
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
/>
Expand All @@ -94,7 +96,7 @@ export const ReportTableRow = memo(
width="flex"
privacyFilter
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
/>
Expand All @@ -109,7 +111,7 @@ export const ReportTableRow = memo(
}
style={{
fontWeight: 600,
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
width="flex"
Expand All @@ -124,7 +126,7 @@ export const ReportTableRow = memo(
}
style={{
fontWeight: 600,
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
width="flex"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function ReportTableTotals({
return (
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
key={amountToCurrency(item[balanceTypeOp])}
Expand All @@ -104,7 +104,7 @@ export function ReportTableTotals({
<>
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={amountToCurrency(data.totalAssets)}
Expand All @@ -118,7 +118,7 @@ export function ReportTableTotals({
/>
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={amountToCurrency(data.totalDebts)}
Expand All @@ -134,7 +134,7 @@ export function ReportTableTotals({
)}
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={amountToCurrency(data[balanceTypeOp])}
Expand All @@ -148,7 +148,7 @@ export function ReportTableTotals({
/>
<Cell
style={{
minWidth: 85,
minWidth: compact ? 80 : 125,
...styles.tnum,
}}
value={integerToCurrency(Math.round(average))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function CustomReport() {
} = useFilters();

const location = useLocation();
const loadReport = location.state.report ?? defaultState;
const loadReport = location.state && (location.state.report ?? defaultState);

const [allMonths, setAllMonths] = useState(null);
const [typeDisabled, setTypeDisabled] = useState(['Net']);
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2258.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [carkom]
---

Adding compact elements to custom reports.