Skip to content

Commit

Permalink
Custom Reports date paused (#2080)
Browse files Browse the repository at this point in the history
* work

* fixes

* updates

* update table layout

* revert changes

* notes

* updae names and improve flow
  • Loading branch information
carkom authored Dec 15, 2023
1 parent 8a15caf commit 4497fbc
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 66 deletions.
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.

0 comments on commit 4497fbc

Please sign in to comment.