mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 10:14:26 +08:00
show the reason why the transaction, account, and category cannot be saved on the save button in desktop version
This commit is contained in:
@@ -44,6 +44,28 @@ export function useAccountEditPageBaseBase() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const inputEmptyProblemMessage = computed<string | null>(() => {
|
||||||
|
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<boolean>(() => !!inputEmptyProblemMessage.value);
|
||||||
|
|
||||||
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories());
|
const allAccountCategories = computed<LocalizedAccountCategory[]>(() => getAllAccountCategories());
|
||||||
const allAccountTypes = computed<TypeAndDisplayName[]>(() => getAllAccountTypes());
|
const allAccountTypes = computed<TypeAndDisplayName[]>(() => getAllAccountTypes());
|
||||||
|
|
||||||
@@ -95,42 +117,6 @@ export function useAccountEditPageBaseBase() {
|
|||||||
return account.id === '' || account.id === '0';
|
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 {
|
function addSubAccount(): boolean {
|
||||||
if (account.value.type !== AccountType.MultiSubAccounts.type) {
|
if (account.value.type !== AccountType.MultiSubAccounts.type) {
|
||||||
return false;
|
return false;
|
||||||
@@ -170,6 +156,8 @@ export function useAccountEditPageBaseBase() {
|
|||||||
// computed states
|
// computed states
|
||||||
title,
|
title,
|
||||||
saveButtonTitle,
|
saveButtonTitle,
|
||||||
|
inputEmptyProblemMessage,
|
||||||
|
inputIsEmpty,
|
||||||
allAccountCategories,
|
allAccountCategories,
|
||||||
allAccountTypes,
|
allAccountTypes,
|
||||||
allAvailableMonthDays,
|
allAvailableMonthDays,
|
||||||
@@ -177,8 +165,6 @@ export function useAccountEditPageBaseBase() {
|
|||||||
// functions
|
// functions
|
||||||
getAccountCreditCardStatementDate,
|
getAccountCreditCardStatementDate,
|
||||||
isNewAccount,
|
isNewAccount,
|
||||||
isInputEmpty,
|
|
||||||
getAccountOrSubAccountProblemMessage,
|
|
||||||
addSubAccount,
|
addSubAccount,
|
||||||
setAccount
|
setAccount
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -169,10 +169,16 @@
|
|||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-text class="overflow-y-visible">
|
<v-card-text class="overflow-y-visible">
|
||||||
<div class="w-100 d-flex justify-center mt-2 mt-sm-4 mt-md-6 gap-4">
|
<div class="w-100 d-flex justify-center mt-2 mt-sm-4 mt-md-6 gap-4">
|
||||||
<v-btn :disabled="isInputEmpty() || loading || submitting" @click="save">
|
<v-tooltip :disabled="!inputIsEmpty" :text="inputEmptyProblemMessage ? tt(inputEmptyProblemMessage) : ''">
|
||||||
{{ tt(saveButtonTitle) }}
|
<template v-slot:activator="{ props }">
|
||||||
<v-progress-circular indeterminate size="22" class="ml-2" v-if="submitting"></v-progress-circular>
|
<div v-bind="props" class="d-inline-block">
|
||||||
</v-btn>
|
<v-btn :disabled="inputIsEmpty || loading || submitting" @click="save">
|
||||||
|
{{ tt(saveButtonTitle) }}
|
||||||
|
<v-progress-circular indeterminate size="22" class="ml-2" v-if="submitting"></v-progress-circular>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</v-tooltip>
|
||||||
<v-btn color="secondary" variant="tonal"
|
<v-btn color="secondary" variant="tonal"
|
||||||
:disabled="loading || submitting" @click="cancel">{{ tt('Cancel') }}</v-btn>
|
:disabled="loading || submitting" @click="cancel">{{ tt('Cancel') }}</v-btn>
|
||||||
</div>
|
</div>
|
||||||
@@ -228,13 +234,13 @@ const {
|
|||||||
subAccounts,
|
subAccounts,
|
||||||
title,
|
title,
|
||||||
saveButtonTitle,
|
saveButtonTitle,
|
||||||
|
inputEmptyProblemMessage,
|
||||||
|
inputIsEmpty,
|
||||||
allAccountCategories,
|
allAccountCategories,
|
||||||
allAccountTypes,
|
allAccountTypes,
|
||||||
allAvailableMonthDays,
|
allAvailableMonthDays,
|
||||||
isAccountSupportCreditCardStatementDate,
|
isAccountSupportCreditCardStatementDate,
|
||||||
isNewAccount,
|
isNewAccount,
|
||||||
isInputEmpty,
|
|
||||||
getAccountOrSubAccountProblemMessage,
|
|
||||||
addSubAccount,
|
addSubAccount,
|
||||||
setAccount
|
setAccount
|
||||||
} = useAccountEditPageBaseBase();
|
} = useAccountEditPageBaseBase();
|
||||||
@@ -325,7 +331,7 @@ function open(options?: { id?: string, currentAccount?: Account, category?: numb
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save(): void {
|
function save(): void {
|
||||||
const problemMessage = getAccountOrSubAccountProblemMessage();
|
const problemMessage = inputEmptyProblemMessage.value;
|
||||||
|
|
||||||
if (problemMessage) {
|
if (problemMessage) {
|
||||||
snackbar.value?.showMessage(problemMessage);
|
snackbar.value?.showMessage(problemMessage);
|
||||||
|
|||||||
@@ -79,10 +79,16 @@
|
|||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-text class="overflow-y-visible">
|
<v-card-text class="overflow-y-visible">
|
||||||
<div class="w-100 d-flex justify-center mt-2 mt-sm-4 mt-md-6 gap-4">
|
<div class="w-100 d-flex justify-center mt-2 mt-sm-4 mt-md-6 gap-4">
|
||||||
<v-btn :disabled="inputIsEmpty || loading || submitting" @click="save">
|
<v-tooltip :disabled="!inputIsEmpty" :text="inputEmptyProblemMessage ? tt(inputEmptyProblemMessage) : ''">
|
||||||
{{ tt(saveButtonTitle) }}
|
<template v-slot:activator="{ props }">
|
||||||
<v-progress-circular indeterminate size="22" class="ml-2" v-if="submitting"></v-progress-circular>
|
<div v-bind="props" class="d-inline-block">
|
||||||
</v-btn>
|
<v-btn :disabled="inputIsEmpty || loading || submitting" @click="save">
|
||||||
|
{{ tt(saveButtonTitle) }}
|
||||||
|
<v-progress-circular indeterminate size="22" class="ml-2" v-if="submitting"></v-progress-circular>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</v-tooltip>
|
||||||
<v-btn color="secondary" variant="tonal"
|
<v-btn color="secondary" variant="tonal"
|
||||||
:disabled="loading || submitting" @click="cancel">{{ tt('Cancel') }}</v-btn>
|
:disabled="loading || submitting" @click="cancel">{{ tt('Cancel') }}</v-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -418,10 +418,17 @@
|
|||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-text class="overflow-y-visible">
|
<v-card-text class="overflow-y-visible">
|
||||||
<div class="w-100 d-flex justify-center flex-wrap mt-2 mt-sm-4 mt-md-6 gap-4">
|
<div class="w-100 d-flex justify-center flex-wrap mt-2 mt-sm-4 mt-md-6 gap-4">
|
||||||
<v-btn :disabled="inputIsEmpty || loading || submitting" v-if="mode !== TransactionEditPageMode.View" @click="save">
|
<v-tooltip :disabled="!inputIsEmpty" :text="inputEmptyProblemMessage ? tt(inputEmptyProblemMessage) : ''">
|
||||||
{{ tt(saveButtonTitle) }}
|
<template v-slot:activator="{ props }">
|
||||||
<v-progress-circular indeterminate size="22" class="ml-2" v-if="submitting"></v-progress-circular>
|
<div v-bind="props" class="d-inline-block">
|
||||||
</v-btn>
|
<v-btn :disabled="inputIsEmpty || loading || submitting"
|
||||||
|
v-if="mode !== TransactionEditPageMode.View" @click="save">
|
||||||
|
{{ tt(saveButtonTitle) }}
|
||||||
|
<v-progress-circular indeterminate size="22" class="ml-2" v-if="submitting"></v-progress-circular>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</v-tooltip>
|
||||||
<v-btn-group variant="tonal" density="comfortable"
|
<v-btn-group variant="tonal" density="comfortable"
|
||||||
v-if="mode === TransactionEditPageMode.View && transaction.type !== TransactionType.ModifyBalance">
|
v-if="mode === TransactionEditPageMode.View && transaction.type !== TransactionType.ModifyBalance">
|
||||||
<v-btn :disabled="loading || submitting"
|
<v-btn :disabled="loading || submitting"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<f7-nav-title :title="tt(title)"></f7-nav-title>
|
<f7-nav-title :title="tt(title)"></f7-nav-title>
|
||||||
<f7-nav-right>
|
<f7-nav-right>
|
||||||
<f7-link icon-f7="ellipsis" :class="{ 'disabled': account.type !== AccountType.MultiSubAccounts.type }" @click="showMoreActionSheet = true"></f7-link>
|
<f7-link icon-f7="ellipsis" :class="{ 'disabled': account.type !== AccountType.MultiSubAccounts.type }" @click="showMoreActionSheet = true"></f7-link>
|
||||||
<f7-link :class="{ 'disabled': isInputEmpty() || submitting }" :text="tt(saveButtonTitle)" @click="save"></f7-link>
|
<f7-link :class="{ 'disabled': inputIsEmpty || submitting }" :text="tt(saveButtonTitle)" @click="save"></f7-link>
|
||||||
</f7-nav-right>
|
</f7-nav-right>
|
||||||
</f7-navbar>
|
</f7-navbar>
|
||||||
|
|
||||||
@@ -567,14 +567,14 @@ const {
|
|||||||
subAccounts,
|
subAccounts,
|
||||||
title,
|
title,
|
||||||
saveButtonTitle,
|
saveButtonTitle,
|
||||||
|
inputEmptyProblemMessage,
|
||||||
|
inputIsEmpty,
|
||||||
allAccountCategories,
|
allAccountCategories,
|
||||||
allAccountTypes,
|
allAccountTypes,
|
||||||
allAvailableMonthDays,
|
allAvailableMonthDays,
|
||||||
isAccountSupportCreditCardStatementDate,
|
isAccountSupportCreditCardStatementDate,
|
||||||
getAccountCreditCardStatementDate,
|
getAccountCreditCardStatementDate,
|
||||||
isNewAccount,
|
isNewAccount,
|
||||||
isInputEmpty,
|
|
||||||
getAccountOrSubAccountProblemMessage,
|
|
||||||
addSubAccount,
|
addSubAccount,
|
||||||
setAccount
|
setAccount
|
||||||
} = useAccountEditPageBaseBase();
|
} = useAccountEditPageBaseBase();
|
||||||
@@ -658,7 +658,7 @@ function init(): void {
|
|||||||
|
|
||||||
function save(): void {
|
function save(): void {
|
||||||
const router = props.f7router;
|
const router = props.f7router;
|
||||||
const problemMessage = getAccountOrSubAccountProblemMessage();
|
const problemMessage = inputEmptyProblemMessage.value;
|
||||||
|
|
||||||
if (problemMessage) {
|
if (problemMessage) {
|
||||||
showAlert(problemMessage);
|
showAlert(problemMessage);
|
||||||
|
|||||||
Reference in New Issue
Block a user