From 3b29303237301b32875520f7c187f8ef2062d806 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 4 Aug 2025 21:39:58 +0800 Subject: [PATCH] show the reason why the transaction, account, and category cannot be saved on the save button in desktop version --- .../base/accounts/AccountEditPageBase.ts | 62 +++++++------------ .../accounts/list/dialogs/EditDialog.vue | 20 +++--- .../categories/list/dialogs/EditDialog.vue | 14 +++-- .../transactions/list/dialogs/EditDialog.vue | 15 +++-- src/views/mobile/accounts/EditPage.vue | 8 +-- 5 files changed, 62 insertions(+), 57 deletions(-) diff --git a/src/views/base/accounts/AccountEditPageBase.ts b/src/views/base/accounts/AccountEditPageBase.ts index 93db9707..e96ddc99 100644 --- a/src/views/base/accounts/AccountEditPageBase.ts +++ b/src/views/base/accounts/AccountEditPageBase.ts @@ -44,6 +44,28 @@ export function useAccountEditPageBaseBase() { } }); + const inputEmptyProblemMessage = computed(() => { + let problemMessage = getInputEmptyProblemMessage(account.value, false); + + if (problemMessage) { + return problemMessage; + } + + if (account.value.type === AccountType.MultiSubAccounts.type) { + for (let i = 0; i < subAccounts.value.length; i++) { + problemMessage = getInputEmptyProblemMessage(subAccounts.value[i], true); + + if (problemMessage) { + return problemMessage; + } + } + } + + return null; + }); + + const inputIsEmpty = computed(() => !!inputEmptyProblemMessage.value); + const allAccountCategories = computed(() => getAllAccountCategories()); const allAccountTypes = computed(() => getAllAccountTypes()); @@ -95,42 +117,6 @@ export function useAccountEditPageBaseBase() { return account.id === '' || account.id === '0'; } - function isInputEmpty(): boolean { - const isAccountEmpty = !!getInputEmptyProblemMessage(account.value, false); - - if (isAccountEmpty) { - return true; - } - - if (account.value.type === AccountType.MultiSubAccounts.type) { - for (let i = 0; i < subAccounts.value.length; i++) { - const isSubAccountEmpty = !!getInputEmptyProblemMessage(subAccounts.value[i], true); - - if (isSubAccountEmpty) { - return true; - } - } - } - - return false; - } - - function getAccountOrSubAccountProblemMessage(): string | null { - let problemMessage = getInputEmptyProblemMessage(account.value, false); - - if (!problemMessage && account.value.type === AccountType.MultiSubAccounts.type) { - for (let i = 0; i < subAccounts.value.length; i++) { - problemMessage = getInputEmptyProblemMessage(subAccounts.value[i], true); - - if (problemMessage) { - break; - } - } - } - - return problemMessage; - } - function addSubAccount(): boolean { if (account.value.type !== AccountType.MultiSubAccounts.type) { return false; @@ -170,6 +156,8 @@ export function useAccountEditPageBaseBase() { // computed states title, saveButtonTitle, + inputEmptyProblemMessage, + inputIsEmpty, allAccountCategories, allAccountTypes, allAvailableMonthDays, @@ -177,8 +165,6 @@ export function useAccountEditPageBaseBase() { // functions getAccountCreditCardStatementDate, isNewAccount, - isInputEmpty, - getAccountOrSubAccountProblemMessage, addSubAccount, setAccount }; diff --git a/src/views/desktop/accounts/list/dialogs/EditDialog.vue b/src/views/desktop/accounts/list/dialogs/EditDialog.vue index 35aa83af..e6bf103c 100644 --- a/src/views/desktop/accounts/list/dialogs/EditDialog.vue +++ b/src/views/desktop/accounts/list/dialogs/EditDialog.vue @@ -169,10 +169,16 @@
- - {{ tt(saveButtonTitle) }} - - + + + {{ tt('Cancel') }}
@@ -228,13 +234,13 @@ const { subAccounts, title, saveButtonTitle, + inputEmptyProblemMessage, + inputIsEmpty, allAccountCategories, allAccountTypes, allAvailableMonthDays, isAccountSupportCreditCardStatementDate, isNewAccount, - isInputEmpty, - getAccountOrSubAccountProblemMessage, addSubAccount, setAccount } = useAccountEditPageBaseBase(); @@ -325,7 +331,7 @@ function open(options?: { id?: string, currentAccount?: Account, category?: numb } function save(): void { - const problemMessage = getAccountOrSubAccountProblemMessage(); + const problemMessage = inputEmptyProblemMessage.value; if (problemMessage) { snackbar.value?.showMessage(problemMessage); diff --git a/src/views/desktop/categories/list/dialogs/EditDialog.vue b/src/views/desktop/categories/list/dialogs/EditDialog.vue index c5acf871..877d50bf 100644 --- a/src/views/desktop/categories/list/dialogs/EditDialog.vue +++ b/src/views/desktop/categories/list/dialogs/EditDialog.vue @@ -79,10 +79,16 @@
- - {{ tt(saveButtonTitle) }} - - + + + {{ tt('Cancel') }}
diff --git a/src/views/desktop/transactions/list/dialogs/EditDialog.vue b/src/views/desktop/transactions/list/dialogs/EditDialog.vue index 3e576d53..3b038d84 100644 --- a/src/views/desktop/transactions/list/dialogs/EditDialog.vue +++ b/src/views/desktop/transactions/list/dialogs/EditDialog.vue @@ -418,10 +418,17 @@
- - {{ tt(saveButtonTitle) }} - - + + + - + @@ -567,14 +567,14 @@ const { subAccounts, title, saveButtonTitle, + inputEmptyProblemMessage, + inputIsEmpty, allAccountCategories, allAccountTypes, allAvailableMonthDays, isAccountSupportCreditCardStatementDate, getAccountCreditCardStatementDate, isNewAccount, - isInputEmpty, - getAccountOrSubAccountProblemMessage, addSubAccount, setAccount } = useAccountEditPageBaseBase(); @@ -658,7 +658,7 @@ function init(): void { function save(): void { const router = props.f7router; - const problemMessage = getAccountOrSubAccountProblemMessage(); + const problemMessage = inputEmptyProblemMessage.value; if (problemMessage) { showAlert(problemMessage);