From b7f53fb6ff1e25d5885f83ed3f9c2f3b7bff2b3d Mon Sep 17 00:00:00 2001
From: Yaroslav Ermilov <25526713+ya-erm@users.noreply.github.com>
Date: Wed, 1 May 2024 15:57:21 +0200
Subject: [PATCH 1/7] Restore scroll position after operation editing
---
src/lib/utils/getSearchParam.ts | 19 +++++---
.../accounts/GroupedOperationsList.svelte | 32 ++++++++++---
.../accounts/groupings/edit/GroupList.svelte | 2 +
.../transactions/TransactionList.svelte | 32 ++++++++++---
src/routes/transactions/edit/+page.svelte | 40 +---------------
.../transactions/edit/EditTransaction.svelte | 47 +++++++++++++++++++
.../transactions/form/AccountSelector.svelte | 2 +
.../transactions/form/TransactionForm.svelte | 2 +
8 files changed, 120 insertions(+), 56 deletions(-)
create mode 100644 src/routes/transactions/edit/EditTransaction.svelte
diff --git a/src/lib/utils/getSearchParam.ts b/src/lib/utils/getSearchParam.ts
index 3ec8792..b971bc8 100644
--- a/src/lib/utils/getSearchParam.ts
+++ b/src/lib/utils/getSearchParam.ts
@@ -1,4 +1,4 @@
-import { replaceState } from '$app/navigation';
+import { goto } from '$app/navigation';
import type { Page } from '@sveltejs/kit';
export function getNumberSearchParam(page: Page, name: string) {
@@ -9,12 +9,19 @@ export function getSearchParam(page: Page, name: string) {
return page.url.searchParams.get(name);
}
-export async function setSearchParam(page: Page, name: string, value: string) {
- page.url.searchParams.set(name, value);
- replaceState(page.url, page.state);
+export async function setSearchParam(
+ page: Page,
+ name: string,
+ value: string,
+ { replace }: { replace: boolean } = { replace: true },
+) {
+ const searchParams = new URLSearchParams(page.url.searchParams);
+ searchParams.set(name, value);
+ await goto(`?${searchParams.toString()}`, { replaceState: replace });
}
export async function deleteSearchParam(page: Page, name: string) {
- page.url.searchParams.delete(name);
- replaceState(page.url, page.state);
+ const searchParams = new URLSearchParams(page.url.searchParams);
+ searchParams.delete(name);
+ await goto(`?${searchParams.toString()}`, { replaceState: true });
}
diff --git a/src/routes/accounts/GroupedOperationsList.svelte b/src/routes/accounts/GroupedOperationsList.svelte
index 2beedc1..ea18bac 100644
--- a/src/routes/accounts/GroupedOperationsList.svelte
+++ b/src/routes/accounts/GroupedOperationsList.svelte
@@ -1,12 +1,17 @@
@@ -37,13 +42,28 @@
handleTransactionClick(transaction.id)}
+ onClick={() => openOperationForm(transaction.id)}
{transaction}
/>
{/each}
{/each}
+
+
+
+
+
+
From ab07ec1f81039d608ff3c595e53db4ea9b1dfd14 Mon Sep 17 00:00:00 2001
From: Yaroslav Ermilov <25526713+ya-erm@users.noreply.github.com>
Date: Tue, 7 May 2024 20:50:17 +0200
Subject: [PATCH 5/7] Fix input focus in transaction form
---
src/routes/transactions/form/TransactionForm.svelte | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/routes/transactions/form/TransactionForm.svelte b/src/routes/transactions/form/TransactionForm.svelte
index 6137480..cc31b9d 100644
--- a/src/routes/transactions/form/TransactionForm.svelte
+++ b/src/routes/transactions/form/TransactionForm.svelte
@@ -177,8 +177,10 @@
bind:categoryId
categories={categories.filter((c) => c.type === type)}
onChange={() => {
- inputRef?.focus({ preventScroll: true });
- inputRef?.scrollIntoView({ behavior: 'smooth' });
+ if (!inputRef?.value) {
+ inputRef?.focus({ preventScroll: true });
+ inputRef?.scrollIntoView({ behavior: 'smooth' });
+ }
}}
/>
{/if}
From cb272f87c9d7406dbb6c0fbf82683529850e7673 Mon Sep 17 00:00:00 2001
From: Yaroslav Ermilov <25526713+ya-erm@users.noreply.github.com>
Date: Tue, 7 May 2024 20:58:06 +0200
Subject: [PATCH 6/7] Autofill destination amount input for same-currency
transfers
---
src/routes/transactions/form/TransactionForm.svelte | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/routes/transactions/form/TransactionForm.svelte b/src/routes/transactions/form/TransactionForm.svelte
index cc31b9d..f6f308d 100644
--- a/src/routes/transactions/form/TransactionForm.svelte
+++ b/src/routes/transactions/form/TransactionForm.svelte
@@ -68,6 +68,8 @@
$: accountCurrency = accounts.find(({ id }) => id === accountId)?.currency;
$: destinationAccountCurrency = accounts.find(({ id }) => id === destinationAccountId)?.currency;
+ let destinationAmountTouched = false;
+
let _value1 = (isTransfer ? sourceTransaction?.amount : transaction?.amount)?.toString() ?? '';
let _value2 = destinationTransaction?.amount?.toString() ?? transaction?.anotherCurrencyAmount?.toString() ?? '';
$: _rate = Number(_value1) / Number(_value2);
@@ -238,6 +240,11 @@
inputmode="decimal"
bind:ref={inputRef}
bind:value={_value1}
+ onChange={(value) => {
+ if (type === 'TRANSFER' && accountCurrency === destinationAccountCurrency && !destinationAmountTouched) {
+ _value2 = value;
+ }
+ }}
endText={accountCurrency}
required
/>
@@ -248,6 +255,9 @@
inputmode="decimal"
bind:value={_value2}
endText={destinationAccountCurrency || anotherCurrency}
+ onChange={(value) => {
+ destinationAmountTouched = !!value;
+ }}
required
/>
{/if}
From d857878ccd68313510cfb6c6b15641456726da3a Mon Sep 17 00:00:00 2001
From: Yaroslav Ermilov <25526713+ya-erm@users.noreply.github.com>
Date: Tue, 7 May 2024 21:02:13 +0200
Subject: [PATCH 7/7] Version 2.8.5
---
package-lock.json | 4 ++--
package.json | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 778bd5d..4f46ef8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "client",
- "version": "2.8.4",
+ "version": "2.8.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "client",
- "version": "2.8.4",
+ "version": "2.8.5",
"dependencies": {
"@prisma/client": "^5.13.0",
"@vercel/analytics": "^1.2.2",
diff --git a/package.json b/package.json
index 66e3e75..8a1cd71 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "client",
- "version": "2.8.4",
+ "version": "2.8.5",
"private": true,
"scripts": {
"dev": "vite dev",