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 filtering of group name to autocomplete for transactions #2861

Merged
merged 38 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2476e45
Delete packages/desktop-client/e2e directory
Crazypkr1099 Jun 7, 2024
bbec585
Delete packages/desktop-client/e2e directory
Crazypkr1099 Jun 7, 2024
d9570dc
Add toggleable option to autoCompleteCategories
Crazypkr1099 Jun 9, 2024
6d6c9fb
Merge branch 'master' into autoCompleteCategories
Crazypkr1099 Jun 9, 2024
341993d
Create 2861.md
Crazypkr1099 Jun 9, 2024
f451dc6
Fixing typescript error & removing console.log
Crazypkr1099 Jun 9, 2024
0efa14d
Merge branch 'autoCompleteCategories' of https://github.com/Crazypkr1…
Crazypkr1099 Jun 9, 2024
65b7083
Added themesetting back in
Crazypkr1099 Jun 9, 2024
654f1bc
Added filtering and separation for group name autocomplete
Crazypkr1099 Jun 11, 2024
4247932
Merge branch 'master' into autoCompleteCategories
Crazypkr1099 Jun 11, 2024
0011172
removed typescript error
Crazypkr1099 Jun 11, 2024
117e381
Merge branch 'autoCompleteCategories' of https://github.com/Crazypkr1…
Crazypkr1099 Jun 11, 2024
36e9604
another typescript error fixed
Crazypkr1099 Jun 11, 2024
3b1c8b1
ts error
Crazypkr1099 Jun 11, 2024
7ee65b4
removed styling
Crazypkr1099 Jun 11, 2024
e3745b0
Update 2861.md
Crazypkr1099 Jun 11, 2024
de439af
Update prefs.d.ts
Crazypkr1099 Jun 11, 2024
3106cf4
Update index.tsx
Crazypkr1099 Jun 11, 2024
ade7a45
Update index.tsx
Crazypkr1099 Jun 11, 2024
b00a02a
removed toggleablesettings
Crazypkr1099 Jun 12, 2024
863493e
Merge branch 'autoCompleteCategories' of https://github.com/Crazypkr1…
Crazypkr1099 Jun 12, 2024
d555cc2
Merge branch 'master' into autoCompleteCategories
Crazypkr1099 Jun 12, 2024
0b28d76
changed test tobe items = screen
Crazypkr1099 Jun 12, 2024
b52604f
Merge branch 'autoCompleteCategories' of https://github.com/Crazypkr1…
Crazypkr1099 Jun 12, 2024
a889c62
removed isChanged passdown
Crazypkr1099 Jun 15, 2024
88e5117
Merge branch 'master' into autoCompleteCategories
Crazypkr1099 Jun 17, 2024
2c057ec
Added string followed by category name capability, moved sorting logi…
Crazypkr1099 Jun 18, 2024
27646f4
Fix unnecessary changes
Crazypkr1099 Jun 18, 2024
7899853
Apply suggestions from code review
Crazypkr1099 Jun 18, 2024
4945d4e
Merge branch 'master' into autoCompleteCategories
Crazypkr1099 Jun 18, 2024
2337a81
Fixed TS, sort, and memo to useCallback
Crazypkr1099 Jun 18, 2024
9beb69f
Merge branch 'master' into autoCompleteCategories
Crazypkr1099 Jun 18, 2024
b5c40e7
fix tosorted -> sort
Crazypkr1099 Jun 18, 2024
f042e4f
Merge branch 'autoCompleteCategories' of https://github.com/Crazypkr1…
Crazypkr1099 Jun 18, 2024
527dd78
Apply suggestions from code review
Crazypkr1099 Jun 18, 2024
32a4ecd
fix typescript issue
Crazypkr1099 Jun 18, 2024
5ed189f
Merge branch 'autoCompleteCategories' of https://github.com/Crazypkr1…
Crazypkr1099 Jun 18, 2024
63dafb9
Merge branch 'master' into autoCompleteCategories
Crazypkr1099 Jun 18, 2024
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 @@ -302,6 +302,27 @@ function SingleAutocomplete<T extends Item>({

const filtered = isChanged ? filteredSuggestions || suggestions : suggestions;

function customSort(obj, value) {
const name = obj.name.toLowerCase();
const groupName = obj.group ? obj.group.name.toLowerCase() : '';
value = value.toLowerCase();

if (obj.id === 'split') {
return -2;
}
if (name.includes(value)) {
return -1;
}
if (groupName.includes(value)) {
return 0;
}
return 1;
}

if (isChanged) {
filtered.sort((a, b) => customSort(a, value) - customSort(b, value));
}
Crazypkr1099 marked this conversation as resolved.
Show resolved Hide resolved

return (
<Downshift
onSelect={(item, { inputValue }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ function CategoryList({
showBalances,
}: CategoryListProps) {
let lastGroup: string | undefined | null = null;

Crazypkr1099 marked this conversation as resolved.
Show resolved Hide resolved
const filteredItems = useMemo(
() =>
showHiddenItems
? items
: items.filter(item => !item.hidden && !item.group?.hidden),
[showHiddenItems, items],
);

return (
<View>
<View
Expand All @@ -100,6 +98,7 @@ function CategoryList({
const showGroup = item.cat_group !== lastGroup;
const groupName = `${item.group?.name}${item.group?.hidden ? ' (hidden)' : ''}`;
lastGroup = item.cat_group;

return (
<Fragment key={item.id}>
{showGroup && item.group?.name && (
Expand All @@ -121,7 +120,9 @@ function CategoryList({
embedded,
style: {
...(showHiddenItems &&
item.hidden && { color: theme.pageTextSubdued }),
item.hidden && {
color: theme.pageTextSubdued,
}),
Crazypkr1099 marked this conversation as resolved.
Show resolved Hide resolved
},
showBalances,
})}
Expand Down Expand Up @@ -201,24 +202,29 @@ export function CategoryAutocomplete({
return suggestions.filter(suggestion => {
return (
suggestion.id === 'split' ||
suggestion.group?.name
.toLowerCase()
.includes(value.toLowerCase()) ||
defaultFilterSuggestion(suggestion, value)
);
});
}}
suggestions={categorySuggestions}
renderItems={(items, getItemProps, highlightedIndex) => (
<CategoryList
items={items}
embedded={embedded}
getItemProps={getItemProps}
highlightedIndex={highlightedIndex}
renderSplitTransactionButton={renderSplitTransactionButton}
renderCategoryItemGroupHeader={renderCategoryItemGroupHeader}
renderCategoryItem={renderCategoryItem}
showHiddenItems={showHiddenCategories}
showBalances={showBalances}
/>
)}
renderItems={(items, getItemProps, highlightedIndex) => {
return (
Crazypkr1099 marked this conversation as resolved.
Show resolved Hide resolved
<CategoryList
items={items}
embedded={embedded}
getItemProps={getItemProps}
highlightedIndex={highlightedIndex}
renderSplitTransactionButton={renderSplitTransactionButton}
renderCategoryItemGroupHeader={renderCategoryItemGroupHeader}
renderCategoryItem={renderCategoryItem}
showHiddenItems={showHiddenCategories}
showBalances={showBalances}
/>
);
}}
Crazypkr1099 marked this conversation as resolved.
Show resolved Hide resolved
{...props}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ describe('Transactions', () => {
items = screen
.getByTestId('autocomplete')
.querySelectorAll('[data-testid$="category-item"]');
expect(items.length).toBe(0);
expect(items.length).toBe(3);
});

test('dropdown selects an item with keyboard', async () => {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2861.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Features
Crazypkr1099 marked this conversation as resolved.
Show resolved Hide resolved
authors: [Crazypkr]
---

Add autocomplete to include categories underneath the prioritized subcategory
Loading