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

Reorder transactions of same date #1603

Closed

Conversation

joel-jeremy
Copy link
Contributor

Resolves #1165

@netlify
Copy link

netlify bot commented Aug 29, 2023

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 5f77347
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/65a19607b4187600081556dd
😎 Deploy Preview https://deploy-preview-1603.demo.actualbudget.org/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2023

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
10 5.07 MB → 5.08 MB (+4.92 kB) +0.09%
Changeset
File Δ Size
src/components/transactions/TransactionList.jsx 📈 +1.64 kB (+39.97%) 4.11 kB → 5.75 kB
src/components/transactions/TransactionsTable.jsx 📈 +3.13 kB (+6.00%) 52.19 kB → 55.32 kB
src/components/accounts/Account.jsx 📈 +156 B (+0.39%) 39.06 kB → 39.21 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
static/js/index-BHxW5TjR.js 0 B → 2.63 MB (+2.63 MB) -
static/js/ReportRouter-ZTw6xeGU.js 0 B → 1.94 MB (+1.94 MB) -
static/js/wide-1bNFr1LF.js 0 B → 241.22 kB (+241.22 kB) -
static/js/BackgroundImage-nXzNzoFw.js 0 B → 122.29 kB (+122.29 kB) -
static/js/narrow-8KYRZMfi.js 0 B → 82.17 kB (+82.17 kB) -
static/js/FiltersMenu-zS9C0D2Y.js 0 B → 28.92 kB (+28.92 kB) -
static/js/BalanceTooltip-V-H4EbWt.js 0 B → 6.07 kB (+6.07 kB) -
static/js/ButtonLink-seatSfDy.js 0 B → 379 B (+379 B) -

Removed

Asset File Size % Changed
static/js/index-J-HRzf7W.js 2.63 MB → 0 B (-2.63 MB) -100%
static/js/ReportRouter-kHvxuvO-.js 1.94 MB → 0 B (-1.94 MB) -100%
static/js/wide-igRhAA-f.js 236.3 kB → 0 B (-236.3 kB) -100%
static/js/BackgroundImage-V1jYm3hh.js 122.29 kB → 0 B (-122.29 kB) -100%
static/js/narrow-v240ErwI.js 82.17 kB → 0 B (-82.17 kB) -100%
static/js/FiltersMenu-4QE4ezd2.js 28.92 kB → 0 B (-28.92 kB) -100%
static/js/BalanceTooltip-MQNa0IKd.js 6.07 kB → 0 B (-6.07 kB) -100%
static/js/ButtonLink-X4dED4fm.js 379 B → 0 B (-379 B) -100%

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74-bhyX5Ad6.js 13.5 kB 0%
static/js/resize-observer-6FaCDon1.js 18.37 kB 0%

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2023

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.23 MB → 1.24 MB (+1.17 kB) +0.09%
Changeset
File Δ Size
packages/loot-core/src/server/accounts/transactions.ts 📈 +525 B (+9.50%) 5.4 kB → 5.91 kB
packages/loot-core/src/server/db/index.ts 📈 +1.57 kB (+9.00%) 17.47 kB → 19.04 kB
packages/loot-core/src/server/db/sort.ts 📈 +76 B (+4.06%) 1.83 kB → 1.9 kB
packages/loot-core/src/server/main.ts 📈 +265 B (+0.41%) 63.67 kB → 63.93 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.23 MB → 1.24 MB (+1.17 kB) +0.09%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@joel-jeremy joel-jeremy force-pushed the sortable-transactions branch from 866571b to 96945da Compare August 30, 2023 14:41
Copy link
Member

@MatissJanis MatissJanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me. Also not finding any obvious bugs.

Let me know what you think about the comments

@@ -28,6 +28,8 @@ export interface ServerHandlers {

'transaction-delete': (transaction) => Promise<EmptyObject>;

'transaction-move': (arg: { id; accountId; targetId }) => Promise<unknown>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥜 nitpick: ‏ideally we shouldn't use unknown and any types for new code we add.

Comment on lines 367 to 375
if (
query.state.orderExpressions &&
query.state.orderExpressions.length > 0
) {
// If there are no order expressions in the query,
// transactions are sorted by sort_order by default.
// In case there are order expressions, let's add back
// the sort_order sorting so that transactions still
// maintain the correct order.
query = query.orderBy({ sort_order: 'desc' });
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ question: ‏should this logic also be added to mobile account component? And if yes: any way we could unify it so we don't have duplicate sorting logic?

(I don't mean actually implementing FULL drag-n-drop support on mobile; just that the list is ordered the same order on both desktop and mobile)

accountId: trans.account,
targetId: sort.targetId,
});
onRefetch();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ question: ‏why do we need to refetch after sorting?

onExpose={name => !isPreview && onEdit(id, name)}
onUpdate={value => {
onUpdate('date', value);
}}
unexposedContent={
<View innerRef={dragRef}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion: ‏adding drag handler to only the date column makes the functionality pretty hidden. What do you think about adding a drag-handler at the beginning of the row?

For example: this is what gmail used to do

Comment on lines 622 to 639
const lastTransaction = await first(
'SELECT sort_order FROM v_transactions ' +
'WHERE date = ? AND is_child <> 1 AND parent_id IS NULL ' +
'ORDER BY sort_order DESC LIMIT 1',
[transaction.date.replace(/-/g, '')], // Remove hyphens
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 thought: ‏this could potentially be a pretty expensive SQL query. Especially for bigger databases.

Do we really need the last transactions sort_order when creating a new transaction? Could we just set it to 99999 or something like that? And then change sorting from sort_by:sort_order to sort_by:sort_order,insertion_id (i.e. two index sorting).

WDYT?

Comment on lines 650 to 663
'SELECT vt.id, vt.sort_order FROM v_transactions vt WHERE vt.account = ? ' +
'AND vt.date = (SELECT vt2.date FROM v_transactions vt2 WHERE vt2.id = ? LIMIT 1) ORDER BY sort_order',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥜 nitpick: ‏if you use ` symbol - you can write multi line strings.

@shaankhosla
Copy link
Contributor

This is awesome, it'll definitely be really useful to be able to drag transactions around. I thought of two enhancements, but these likely should be in a future PR/issue:

  1. Indicating on hover what part of the entry is draggable, I accidentally kept clicking anywhere on the entry (like near the payee) and trying to drag.
  2. The blue lines that appear indicating where the entry would be placed when the drag is released is good. However, when you drag a transaction to another date it still appears, making it seem like you can drag a transaction from one day to another.

@github-actions
Copy link
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@youngcw
Copy link
Member

youngcw commented Oct 14, 2023

I agree that it would be nice to not show the blue lines on places that the transaction cant be dropped.

Im not sure if a visual indicator is needed considering that we expect people to find the reorder functionality on the budget page without an indicator. It works pretty similar where only the far left item can be grabbed to move the line.

@youngcw
Copy link
Member

youngcw commented Nov 9, 2023

@joel-jeremy What is left on this?

@joel-jeremy joel-jeremy force-pushed the sortable-transactions branch from 96945da to 50e63ea Compare December 6, 2023 05:58
@Jackenmen
Copy link
Contributor

Would it be possible to make it work on the "All accounts" view as well?

@joel-jeremy joel-jeremy force-pushed the sortable-transactions branch from 50e63ea to 5c8ebff Compare January 12, 2024 17:44
Copy link
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Mar 17, 2024
Copy link
Contributor

This PR was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Reorder transactions of the same date
5 participants