Skip to content

Commit

Permalink
Consider account sort order in autocomplete (actualbudget#2896)
Browse files Browse the repository at this point in the history
* Consider account sort order in autocomplete

* Add release notes
  • Loading branch information
dymanoid authored Jun 18, 2024
1 parent 8832c2b commit 7bb0425
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,12 @@ export function AccountAutocomplete({
.filter(item => {
return includeClosedAccounts ? item : !item.closed;
})
.sort((a, b) => {
if (a.closed === b.closed) {
return a.offbudget === b.offbudget ? 0 : a.offbudget ? 1 : -1;
} else {
return a.closed ? 1 : -1;
}
});
.sort(
(a, b) =>
a.closed - b.closed ||
a.offbudget - b.offbudget ||
a.sort_order - b.sort_order,
);

return (
<Autocomplete
Expand Down
1 change: 1 addition & 0 deletions packages/loot-core/src/client/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,6 @@ export function moveAccount(id, targetId) {
return async (dispatch: Dispatch) => {
await send('account-move', { id, targetId });
dispatch(getAccounts());
dispatch(getPayees());
};
}
2 changes: 1 addition & 1 deletion packages/loot-core/src/server/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ export function getPayees() {
SELECT p.*, COALESCE(a.name, p.name) AS name FROM payees p
LEFT JOIN accounts a ON (p.transfer_acct = a.id AND a.tombstone = 0)
WHERE p.tombstone = 0 AND (p.transfer_acct IS NULL OR a.id IS NOT NULL)
ORDER BY p.transfer_acct IS NULL DESC, p.name COLLATE NOCASE
ORDER BY p.transfer_acct IS NULL DESC, p.name COLLATE NOCASE, a.offbudget, a.sort_order
`);
}

Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2896.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [dymanoid]
---

Respect the user-defined account sort order in all autocomplete lists.

0 comments on commit 7bb0425

Please sign in to comment.