mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
migrate to typescript
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
||||
<f7-nav-title :title="$t(title)"></f7-nav-title>
|
||||
<f7-nav-right>
|
||||
<f7-link icon-f7="ellipsis" :class="{ 'disabled': editAccountId || account.type !== allAccountTypes.MultiSubAccounts }" @click="showMoreActionSheet = true"></f7-link>
|
||||
<f7-link icon-f7="ellipsis" :class="{ 'disabled': editAccountId || account.type !== allAccountTypes.MultiSubAccounts.type }" @click="showMoreActionSheet = true"></f7-link>
|
||||
<f7-link :class="{ 'disabled': isInputEmpty() || submitting }" :text="$t(saveButtonTitle)" @click="save"></f7-link>
|
||||
</f7-nav-right>
|
||||
</f7-navbar>
|
||||
@@ -23,7 +23,7 @@
|
||||
@click="showAccountCategorySheet = true"
|
||||
>
|
||||
<list-item-selection-sheet value-type="item"
|
||||
key-field="id" value-field="id" title-field="displayName"
|
||||
key-field="type" value-field="type" title-field="displayName"
|
||||
icon-field="defaultAccountIconId" icon-type="account"
|
||||
:items="allAccountCategories"
|
||||
v-model:show="showAccountCategorySheet"
|
||||
@@ -40,7 +40,7 @@
|
||||
@click="showAccountTypeSheet = true"
|
||||
>
|
||||
<list-item-selection-sheet value-type="item"
|
||||
key-field="id" value-field="id" title-field="displayName"
|
||||
key-field="type" value-field="type" title-field="displayName"
|
||||
:items="allAccountTypesArray"
|
||||
v-model:show="showAccountTypeSheet"
|
||||
v-model="account.type">
|
||||
@@ -94,7 +94,7 @@
|
||||
<f7-list-input label="Description" type="textarea" placeholder="Your account description (optional)"></f7-list-input>
|
||||
</f7-list>
|
||||
|
||||
<f7-list form strong inset dividers class="margin-vertical" v-else-if="!loading && account.type === allAccountTypes.SingleAccount">
|
||||
<f7-list form strong inset dividers class="margin-vertical" v-else-if="!loading && account.type === allAccountTypes.SingleAccount.type">
|
||||
<f7-list-input
|
||||
type="text"
|
||||
clear-button
|
||||
@@ -237,7 +237,7 @@
|
||||
></f7-list-input>
|
||||
</f7-list>
|
||||
|
||||
<f7-list form strong inset dividers class="margin-vertical" v-else-if="!loading && account.type === allAccountTypes.MultiSubAccounts">
|
||||
<f7-list form strong inset dividers class="margin-vertical" v-else-if="!loading && account.type === allAccountTypes.MultiSubAccounts.type">
|
||||
<f7-list-input
|
||||
type="text"
|
||||
clear-button
|
||||
@@ -324,7 +324,7 @@
|
||||
></f7-list-input>
|
||||
</f7-list>
|
||||
|
||||
<f7-block class="no-padding no-margin" v-if="!loading && account.type === allAccountTypes.MultiSubAccounts">
|
||||
<f7-block class="no-padding no-margin" v-if="!loading && account.type === allAccountTypes.MultiSubAccounts.type">
|
||||
<f7-list strong inset dividers class="subaccount-edit-list margin-vertical"
|
||||
:key="idx"
|
||||
v-for="(subAccount, idx) in subAccounts">
|
||||
@@ -493,12 +493,12 @@ import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
import { useAccountsStore } from '@/stores/account.js';
|
||||
|
||||
import accountConstants from '@/consts/account.js';
|
||||
import iconConstants from '@/consts/icon.js';
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import transactionConstants from '@/consts/transaction.js';
|
||||
import { getNameByKeyValue } from '@/lib/common.js';
|
||||
import { generateRandomUUID } from '@/lib/misc.js';
|
||||
import { AccountType, AccountCategory } from '@/core/account.ts';
|
||||
import { ALL_ACCOUNT_ICONS } from '@/consts/icon.ts';
|
||||
import { ALL_ACCOUNT_COLORS } from '@/consts/color.ts';
|
||||
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
|
||||
import { getNameByKeyValue } from '@/lib/common.ts';
|
||||
import { generateRandomUUID } from '@/lib/misc.ts';
|
||||
import {
|
||||
setAccountModelByAnotherAccount,
|
||||
setAccountSuitableIcon
|
||||
@@ -555,7 +555,7 @@ export default {
|
||||
}
|
||||
},
|
||||
allAccountTypes() {
|
||||
return accountConstants.allAccountTypes;
|
||||
return AccountType.all();
|
||||
},
|
||||
allAccountCategories() {
|
||||
return this.$locale.getAllAccountCategories();
|
||||
@@ -564,10 +564,10 @@ export default {
|
||||
return this.$locale.getAllAccountTypes();
|
||||
},
|
||||
allAccountIcons() {
|
||||
return iconConstants.allAccountIcons;
|
||||
return ALL_ACCOUNT_ICONS;
|
||||
},
|
||||
allAccountColors() {
|
||||
return colorConstants.allAccountColors;
|
||||
return ALL_ACCOUNT_COLORS;
|
||||
},
|
||||
allCurrencies() {
|
||||
return this.$locale.getAllCurrencies();
|
||||
@@ -590,10 +590,10 @@ export default {
|
||||
return allAvailableDays;
|
||||
},
|
||||
allowedMinAmount() {
|
||||
return transactionConstants.minAmountNumber;
|
||||
return TRANSACTION_MIN_AMOUNT;
|
||||
},
|
||||
allowedMaxAmount() {
|
||||
return transactionConstants.maxAmountNumber;
|
||||
return TRANSACTION_MAX_AMOUNT;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -654,7 +654,7 @@ export default {
|
||||
this.$routeBackOnError(this.f7router, 'loadingError');
|
||||
},
|
||||
addSubAccount() {
|
||||
if (this.account.type !== this.allAccountTypes.MultiSubAccounts) {
|
||||
if (this.account.type !== this.allAccountTypes.MultiSubAccounts.type) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -694,7 +694,7 @@ export default {
|
||||
|
||||
let problemMessage = self.getInputEmptyProblemMessage(self.account, false);
|
||||
|
||||
if (!problemMessage && self.account.type === self.allAccountTypes.MultiSubAccounts) {
|
||||
if (!problemMessage && self.account.type === self.allAccountTypes.MultiSubAccounts.type) {
|
||||
for (let i = 0; i < self.subAccounts.length; i++) {
|
||||
problemMessage = self.getInputEmptyProblemMessage(self.subAccounts[i], true);
|
||||
|
||||
@@ -745,10 +745,10 @@ export default {
|
||||
return this.$locale.getCurrencyName(currencyCode);
|
||||
},
|
||||
getAccountTypeName(accountType) {
|
||||
return getNameByKeyValue(this.allAccountTypesArray, accountType, 'id', 'displayName');
|
||||
return getNameByKeyValue(this.allAccountTypesArray, accountType, 'type', 'displayName');
|
||||
},
|
||||
getAccountCategoryName(accountCategory) {
|
||||
return getNameByKeyValue(this.allAccountCategories, accountCategory, 'id', 'displayName');
|
||||
return getNameByKeyValue(this.allAccountCategories, accountCategory, 'type', 'displayName');
|
||||
},
|
||||
getAccountCreditCardStatementDate(statementDate) {
|
||||
return getNameByKeyValue(this.allAvailableMonthDays, statementDate, 'day', 'displayName');
|
||||
@@ -766,7 +766,7 @@ export default {
|
||||
return this.$locale.formatAmountWithCurrency(this.settingsStore, this.userStore, value, currencyCode);
|
||||
},
|
||||
isAccountSupportCreditCardStatementDate() {
|
||||
return this.account && this.account.category === accountConstants.creditCardCategoryType;
|
||||
return this.account && this.account.category === AccountCategory.CreditCard.type;
|
||||
},
|
||||
chooseSuitableIcon(oldCategory, newCategory) {
|
||||
setAccountSuitableIcon(this.account, oldCategory, newCategory);
|
||||
@@ -778,7 +778,7 @@ export default {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.account.type === this.allAccountTypes.MultiSubAccounts) {
|
||||
if (this.account.type === this.allAccountTypes.MultiSubAccounts.type) {
|
||||
for (let i = 0; i < this.subAccounts.length; i++) {
|
||||
const isSubAccountEmpty = !!this.getInputEmptyProblemMessage(this.subAccounts[i], true);
|
||||
|
||||
@@ -797,7 +797,7 @@ export default {
|
||||
return 'Account type cannot be blank';
|
||||
} else if (!account.name) {
|
||||
return 'Account name cannot be blank';
|
||||
} else if (account.type === this.allAccountTypes.SingleAccount && !account.currency) {
|
||||
} else if (account.type === this.allAccountTypes.SingleAccount.type && !account.currency) {
|
||||
return 'Account currency cannot be blank';
|
||||
} else {
|
||||
return null;
|
||||
|
||||
@@ -38,8 +38,9 @@
|
||||
</f7-card-header>
|
||||
</f7-card>
|
||||
|
||||
<div class="skeleton-text" :key="listIdx" v-for="listIdx in [ 1, 2, 3 ]" v-if="loading">
|
||||
<f7-list strong inset dividers sortable class="list-has-group-title account-list margin-vertical">
|
||||
<div class="skeleton-text" v-if="loading">
|
||||
<f7-list strong inset dividers sortable class="list-has-group-title account-list margin-vertical"
|
||||
:key="listIdx" v-for="listIdx in [ 1, 2, 3 ]">
|
||||
<f7-list-item group-title :sortable="false">
|
||||
<small>
|
||||
<span>Account Category</span>
|
||||
@@ -66,12 +67,12 @@
|
||||
<f7-list-item :title="$t('No available account')"></f7-list-item>
|
||||
</f7-list>
|
||||
|
||||
<div :key="accountCategory.id"
|
||||
<div :key="accountCategory.type"
|
||||
v-for="accountCategory in allAccountCategories"
|
||||
v-show="(showHidden && hasAccount(accountCategory, false)) || hasAccount(accountCategory, true)">
|
||||
<f7-list strong inset dividers sortable class="list-has-group-title account-list margin-vertical"
|
||||
:sortable-enabled="sortable"
|
||||
v-if="allCategorizedAccountsMap[accountCategory.id]"
|
||||
v-if="allCategorizedAccountsMap[accountCategory.type]"
|
||||
@sortable:sort="onSort">
|
||||
<f7-list-item group-title :sortable="false">
|
||||
<small>
|
||||
@@ -82,15 +83,15 @@
|
||||
<f7-list-item swipeout
|
||||
class="nested-list-item"
|
||||
:id="getAccountDomId(account)"
|
||||
:class="{ 'has-child-list-item': account.type === allAccountTypes.MultiSubAccounts && hasVisibleSubAccount(account), 'actual-first-child': account.id === firstShowingIds.accounts[accountCategory.id], 'actual-last-child': account.id === lastShowingIds.accounts[accountCategory.id] }"
|
||||
:class="{ 'has-child-list-item': account.type === allAccountTypes.MultiSubAccounts.type && hasVisibleSubAccount(account), 'actual-first-child': account.id === firstShowingIds.accounts[accountCategory.type], 'actual-last-child': account.id === lastShowingIds.accounts[accountCategory.type] }"
|
||||
:after="accountBalance(account)"
|
||||
:link="!sortable ? '/transaction/list?accountIds=' + account.id : null"
|
||||
:key="account.id"
|
||||
v-for="account in allCategorizedAccountsMap[accountCategory.id].accounts"
|
||||
v-for="account in allCategorizedAccountsMap[accountCategory.type].accounts"
|
||||
v-show="showHidden || !account.hidden"
|
||||
@taphold="setSortable()"
|
||||
>
|
||||
<template #media v-if="account.type !== allAccountTypes.MultiSubAccounts || !hasVisibleSubAccount(account)">
|
||||
<template #media v-if="account.type !== allAccountTypes.MultiSubAccounts.type || !hasVisibleSubAccount(account)">
|
||||
<ItemIcon icon-type="account" :icon-id="account.icon" :color="account.color">
|
||||
<f7-badge color="gray" class="right-bottom-icon" v-if="account.hidden">
|
||||
<f7-icon f7="eye_slash_fill"></f7-icon>
|
||||
@@ -101,7 +102,7 @@
|
||||
<template #title>
|
||||
<div class="display-flex padding-top-half padding-bottom-half">
|
||||
<ItemIcon icon-type="account" :icon-id="account.icon" :color="account.color"
|
||||
v-if="account.type === allAccountTypes.MultiSubAccounts && hasVisibleSubAccount(account)">
|
||||
v-if="account.type === allAccountTypes.MultiSubAccounts.type && hasVisibleSubAccount(account)">
|
||||
<f7-badge color="gray" class="right-bottom-icon" v-if="account.hidden">
|
||||
<f7-icon f7="eye_slash_fill"></f7-icon>
|
||||
</f7-badge>
|
||||
@@ -111,7 +112,7 @@
|
||||
<div class="item-footer" v-if="account.comment">{{ account.comment }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<li v-if="account.type === allAccountTypes.MultiSubAccounts">
|
||||
<li v-if="account.type === allAccountTypes.MultiSubAccounts.type">
|
||||
<ul class="no-padding">
|
||||
<f7-list-item class="no-sortable nested-list-item-child"
|
||||
:class="{ 'actual-first-child': subAccount.id === firstShowingIds.subAccounts[account.id], 'actual-last-child': subAccount.id === lastShowingIds.subAccounts[account.id] }"
|
||||
@@ -179,8 +180,8 @@ import { useUserStore } from '@/stores/user.js';
|
||||
import { useAccountsStore } from '@/stores/account.js';
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
|
||||
import accountConstants from '@/consts/account.js';
|
||||
import { onSwipeoutDeleted } from '@/lib/ui.mobile.js';
|
||||
import { AccountType, AccountCategory } from '@/core/account.ts';
|
||||
import { onSwipeoutDeleted } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -205,10 +206,10 @@ export default {
|
||||
return this.userStore.currentUserDefaultCurrency;
|
||||
},
|
||||
allAccountTypes() {
|
||||
return accountConstants.allAccountTypes;
|
||||
return AccountType.all();
|
||||
},
|
||||
allAccountCategories() {
|
||||
return accountConstants.allCategories;
|
||||
return AccountCategory.values();
|
||||
},
|
||||
allCategorizedAccountsMap() {
|
||||
return this.accountsStore.allCategorizedAccountsMap;
|
||||
|
||||
Reference in New Issue
Block a user