Compare commits

...

28 Commits

Author SHA1 Message Date
Leandro Menezes
83cd364c5f Changed to remove sessionStorage 2025-06-15 13:56:29 -03:00
Crazypkr1099
b61b1758d6 Merge branch 'master' into scrollToLocationBudget 2024-06-20 21:53:37 -04:00
Crazypkr
dbc434c84e Renamed scrollToPosition to setScrollPosition 2024-06-20 21:50:53 -04:00
Crazypkr
b1ea639e11 Merge branch 'scrollToLocationBudget' of https://github.com/Crazypkr1099/actual into scrollToLocationBudget 2024-06-20 21:47:07 -04:00
Crazypkr
bc6098fbb3 Remove intersectionboundary 2024-06-20 21:47:04 -04:00
Crazypkr1099
15869eca61 Merge branch 'master' into scrollToLocationBudget 2024-06-19 21:59:42 -04:00
Crazypkr1099
c5c098ea0c Merge branch 'master' into scrollToLocationBudget 2024-06-18 18:38:02 -04:00
Crazypkr1099
f6b88cc1ba Merge branch 'master' into scrollToLocationBudget 2024-06-18 16:03:47 -04:00
Crazypkr1099
ca1d067921 Merge branch 'master' into scrollToLocationBudget 2024-06-18 13:55:14 -04:00
Crazypkr1099
18e55800e4 Merge branch 'master' into scrollToLocationBudget 2024-06-18 12:36:52 -04:00
Crazypkr1099
18314acd25 Merge branch 'master' into scrollToLocationBudget 2024-06-14 18:44:32 -04:00
Crazypkr1099
042058ec7b Merge branch 'scrollToLocationBudget' of https://github.com/Crazypkr1099/actual into scrollToLocationBudget 2024-06-12 22:43:01 -04:00
Crazypkr1099
9580be7bc4 Mobile Support 2024-06-12 22:42:58 -04:00
Crazypkr1099
569b995278 Update 2859.md 2024-06-12 19:12:39 -04:00
Crazypkr1099
9590a93e9f Merge branch 'master' into scrollToLocationBudget 2024-06-12 19:12:01 -04:00
Crazypkr1099
c20ebd9dbd Added rollover and reset when leaving budget page 2024-06-12 19:10:50 -04:00
Crazypkr
112f066b8b Fix typescript mistake and changed to sessionStorage 2024-06-09 07:53:45 -04:00
Crazypkr
cf6825a541 bug fixes 2024-06-08 12:27:37 -04:00
Crazypkr
9ec0bdec33 fixing more issues 2024-06-08 12:10:31 -04:00
Crazypkr
4c57596117 linting fix 2024-06-08 12:04:26 -04:00
Crazypkr1099
9e7ebb405f Merge branch 'master' into scrollToLocationBudget 2024-06-08 11:57:25 -04:00
Crazypkr
7ba3a37ead Merge branch 'scrollToLocationBudget' of https://github.com/Crazypkr1099/actual into scrollToLocationBudget 2024-06-08 11:55:13 -04:00
Crazypkr
201e1dab54 Revert "Delete packages/desktop-client/e2e directory"
This reverts commit 2476e45735.
2024-06-08 11:55:09 -04:00
Crazypkr
ab124105c2 Revert "Delete packages/desktop-client/e2e directory"
This reverts commit bbec585305.
2024-06-08 11:53:54 -04:00
Crazypkr1099
129b2c3061 Create 2859.md 2024-06-08 11:39:30 -04:00
Crazypkr
9d6b574708 Add ability to scroll to current position in table when leaving budgetable 2024-06-08 11:34:57 -04:00
Crazypkr1099
bbec585305 Delete packages/desktop-client/e2e directory 2024-06-06 23:51:10 -04:00
Crazypkr1099
2476e45735 Delete packages/desktop-client/e2e directory 2024-06-06 23:45:55 -04:00
8 changed files with 111 additions and 12 deletions

Submodule packages/desktop-client/locale added at a0e122296a

View File

