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 transactions with enter #77

Merged
merged 5 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Reset input when escape key is pressed
- Implement audit logging
- Save collapsed state of book navigation items
- Enable creation of transactions by pressing enter

## [0.26.6] - 2024-06-10

Expand Down
8 changes: 6 additions & 2 deletions src/components/NewTransactionInput.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<TransactionListItemTemplate>
<TransactionListItemTemplate @keyup.enter="handleSubmitTransactionClick()">
<template #date>
<DateInput
:date="date"
Expand Down Expand Up @@ -96,12 +96,14 @@
});

async function handleSubmitTransactionClick(): Promise<void> {
// TODO validation
if (!isValid.value) return;

await createNewTransaction();
}

async function createNewTransaction(): Promise<void> {
isLoading.value = true;

await transactionService.addTransactionWithSplits({
date: DateUtils.getDateStringForTransaction(date.value),
description: description.value,
Expand All @@ -110,7 +112,9 @@
srcAccountId: props.accountId,
destAccountId: destAccountId.value
});

isLoading.value = false;

resetFields();
}

Expand Down
9 changes: 6 additions & 3 deletions src/components/sidebar/NewTransactionSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:name="t('money', 'Info')"
id="info-tab"
:order="1"
@keyup.enter="handleCreateTransaction()"
>
<div>
<h2>{{ t('money', 'Properties') }}</h2>
Expand Down Expand Up @@ -81,7 +82,7 @@
class="self-end"
type="primary"
:wide="true"
:disabled="isLoading || NumberUtils.areEqual(value, 0.0)"
:disabled="isLoading || !isValid"
@click="handleCreateTransaction()"
>
<template #icon>
Expand All @@ -107,8 +108,6 @@
</style>

<script setup lang="ts">
import dayjs from 'dayjs';

import { translate as t } from '@nextcloud/l10n';

import { computed, ref, type Ref } from 'vue';
Expand Down Expand Up @@ -179,6 +178,8 @@
);
});

const isValid = computed(() => NumberUtils.areNotEqual(value.value, 0.0));

async function handleCloseSidebar(): Promise<void> {
await router.push({ name: 'account' });
}
Expand Down Expand Up @@ -212,6 +213,8 @@
}

async function handleCreateTransaction(): Promise<void> {
if (!isValid.value) return;

isLoading.value = true;

const result = await transactionService.addTransactionWithSplits({
Expand Down