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

Custom Reports date paused #2080

Merged
merged 9 commits into from
Dec 15, 2023
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,8 +50,19 @@ export default function CategorySelector({

return (
<View>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<Button type="bare" onClick={() => setUncheckedHidden(state => !state)}>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
marginBottom: 5,
flexShrink: 0,
}}
>
<Button
type="bare"
onClick={() => setUncheckedHidden(state => !state)}
style={{ padding: 8 }}
>
<View>
{uncheckedHidden ? (
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
Expand Down Expand Up @@ -97,7 +108,6 @@ export default function CategorySelector({
marginLeft: 0,
paddingLeft: 0,
paddingRight: 10,
height: 320,
flexGrow: 1,
overflowY: 'auto',
}}
Expand Down
144 changes: 85 additions & 59 deletions packages/desktop-client/src/components/reports/ReportSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export function ReportSidebar({
setBalanceType,
mode,
setMode,
isDateStatic,
setIsDateStatic,
showEmpty,
setShowEmpty,
showOffBudgetHidden,
Expand All @@ -49,6 +51,7 @@ export function ReportSidebar({
setSelectedCategories,
}) {
const onSelectRange = cond => {
setDateRange(cond);
switch (cond) {
case 'All time':
onChangeDates(...getFullRange(allMonths));
Expand Down Expand Up @@ -325,67 +328,90 @@ export function ReportSidebar({
<Text>
<strong>Date filters</strong>
</Text>
</View>
<View
style={{
flexDirection: 'row',
padding: 5,
alignItems: 'center',
}}
>
<Text style={{ width: 40, textAlign: 'right', marginRight: 5 }}>
Range:
</Text>
<Select
value={dateRange}
onChange={e => {
setDateRange(e);
onSelectRange(e);
<View style={{ flex: 1 }} />
<ModeButton
selected={!isDateStatic}
onSelect={() => {
setIsDateStatic(false);
onSelectRange(dateRange);
}}
options={ReportOptions.dateRange.map(option => [
option.description,
option.description,
])}
line={dateRangeLine}
/>
</View>
<View
style={{
flexDirection: 'row',
padding: 5,
alignItems: 'center',
}}
>
<Text style={{ width: 40, textAlign: 'right', marginRight: 5 }}>
From:
</Text>
<Select
onChange={newValue =>
onChangeDates(...validateStart(allMonths, newValue, endDate))
}
value={startDate}
defaultLabel={monthUtils.format(startDate, 'MMMM, yyyy')}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
/>
</View>
<View
style={{
flexDirection: 'row',
padding: 5,
alignItems: 'center',
}}
>
<Text style={{ width: 40, textAlign: 'right', marginRight: 5 }}>
To:
</Text>
<Select
onChange={newValue =>
onChangeDates(...validateEnd(allMonths, startDate, newValue))
}
value={endDate}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
/>
>
Live
</ModeButton>
<ModeButton
selected={isDateStatic}
onSelect={() => {
setIsDateStatic(true);
onChangeDates(startDate, endDate);
}}
>
Static
</ModeButton>
</View>
{!isDateStatic ? (
<View
style={{
flexDirection: 'row',
padding: 5,
alignItems: 'center',
}}
>
<Text style={{ width: 40, textAlign: 'right', marginRight: 5 }}>
Range:
</Text>
<Select
value={dateRange}
onChange={e => {
onSelectRange(e);
}}
options={ReportOptions.dateRange.map(option => [
option.description,
option.description,
])}
line={dateRangeLine}
/>
</View>
) : (
<>
<View
style={{
flexDirection: 'row',
padding: 5,
alignItems: 'center',
}}
>
<Text style={{ width: 40, textAlign: 'right', marginRight: 5 }}>
From:
</Text>
<Select
onChange={newValue =>
onChangeDates(...validateStart(allMonths, newValue, endDate))
}
value={startDate}
defaultLabel={monthUtils.format(startDate, 'MMMM, yyyy')}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
/>
</View>
<View
style={{
flexDirection: 'row',
padding: 5,
alignItems: 'center',
}}
>
<Text style={{ width: 40, textAlign: 'right', marginRight: 5 }}>
To:
</Text>
<Select
onChange={newValue =>
onChangeDates(...validateEnd(allMonths, startDate, newValue))
}
value={endDate}
options={allMonths.map(({ name, pretty }) => [name, pretty])}
/>
</View>
</>
)}
<View
style={{
height: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function CustomReport() {
const [endDate, setEndDate] = useState(monthUtils.currentMonth());

const [mode, setMode] = useState('total');
const [isDateStatic, setIsDateStatic] = useState(false);
const [groupBy, setGroupBy] = useState('Category');
const [balanceType, setBalanceType] = useState('Payment');
const [showEmpty, setShowEmpty] = useState(false);
Expand Down Expand Up @@ -126,6 +127,7 @@ export default function CustomReport() {
selectedCategories,
filters,
conditionsOp,
showEmpty,
showOffBudgetHidden,
showUncategorized,
]);
Expand Down Expand Up @@ -210,6 +212,8 @@ export default function CustomReport() {
setBalanceType={setBalanceType}
mode={mode}
setMode={setMode}
isDateStatic={isDateStatic}
setIsDateStatic={setIsDateStatic}
showEmpty={showEmpty}
setShowEmpty={setShowEmpty}
showOffBudgetHidden={showOffBudgetHidden}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ export default function createSpreadsheet({

setData({
data: calcData.filter(i => (!showEmpty ? i[balanceTypeOp] !== 0 : true)),
monthData: monthData.filter(i =>
!showEmpty ? i[balanceTypeOp] !== 0 : true,
),
monthData,
startDate,
endDate,
totalDebts: integerToAmount(totalDebts),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ function createGroupedSpreadsheet({
totalDebts: integerToAmount(totalDebts),
totalTotals: integerToAmount(totalAssets + totalDebts),
monthData,
categories: stackedCategories,
categories: stackedCategories.filter(i =>
!showEmpty ? i[balanceTypeOp] !== 0 : true,
),
};
},
[startDate, endDate],
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2080.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [carkom]
---

Add live/static choice for date filters.
Loading