@@ -37,7 +37,6 @@ export const BudgetCategories = memo(
function onCollapse(value) {
setCollapsedGroupIdsPref(value);
}
const [isAddingGroup, setIsAddingGroup] = useState(false);
const [newCategoryForGroup, setNewCategoryForGroup] = useState(null);
const items = useMemo(() => {

View File

@@ -1,4 +1,5 @@
import React, { useState } from 'react';
import React, { useRef, useState, useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { useCategories } from '../../hooks/useCategories';
import { useLocalPref } from '../../hooks/useLocalPref';
@@ -29,12 +30,38 @@ export function BudgetTable(props) {
onBudgetAction,
} = props;
const budgetCategoriesRef = useRef();
const scrollableDivRef = useRef();
const location = useLocation();
const { grouped: categoryGroups } = useCategories();
const [collapsedGroupIds = [], setCollapsedGroupIdsPref] =
useLocalPref('budget.collapsed');
const [showHiddenCategories, setShowHiddenCategoriesPef] = useLocalPref(
'budget.showHiddenCategories',
);
const getCurrentScrollPosition = () => {
return scrollableDivRef.current?.scrollTop || 0;
};
const onShowActivityWithScroll = (categoryId, month) => {
const scrollPosition = getCurrentScrollPosition();
onShowActivity(categoryId, month, scrollPosition);
};
useEffect(() => {
const savedScrollPosition = location.state?.scrollPosition;
if (savedScrollPosition && scrollableDivRef.current) {
// Use requestAnimationFrame to ensure the DOM is ready
requestAnimationFrame(() => {
if (scrollableDivRef.current) {
scrollableDivRef.current.scrollTop = savedScrollPosition;
}
});
}
}, [location.state?.scrollPosition]);
const [editing, setEditing] = useState(null);
const onEditMonth = (id, month) => {
@@ -201,6 +228,7 @@ export function BudgetTable(props) {
collapseAllCategories={collapseAllCategories}
/>
<View
id="scrollableDiv"
style={{
overflowY: 'scroll',
overflowAnchor: 'none',
@@ -208,6 +236,7 @@ export function BudgetTable(props) {
paddingLeft: 5,
paddingRight: 5,
}}
innerRef={scrollableDivRef}
>
<View
style={{
@@ -228,7 +257,7 @@ export function BudgetTable(props) {
onReorderCategory={_onReorderCategory}
onReorderGroup={_onReorderGroup}
onBudgetAction={onBudgetAction}
onShowActivity={onShowActivity}
onShowActivity={onShowActivityWithScroll}
/>
</View>
</View>

View File

@@ -276,7 +276,7 @@ function BudgetInner(props: BudgetInnerProps) {
dispatch(applyBudgetAction(month, type, args));
};
const onShowActivity = (categoryId, month) => {
const onShowActivity = (categoryId, month, scrollPosition) => {
const conditions = [
{ field: 'category', op: 'is', value: categoryId, type: 'id' },
{
@@ -287,6 +287,12 @@ function BudgetInner(props: BudgetInnerProps) {
type: 'date',
},
];
navigate('/budget', {
replace: true,
state: { scrollPosition }
});
navigate('/accounts', {
state: {
goBack: true,

View File

@@ -302,7 +302,9 @@ export const CategoryMonth = memo(function CategoryMonth({
<Field name="spent" width="flex" style={{ textAlign: 'right' }}>
<span
data-testid="category-month-spent"
onClick={() => onShowActivity(category.id, month)}
onClick={() => {
onShowActivity(category.id, month);
}}
>
<CellValue
binding={reportBudget.catSumAmount(category.id)}

View File

@@ -295,7 +295,9 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({
<Field name="spent" width="flex" style={{ textAlign: 'right' }}>
<span
data-testid="category-month-spent"
onClick={() => onShowActivity(category.id, month)}
onClick={() => {
onShowActivity(category.id, month);
}}
>
<CellValue
binding={rolloverBudget.catSumAmount(category.id)}

View File

@@ -1,5 +1,6 @@
import React, { memo, useRef } from 'react';
import React, { memo, useRef, useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { useLocation } from 'react-router-dom';
import { AutoTextSize } from 'auto-text-size';
import memoizeOne from 'memoize-one';
@@ -328,6 +329,8 @@ const ExpenseCategory = memo(function ExpenseCategory({
onBudgetAction,
show3Cols,
showBudgetedCol,
setScrollPosition,
onShowActivityWithScroll,
}) {
const opacity = blank ? 0 : 1;
@@ -396,10 +399,6 @@ const ExpenseCategory = memo(function ExpenseCategory({
const listItemRef = useRef();
const format = useFormat();
const navigate = useNavigate();
const onShowActivity = () => {
navigate(`/categories/${category.id}?month=${month}`);
};
const sidebarColumnWidth = getColumnWidth({ show3Cols, isSidebar: true });
const columnWidth = getColumnWidth({ show3Cols });
@@ -517,7 +516,9 @@ const ExpenseCategory = memo(function ExpenseCategory({
binding={spent}
getStyle={makeAmountGrey}
type="financial"
onClick={onShowActivity}
onClick={() => {
onShowActivityWithScroll(category.id, month);
}}
formatter={value => (
<Button
type="bare"
@@ -1235,6 +1236,8 @@ const ExpenseGroup = memo(function ExpenseGroup({
showHiddenCategories,
collapsed,
onToggleCollapse,
setScrollPosition,
onShowActivityWithScroll,
}) {
function editable(content) {
if (!editMode) {
@@ -1347,6 +1350,8 @@ const ExpenseGroup = memo(function ExpenseGroup({
month={month}
// onReorder={onReorderCategory}
onBudgetAction={onBudgetAction}
setScrollPosition={setScrollPosition}
onShowActivityWithScroll={onShowActivityWithScroll}
/>
);
})}
@@ -1458,6 +1463,8 @@ function BudgetGroups({
showBudgetedCol,
show3Cols,
showHiddenCategories,
setScrollPosition,
onShowActivityWithScroll,
}) {
const separateGroups = memoizeOne(groups => {
return {
@@ -1507,6 +1514,8 @@ function BudgetGroups({
showHiddenCategories={showHiddenCategories}
collapsed={collapsedGroupIds.includes(group.id)}
onToggleCollapse={onToggleCollapse}
setScrollPosition={setScrollPosition}
onShowActivityWithScroll={onShowActivityWithScroll}
/>
);
})}
@@ -1557,6 +1566,8 @@ export function BudgetTable({
}) {
const { width } = useResponsive();
const show3Cols = width >= 360;
const location = useLocation();
const navigate = useNavigate();
// let editMode = false; // neuter editMode -- sorry, not rewriting drag-n-drop right now
@@ -1564,6 +1575,44 @@ export function BudgetTable({
'mobile.showSpentColumn',
);
const getCurrentScrollPosition = () => {
const scrollableDiv = document.getElementById('scrollableDiv');
return scrollableDiv?.scrollTop || 0;
};
const setScrollPosition = () => {
const scrollPosition = getCurrentScrollPosition();
navigate('/budget', {
replace: true,
state: { scrollPosition }
});
};
const onShowActivityWithScroll = (categoryId, month) => {
const scrollPosition = getCurrentScrollPosition();
navigate('/budget', {
replace: true,
state: { scrollPosition }
});
navigate(`/categories/${categoryId}?month=${month}`);
};
useEffect(() => {
const savedScrollPosition = location.state?.scrollPosition;
if (savedScrollPosition) {
const scrollableDiv = document.getElementById('scrollableDiv');
if (scrollableDiv) {
requestAnimationFrame(() => {
scrollableDiv.scrollTop = savedScrollPosition;
});
}
}
}, [location.state?.scrollPosition]);
function toggleSpentColumn() {
setShowSpentColumnPref(!showSpentColumn);
}
@@ -1623,9 +1672,12 @@ export function BudgetTable({
<PullToRefresh onRefresh={onRefresh}>
<View
data-testid="budget-table"
id="scrollableDiv"
style={{
backgroundColor: theme.pageBackground,
paddingBottom: MOBILE_NAV_HEIGHT,
overflowY: 'auto',
height: '100%',
}}
>
<BudgetGroups
@@ -1647,6 +1699,8 @@ export function BudgetTable({
onReorderCategory={onReorderCategory}
onReorderGroup={onReorderGroup}
onBudgetAction={onBudgetAction}
setScrollPosition={setScrollPosition}
onShowActivityWithScroll={onShowActivityWithScroll}
/>
</View>
</PullToRefresh>

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [Crazypkr]
---
Add ability to return back to previous scroll location on Budget Table when clicking spent column to view transactions