migrate to typescript

This commit is contained in:
MaysWind
2024-12-29 14:24:37 +08:00
parent b638a73e4d
commit 2560a70e5e
171 changed files with 3402 additions and 2557 deletions
+4 -4
View File
@@ -124,9 +124,9 @@ import { mapStores } from 'pinia';
import { useUserStore } from '@/stores/user.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import { getMapProvider } from '@/lib/server_settings.js';
import { getMapProvider } from '@/lib/server_settings.ts';
import { getMapWebsite } from '@/lib/map/index.js';
import licenses from '@/lib/licenses.js';
import { getLicense, getThirdPartyLicenses } from '@/lib/licenses.ts';
export default {
computed: {
@@ -152,10 +152,10 @@ export default {
return getMapWebsite();
},
licenseLines() {
return licenses.getLicense().replaceAll(/\r/g, '').split('\n');
return getLicense().replaceAll(/\r/g, '').split('\n');
},
thirdPartyLicenses() {
return licenses.getThirdPartyLicenses();
return getThirdPartyLicenses();
}
}
}
+4 -3
View File
@@ -112,7 +112,8 @@ import { mapStores } from 'pinia';
import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.js';
import assetConstants from '@/consts/asset.js';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
import { ThemeType } from '@/core/theme.ts';
import {
mdiChevronLeft,
@@ -131,7 +132,7 @@ export default {
computed: {
...mapStores(useRootStore, useSettingsStore),
ezBookkeepingLogoPath() {
return assetConstants.ezBookkeepingLogoPath;
return APPLICATION_LOGO_PATH;
},
version() {
return 'v' + this.$version;
@@ -140,7 +141,7 @@ export default {
return this.$locale.getAllLanguageInfoArray(false);
},
isDarkMode() {
return this.globalTheme.global.name.value === 'dark';
return this.globalTheme.global.name.value === ThemeType.Dark;
},
currentLanguageName() {
return this.$locale.getCurrentLanguageDisplayName();
+2 -1
View File
@@ -197,6 +197,7 @@ import { useAccountsStore } from '@/stores/account.js';
import { useOverviewStore } from '@/stores/overview.js';
import datetimeConstants from '@/consts/datetime.js';
import { ThemeType } from '@/core/theme.ts';
import {
formatUnixTime,
getUnixTimeBeforeUnixTime,
@@ -245,7 +246,7 @@ export default {
computed: {
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useOverviewStore),
isDarkMode() {
return this.globalTheme.global.name.value === 'dark';
return this.globalTheme.global.name.value === ThemeType.Dark;
},
showAmountInHomePage: {
get: function() {
+8 -7
View File
@@ -175,15 +175,16 @@ import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import assetConstants from '@/consts/asset.js';
import apiConstants from '@/consts/api.js';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
import { KnownErrorCode } from '@/consts/api.ts';
import { ThemeType } from '@/core/theme.ts';
import {
isUserRegistrationEnabled,
isUserForgetPasswordEnabled,
isUserVerifyEmailEnabled,
getLoginPageTips
} from '@/lib/server_settings.js';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui.js';
} from '@/lib/server_settings.ts';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
import {
mdiOnepassword,
@@ -212,7 +213,7 @@ export default {
computed: {
...mapStores(useRootStore, useSettingsStore, useExchangeRatesStore),
ezBookkeepingLogoPath() {
return assetConstants.ezBookkeepingLogoPath;
return APPLICATION_LOGO_PATH;
},
version() {
return 'v' + this.$version;
@@ -240,7 +241,7 @@ export default {
}
},
isDarkMode() {
return this.globalTheme.global.name.value === 'dark';
return this.globalTheme.global.name.value === ThemeType.Dark;
},
currentLanguageName() {
return this.$locale.getCurrentLanguageDisplayName();
@@ -320,7 +321,7 @@ export default {
}).catch(error => {
self.logining = false;
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === apiConstants.userEmailNotVerifiedErrorCode && error.error.context && error.error.context.email) {
if (self.isUserVerifyEmailEnabled && error.error && error.error.errorCode === KnownErrorCode.UserEmailNotVerified && error.error.context && error.error.context.email) {
self.$router.push(`/verify_email?email=${encodeURIComponent(error.error.context.email)}&emailSent=${error.error.context.hasValidEmailVerifyToken || false}`);
return;
}
+6 -5
View File
@@ -201,9 +201,10 @@ import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import assetConstants from '@/consts/asset.js';
import { isUserScheduledTransactionEnabled } from '@/lib/server_settings.js';
import { getSystemTheme, setExpenseAndIncomeAmountColor } from '@/lib/ui.js';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
import { ThemeType } from '@/core/theme.ts';
import { isUserScheduledTransactionEnabled } from '@/lib/server_settings.ts';
import { getSystemTheme, setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
import {
mdiMenu,
@@ -263,7 +264,7 @@ export default {
computed: {
...mapStores(useRootStore, useSettingsStore, useUserStore),
ezBookkeepingLogoPath() {
return assetConstants.ezBookkeepingLogoPath;
return APPLICATION_LOGO_PATH;
},
mdAndDown() {
return this.display.mdAndDown.value;
@@ -286,7 +287,7 @@ export default {
if (value !== this.settingsStore.appSettings.theme) {
this.settingsStore.setTheme(value);
if (value === 'light' || value === 'dark') {
if (value === ThemeType.Light || value === ThemeType.Dark) {
this.globalTheme.global.name.value = value;
} else {
this.globalTheme.global.name.value = getSystemTheme();
+4 -3
View File
@@ -137,7 +137,8 @@ import { mapStores } from 'pinia';
import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.js';
import assetConstants from '@/consts/asset.js';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
import { ThemeType } from '@/core/theme.ts';
import {
mdiChevronLeft
@@ -177,7 +178,7 @@ export default {
}
},
ezBookkeepingLogoPath() {
return assetConstants.ezBookkeepingLogoPath;
return APPLICATION_LOGO_PATH;
},
version() {
return 'v' + this.$version;
@@ -186,7 +187,7 @@ export default {
return this.$locale.getAllLanguageInfoArray(false);
},
isDarkMode() {
return this.globalTheme.global.name.value === 'dark';
return this.globalTheme.global.name.value === ThemeType.Dark;
},
currentLanguageName() {
return this.$locale.getCurrentLanguageDisplayName();
+10 -9
View File
@@ -244,10 +244,11 @@ import { useUserStore } from '@/stores/user.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import assetConstants from '@/consts/asset.js';
import categoryConstants from '@/consts/category.js';
import { categorizedArrayToPlainArray } from '@/lib/common.js';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui.js';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
import { CategoryType } from '@/core/category.ts';
import { ThemeType } from '@/core/theme.ts';
import { categorizedArrayToPlainArray } from '@/lib/common.ts';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
import {
mdiArrowLeft,
@@ -277,7 +278,7 @@ export default {
computed: {
...mapStores(useRootStore, useSettingsStore, useTransactionCategoriesStore, useExchangeRatesStore),
ezBookkeepingLogoPath() {
return assetConstants.ezBookkeepingLogoPath;
return APPLICATION_LOGO_PATH;
},
allLanguages() {
return this.$locale.getAllLanguageInfoArray(false);
@@ -314,7 +315,7 @@ export default {
}
},
isDarkMode() {
return this.globalTheme.global.name.value === 'dark';
return this.globalTheme.global.name.value === ThemeType.Dark;
},
currentLanguageName() {
const languageInfo = this.$locale.getLanguageInfo(this.currentLocale);
@@ -495,11 +496,11 @@ export default {
},
getCategoryTypeName(categoryType) {
switch (categoryType) {
case categoryConstants.allCategoryTypes.Income.toString():
case CategoryType.Income.toString():
return this.$t('Income Categories');
case categoryConstants.allCategoryTypes.Expense.toString():
case CategoryType.Expense.toString():
return this.$t('Expense Categories');
case categoryConstants.allCategoryTypes.Transfer.toString():
case CategoryType.Transfer.toString():
return this.$t('Transfer Categories');
default:
return this.$t('Transaction Categories');
+5 -4
View File
@@ -117,10 +117,11 @@ import { useTokensStore } from '@/stores/token.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import assetConstants from '@/consts/asset.js';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
import { ThemeType } from '@/core/theme.ts';
import logger from '@/lib/logger.js';
import webauthn from '@/lib/webauthn.js';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui.js';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
export default {
data() {
@@ -132,7 +133,7 @@ export default {
computed: {
...mapStores(useRootStore, useSettingsStore, useUserStore, useTokensStore, useTransactionsStore, useExchangeRatesStore),
ezBookkeepingLogoPath() {
return assetConstants.ezBookkeepingLogoPath;
return APPLICATION_LOGO_PATH;
},
version() {
return 'v' + this.$version;
@@ -146,7 +147,7 @@ export default {
&& webauthn.isSupported();
},
isDarkMode() {
return this.globalTheme.global.name.value === 'dark';
return this.globalTheme.global.name.value === ThemeType.Dark;
},
currentLanguageName() {
return this.$locale.getCurrentLanguageDisplayName();
+5 -4
View File
@@ -116,8 +116,9 @@ import { mapStores } from 'pinia';
import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.js';
import assetConstants from '@/consts/asset.js';
import { isUserVerifyEmailEnabled } from '@/lib/server_settings.js';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
import { ThemeType } from '@/core/theme.ts';
import { isUserVerifyEmailEnabled } from '@/lib/server_settings.ts';
import {
mdiChevronLeft
@@ -144,7 +145,7 @@ export default {
computed: {
...mapStores(useRootStore, useSettingsStore),
ezBookkeepingLogoPath() {
return assetConstants.ezBookkeepingLogoPath;
return APPLICATION_LOGO_PATH;
},
version() {
return 'v' + this.$version;
@@ -153,7 +154,7 @@ export default {
return this.$locale.getAllLanguageInfoArray(false);
},
isDarkMode() {
return this.globalTheme.global.name.value === 'dark';
return this.globalTheme.global.name.value === ThemeType.Dark;
},
currentLanguageName() {
return this.$locale.getCurrentLanguageDisplayName();
+19 -20
View File
@@ -29,8 +29,8 @@
</div>
<v-divider />
<v-tabs show-arrows class="account-category-tabs my-4" direction="vertical"
:disabled="loading" v-model="activeAccountCategoryId">
<v-tab class="tab-text-truncate" :key="accountCategory.id" :value="accountCategory.id"
:disabled="loading" v-model="activeAccountCategoryType">
<v-tab class="tab-text-truncate" :key="accountCategory.type" :value="accountCategory.type"
v-for="accountCategory in allAccountCategories">
<ItemIcon icon-type="account" :icon-id="accountCategory.defaultAccountIconId" />
<div class="d-flex flex-column text-truncate ml-2">
@@ -146,8 +146,8 @@
handle=".drag-handle"
ghost-class="dragging-item"
:disabled="activeAccountCategoryVisibleAccountCount <= 1"
:list="allCategorizedAccountsMap[activeAccountCategory.id].accounts"
v-if="allCategorizedAccountsMap[activeAccountCategory.id] && allCategorizedAccountsMap[activeAccountCategory.id].accounts && allCategorizedAccountsMap[activeAccountCategory.id].accounts.length"
:list="allCategorizedAccountsMap[activeAccountCategory.type].accounts"
v-if="allCategorizedAccountsMap[activeAccountCategory.type] && allCategorizedAccountsMap[activeAccountCategory.type].accounts && allCategorizedAccountsMap[activeAccountCategory.type].accounts.length"
@change="onMove"
>
<template #item="{ element }">
@@ -169,7 +169,7 @@
</span>
</div>
<div class="mt-4" v-if="element.type === allAccountTypes.MultiSubAccounts">
<div class="mt-4" v-if="element.type === allAccountTypes.MultiSubAccounts.type">
<v-btn-toggle
class="account-subaccounts"
variant="outlined"
@@ -265,10 +265,9 @@ 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 { isObject } from '@/lib/common.js';
import { AccountType, AccountCategory } from '@/core/account.ts';
import { isObject } from '@/lib/common.ts';
import {
getAccountCategoryInfo,
getSubAccountCurrencies,
getAccountOrSubAccountId,
getAccountOrSubAccountComment
@@ -295,7 +294,7 @@ export default {
const { mdAndUp } = useDisplay();
return {
activeAccountCategoryId: accountConstants.allCategories[0].id,
activeAccountCategoryType: AccountCategory.Default.type,
activeTab: 'accountPage',
activeSubAccount: {},
loading: true,
@@ -325,10 +324,10 @@ export default {
return this.userStore.currentUserDefaultCurrency;
},
allAccountTypes() {
return accountConstants.allAccountTypes;
return AccountType.all();
},
allAccountCategories() {
return accountConstants.allCategories;
return AccountCategory.values();
},
allAccounts() {
return this.accountsStore.allAccounts;
@@ -352,17 +351,17 @@ export default {
return this.getDisplayCurrency(totalLiabilities, this.defaultCurrency);
},
activeAccountCategory() {
return getAccountCategoryInfo(this.activeAccountCategoryId);
return AccountCategory.valueOf(this.activeAccountCategoryType);
},
activeAccountCategoryTotalBalance() {
return this.accountCategoryTotalBalance(this.activeAccountCategory);
},
activeAccountCategoryVisibleAccountCount() {
if (!this.allCategorizedAccountsMap[this.activeAccountCategory.id] || !this.allCategorizedAccountsMap[this.activeAccountCategory.id].accounts) {
if (!this.allCategorizedAccountsMap[this.activeAccountCategory.type] || !this.allCategorizedAccountsMap[this.activeAccountCategory.type].accounts) {
return 0;
}
const accounts = this.allCategorizedAccountsMap[this.activeAccountCategory.id].accounts;
const accounts = this.allCategorizedAccountsMap[this.activeAccountCategory.type].accounts;
if (this.showHidden) {
return accounts.length;
@@ -422,7 +421,7 @@ export default {
for (let i = 0; i < self.allAccounts.length; i++) {
const account = self.allAccounts[i];
if (account.type === self.allAccountTypes.MultiSubAccounts && !self.activeSubAccount[account.id]) {
if (account.type === self.allAccountTypes.MultiSubAccounts.type && !self.activeSubAccount[account.id]) {
self.activeSubAccount[account.id] = '';
}
}
@@ -459,9 +458,9 @@ export default {
accountCurrency(account) {
const self = this;
if (account.type === self.allAccountTypes.SingleAccount) {
if (account.type === self.allAccountTypes.SingleAccount.type) {
return self.$locale.getCurrencyName(account.currency);
} else if (account.type === self.allAccountTypes.MultiSubAccounts) {
} else if (account.type === self.allAccountTypes.MultiSubAccounts.type) {
const subAccountCurrencies = getSubAccountCurrencies(account, self.showHidden, self.activeSubAccount[account.id])
.map(currencyCode => self.$locale.getCurrencyName(currencyCode));
return self.$locale.joinMultiText(subAccountCurrencies);
@@ -470,10 +469,10 @@ export default {
}
},
accountBalance(account) {
if (account.type === this.allAccountTypes.SingleAccount) {
if (account.type === this.allAccountTypes.SingleAccount.type) {
const balance = this.accountsStore.getAccountBalance(this.showAccountBalance, account);
return this.getDisplayCurrency(balance, account.currency);
} else if (account.type === this.allAccountTypes.MultiSubAccounts) {
} else if (account.type === this.allAccountTypes.MultiSubAccounts.type) {
const balanceResult = this.accountsStore.getAccountSubAccountBalance(this.showAccountBalance, this.showHidden, account, this.activeSubAccount[account.id]);
if (!isObject(balanceResult)) {
@@ -538,7 +537,7 @@ export default {
const self = this;
self.$refs.editDialog.open({
category: self.activeAccountCategoryId
category: self.activeAccountCategoryType
}).then(result => {
if (result && result.message) {
self.$refs.snackbar.showMessage(result.message);
@@ -1,5 +1,5 @@
<template>
<v-dialog :width="account.type === allAccountTypes.MultiSubAccounts ? 1000 : 800" :persistent="!!persistent" v-model="showState">
<v-dialog :width="account.type === allAccountTypes.MultiSubAccounts.type ? 1000 : 800" :persistent="!!persistent" v-model="showState">
<v-card class="pa-2 pa-sm-4 pa-md-8">
<template #title>
<div class="d-flex align-center justify-center">
@@ -8,7 +8,7 @@
<v-progress-circular indeterminate size="22" class="ml-2" v-if="loading"></v-progress-circular>
</div>
<v-btn density="comfortable" color="default" variant="text" class="ml-2" :icon="true"
:disabled="loading || submitting || !!editAccountId || account.type !== allAccountTypes.MultiSubAccounts">
:disabled="loading || submitting || !!editAccountId || account.type !== allAccountTypes.MultiSubAccounts.type">
<v-icon :icon="icons.more" />
<v-menu activator="parent">
<v-list>
@@ -21,12 +21,12 @@
</div>
</template>
<v-card-text class="d-flex flex-column flex-md-row mt-md-4 pt-0">
<div class="mb-4" v-if="account.type === allAccountTypes.MultiSubAccounts">
<div class="mb-4" v-if="account.type === allAccountTypes.MultiSubAccounts.type">
<v-tabs direction="vertical" :disabled="loading || submitting" v-model="currentAccountIndex">
<v-tab :value="-1">
<span>{{ $t('Main Account') }}</span>
</v-tab>
<template v-if="account.type === allAccountTypes.MultiSubAccounts">
<template v-if="account.type === allAccountTypes.MultiSubAccounts.type">
<v-tab :key="idx" :value="idx" v-for="(subAccount, idx) in subAccounts">
<span>{{ $t('Sub Account') + ' #' + (idx + 1) }}</span>
<v-btn class="ml-2" color="error" size="24" variant="text"
@@ -38,15 +38,15 @@
</div>
<v-window class="d-flex flex-grow-1 disable-tab-transition w-100-window-container"
:class="{ 'ml-md-5': account.type === allAccountTypes.MultiSubAccounts }"
:class="{ 'ml-md-5': account.type === allAccountTypes.MultiSubAccounts.type }"
v-model="activeTab">
<v-window-item value="account">
<v-form class="mt-2">
<v-row>
<v-col cols="12" md="12" v-if="account.type === allAccountTypes.SingleAccount || currentAccountIndex < 0">
<v-col cols="12" md="12" v-if="account.type === allAccountTypes.SingleAccount.type || currentAccountIndex < 0">
<v-select
item-title="displayName"
item-value="id"
item-value="type"
persistent-placeholder
:disabled="loading || submitting"
:label="$t('Account Category')"
@@ -71,10 +71,10 @@
</template>
</v-select>
</v-col>
<v-col cols="12" md="12" v-if="account.type === allAccountTypes.SingleAccount || currentAccountIndex < 0">
<v-col cols="12" md="12" v-if="account.type === allAccountTypes.SingleAccount.type || currentAccountIndex < 0">
<v-select
item-title="displayName"
item-value="id"
item-value="type"
persistent-placeholder
:disabled="loading || submitting || !!editAccountId"
:label="$t('Account Type')"
@@ -108,7 +108,7 @@
:disabled="loading || submitting"
v-model="selectedAccount.color" />
</v-col>
<v-col cols="12" :md="currentAccountIndex < 0 && isAccountSupportCreditCardStatementDate() ? 6 : 12" v-if="account.type === allAccountTypes.SingleAccount || currentAccountIndex >= 0">
<v-col cols="12" :md="currentAccountIndex < 0 && isAccountSupportCreditCardStatementDate() ? 6 : 12" v-if="account.type === allAccountTypes.SingleAccount.type || currentAccountIndex >= 0">
<v-autocomplete
item-title="displayName"
item-value="currencyCode"
@@ -126,7 +126,7 @@
</template>
</v-autocomplete>
</v-col>
<v-col cols="12" :md="account.type === allAccountTypes.SingleAccount || currentAccountIndex >= 0 ? 6 : 12" v-if="currentAccountIndex < 0 && isAccountSupportCreditCardStatementDate()">
<v-col cols="12" :md="account.type === allAccountTypes.SingleAccount.type || currentAccountIndex >= 0 ? 6 : 12" v-if="currentAccountIndex < 0 && isAccountSupportCreditCardStatementDate()">
<v-autocomplete
item-title="displayName"
item-value="day"
@@ -141,7 +141,7 @@
></v-autocomplete>
</v-col>
<v-col cols="12" :md="!editAccountId && selectedAccount.balance ? 6 : 12"
v-if="account.type === allAccountTypes.SingleAccount || currentAccountIndex >= 0">
v-if="account.type === allAccountTypes.SingleAccount.type || currentAccountIndex >= 0">
<amount-input :disabled="loading || submitting || !!editAccountId"
:persistent-placeholder="true"
:currency="selectedAccount.currency"
@@ -151,7 +151,7 @@
v-model="selectedAccount.balance"/>
</v-col>
<v-col cols="12" md="6" v-show="selectedAccount.balance"
v-if="!editAccountId && (account.type === allAccountTypes.SingleAccount || currentAccountIndex >= 0)">
v-if="!editAccountId && (account.type === allAccountTypes.SingleAccount.type || currentAccountIndex >= 0)">
<date-time-select
:disabled="loading || submitting"
:label="$t('Balance Time')"
@@ -200,11 +200,11 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.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 { isNumber } 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 { isNumber } from '@/lib/common.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import {
setAccountModelByAnotherAccount,
setAccountSuitableIcon
@@ -264,7 +264,7 @@ export default {
}
},
allAccountTypes() {
return accountConstants.allAccountTypes;
return AccountType.all();
},
allAccountCategories() {
return this.$locale.getAllAccountCategories();
@@ -273,10 +273,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();
@@ -366,7 +366,7 @@ export default {
});
},
addSubAccount() {
if (this.account.type !== this.allAccountTypes.MultiSubAccounts) {
if (this.account.type !== this.allAccountTypes.MultiSubAccounts.type) {
return;
}
@@ -393,7 +393,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);
@@ -447,7 +447,7 @@ export default {
this.showState = false;
},
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);
@@ -459,7 +459,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);
@@ -478,7 +478,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;
@@ -214,7 +214,8 @@ import { useOverviewStore } from '@/stores/overview.js';
import { useStatisticsStore } from '@/stores/statistics.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import { getSystemTheme } from '@/lib/ui.js';
import { ThemeType } from '@/core/theme.ts';
import { getSystemTheme } from '@/lib/ui/common.ts';
export default {
computed: {
@@ -239,7 +240,7 @@ export default {
if (value !== this.settingsStore.appSettings.theme) {
this.settingsStore.setTheme(value);
if (value === 'light' || value === 'dark') {
if (value === ThemeType.Light || value === ThemeType.Dark) {
this.globalTheme.global.name.value = value;
} else {
this.globalTheme.global.name.value = getSystemTheme();
+5 -5
View File
@@ -200,12 +200,12 @@ import { useDisplay } from 'vuetify';
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import categoryConstants from '@/consts/category.js';
import { CategoryType } from '@/core/category.ts';
import {
isNoAvailableCategory,
getAvailableCategoryCount
} from '@/lib/category.js';
import { getNavSideBarOuterHeight } from '@/lib/ui.desktop.js';
import { getNavSideBarOuterHeight } from '@/lib/ui/desktop.js';
import {
mdiRefresh,
@@ -227,7 +227,7 @@ export default {
const { mdAndUp } = useDisplay();
return {
activeCategoryType: categoryConstants.allCategoryTypes.Expense,
activeCategoryType: CategoryType.Expense,
activeTab: 'categoryPage',
primaryCategoryId: '0',
loading: true,
@@ -255,7 +255,7 @@ export default {
computed: {
...mapStores(useTransactionCategoriesStore),
allCategoryTypes() {
return categoryConstants.allCategoryTypes;
return CategoryType;
},
primaryCategories() {
if (!this.transactionCategoriesStore.allTransactionCategories || !this.transactionCategoriesStore.allTransactionCategories[this.activeCategoryType]) {
@@ -501,7 +501,7 @@ export default {
self.$nextTick(() => {
if (self.$refs.navbar && self.$refs.navbar.$el && self.$refs.navbar.$el.nextElementSibling) {
let navbarHeight = getNavSideBarOuterHeight(self.$refs.navbar.$el.nextElementSibling);
const navbarHeight = getNavSideBarOuterHeight(self.$refs.navbar.$el.nextElementSibling);
self.cardMinHeight = Math.max(navbarHeight, 680);
}
});
@@ -97,10 +97,10 @@
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import categoryConstants from '@/consts/category.js';
import iconConstants from '@/consts/icon.js';
import colorConstants from '@/consts/color.js';
import { generateRandomUUID } from '@/lib/misc.js';
import { CategoryType } from '@/core/category.ts';
import { ALL_CATEGORY_ICONS } from '@/consts/icon.ts';
import { ALL_CATEGORY_COLORS } from '@/consts/color.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import {
setCategoryModelByAnotherCategory,
allVisiblePrimaryTransactionCategoriesByType
@@ -153,10 +153,10 @@ export default {
}
},
allCategoryIcons() {
return iconConstants.allCategoryIcons;
return ALL_CATEGORY_ICONS;
},
allCategoryColors() {
return colorConstants.allCategoryColors;
return ALL_CATEGORY_COLORS;
},
inputIsEmpty() {
return !!this.inputEmptyProblemMessage;
@@ -205,9 +205,9 @@ export default {
const categoryType = parseInt(options.type);
if (categoryType !== categoryConstants.allCategoryTypes.Income &&
categoryType !== categoryConstants.allCategoryTypes.Expense &&
categoryType !== categoryConstants.allCategoryTypes.Transfer) {
if (categoryType !== CategoryType.Income &&
categoryType !== CategoryType.Expense &&
categoryType !== CategoryType.Transfer) {
self.loading = false;
self.showState = false;
@@ -70,8 +70,8 @@
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import categoryConstants from '@/consts/category.js';
import { categorizedArrayToPlainArray } from '@/lib/common.js';
import { CategoryType } from '@/core/category.ts';
import { categorizedArrayToPlainArray } from '@/lib/common.ts';
import {
mdiDotsVertical
@@ -152,11 +152,11 @@ export default {
},
getCategoryTypeName(categoryType) {
switch (categoryType) {
case categoryConstants.allCategoryTypes.Income.toString():
case CategoryType.Income.toString():
return this.$t('Income Categories');
case categoryConstants.allCategoryTypes.Expense.toString():
case CategoryType.Expense.toString():
return this.$t('Expense Categories');
case categoryConstants.allCategoryTypes.Transfer.toString():
case CategoryType.Transfer.toString():
return this.$t('Transfer Categories');
default:
return this.$t('Transaction Categories');
@@ -105,10 +105,10 @@
</template>
</v-list-item>
<v-divider v-if="(showHidden || !account.hidden) && account.type === allAccountTypes.MultiSubAccounts && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id])"/>
<v-divider v-if="(showHidden || !account.hidden) && account.type === allAccountTypes.MultiSubAccounts.type && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id])"/>
<v-list rounded density="comfortable" class="pa-0 ml-4"
v-if="(showHidden || !account.hidden) && account.type === allAccountTypes.MultiSubAccounts && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id])">
v-if="(showHidden || !account.hidden) && account.type === allAccountTypes.MultiSubAccounts.type && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id])">
<template :key="subAccount.id"
v-for="(subAccount, subIdx) in accountCategory.allSubAccounts[account.id]">
<v-divider v-if="showHidden ? subIdx > 0 : (!subAccount.hidden ? subIdx > accountCategory.allFirstVisibleSubAccountIndexes[account.id] : false)"/>
@@ -152,8 +152,8 @@ import { useAccountsStore } from '@/stores/account.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useStatisticsStore } from '@/stores/statistics.js';
import accountConstants from '@/consts/account.js';
import { copyObjectTo } from '@/lib/common.js';
import { AccountType, AccountCategory } from '@/core/account.ts';
import { copyObjectTo } from '@/lib/common.ts';
import {
getCategorizedAccountsWithVisibleCount,
selectAccountOrSubAccounts,
@@ -185,7 +185,7 @@ export default {
data: function () {
return {
loading: true,
expandAccountCategories: accountConstants.allCategories.map(category => category.id),
expandAccountCategories: AccountCategory.values().map(category => category.type),
filterAccountIds: {},
showHidden: false,
icons: {
@@ -215,7 +215,7 @@ export default {
}
},
allAccountTypes() {
return accountConstants.allAccountTypes;
return AccountType.all();
},
allCategorizedAccounts() {
return getCategorizedAccountsWithVisibleCount(this.accountsStore.allCategorizedAccountsMap);
@@ -241,7 +241,7 @@ export default {
const allAccountIds = {};
for (let accountId in self.accountsStore.allAccountsMap) {
for (const accountId in self.accountsStore.allAccountsMap) {
if (!Object.prototype.hasOwnProperty.call(self.accountsStore.allAccountsMap, accountId)) {
continue;
}
@@ -260,7 +260,7 @@ export default {
} else if (self.type === 'statisticsCurrent') {
self.filterAccountIds = copyObjectTo(self.statisticsStore.transactionStatisticsFilter.filterAccountIds, allAccountIds);
} else if (self.type === 'transactionListCurrent') {
for (let accountId in self.transactionsStore.allFilterAccountIds) {
for (const accountId in self.transactionsStore.allFilterAccountIds) {
if (!Object.prototype.hasOwnProperty.call(self.transactionsStore.allFilterAccountIds, accountId)) {
continue;
}
@@ -292,7 +292,7 @@ export default {
let finalAccountIds = '';
let changed = true;
for (let accountId in self.filterAccountIds) {
for (const accountId in self.filterAccountIds) {
if (!Object.prototype.hasOwnProperty.call(self.filterAccountIds, accountId)) {
continue;
}
@@ -149,8 +149,8 @@ import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useStatisticsStore } from '@/stores/statistics.js';
import categoryConstants from '@/consts/category.js';
import { copyObjectTo, arrayItemToObjectField } from '@/lib/common.js';
import { CategoryType } from '@/core/category.ts';
import { copyObjectTo, arrayItemToObjectField } from '@/lib/common.ts';
import {
allTransactionCategoriesWithVisibleCount,
hasAnyAvailableCategory,
@@ -187,9 +187,9 @@ export default {
return {
loading: true,
expandCategoryTypes: [
categoryConstants.allCategoryTypes.Income.toString(),
categoryConstants.allCategoryTypes.Expense.toString(),
categoryConstants.allCategoryTypes.Transfer.toString()
CategoryType.Income.toString(),
CategoryType.Expense.toString(),
CategoryType.Transfer.toString()
],
filterCategoryIds: {},
showHidden: false,
@@ -245,7 +245,7 @@ export default {
const allCategoryIds = {};
for (let categoryId in self.transactionCategoriesStore.allTransactionCategoriesMap) {
for (const categoryId in self.transactionCategoriesStore.allTransactionCategoriesMap) {
if (!Object.prototype.hasOwnProperty.call(self.transactionCategoriesStore.allTransactionCategoriesMap, categoryId)) {
continue;
}
@@ -268,7 +268,7 @@ export default {
} else if (self.type === 'statisticsCurrent') {
self.filterCategoryIds = copyObjectTo(self.statisticsStore.transactionStatisticsFilter.filterCategoryIds, allCategoryIds);
} else if (self.type === 'transactionListCurrent') {
for (let categoryId in self.transactionsStore.allFilterCategoryIds) {
for (const categoryId in self.transactionsStore.allFilterCategoryIds) {
if (!Object.prototype.hasOwnProperty.call(self.transactionsStore.allFilterCategoryIds, categoryId)) {
continue;
}
@@ -303,7 +303,7 @@ export default {
let finalCategoryIds = '';
let changed = true;
for (let categoryId in self.filterCategoryIds) {
for (const categoryId in self.filterCategoryIds) {
if (!Object.prototype.hasOwnProperty.call(self.filterCategoryIds, categoryId)) {
continue;
}
@@ -388,11 +388,11 @@ export default {
},
getCategoryTypeName(categoryType) {
switch (categoryType) {
case categoryConstants.allCategoryTypes.Income.toString():
case CategoryType.Income.toString():
return this.$t('Income Categories');
case categoryConstants.allCategoryTypes.Expense.toString():
case CategoryType.Expense.toString():
return this.$t('Expense Categories');
case categoryConstants.allCategoryTypes.Transfer.toString():
case CategoryType.Transfer.toString():
return this.$t('Transfer Categories');
default:
return this.$t('Transaction Categories');
@@ -136,13 +136,13 @@ import { useTransactionTagsStore } from '@/stores/transactionTag.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useStatisticsStore } from '@/stores/statistics.js';
import transactionConstants from '@/consts/transaction.js';
import { TransactionTagFilterType } from '@/core/transaction.ts';
import {
selectAll,
selectNone,
selectInvert
} from '@/lib/common.js';
} from '@/lib/common.ts';
import {
mdiSelectAll,
@@ -169,7 +169,7 @@ export default {
loading: true,
expandTagCategories: [ 'default' ],
filterTagIds: {},
tagFilterType: transactionConstants.defaultTransactionTagFilterType.type,
tagFilterType: TransactionTagFilterType.Default.type,
showHidden: false,
icons: {
selectAll: mdiSelectAll,
@@ -218,7 +218,7 @@ export default {
const allTransactionTagIds = {};
for (let transactionTagId in self.transactionTagsStore.allTransactionTagsMap) {
for (const transactionTagId in self.transactionTagsStore.allTransactionTagsMap) {
if (!Object.prototype.hasOwnProperty.call(self.transactionTagsStore.allTransactionTagsMap, transactionTagId)) {
continue;
}
@@ -228,7 +228,7 @@ export default {
}
if (self.type === 'statisticsCurrent') {
let transactionTagIds = self.statisticsStore.transactionStatisticsFilter.tagIds ? self.statisticsStore.transactionStatisticsFilter.tagIds.split(',') : [];
const transactionTagIds = self.statisticsStore.transactionStatisticsFilter.tagIds ? self.statisticsStore.transactionStatisticsFilter.tagIds.split(',') : [];
for (let i = 0; i < transactionTagIds.length; i++) {
const transactionTagId = transactionTagIds[i];
@@ -241,7 +241,7 @@ export default {
self.filterTagIds = allTransactionTagIds;
self.tagFilterType = self.statisticsStore.transactionStatisticsFilter.tagFilterType;
} else if (self.type === 'transactionListCurrent') {
for (let transactionTagId in self.transactionsStore.allFilterTagIds) {
for (const transactionTagId in self.transactionsStore.allFilterTagIds) {
if (!Object.prototype.hasOwnProperty.call(self.transactionsStore.allFilterTagIds, transactionTagId)) {
continue;
}
@@ -272,7 +272,7 @@ export default {
let finalTagIds = '';
let changed = true;
for (let transactionTagId in self.filterTagIds) {
for (const transactionTagId in self.filterTagIds) {
if (!Object.prototype.hasOwnProperty.call(self.filterTagIds, transactionTagId)) {
continue;
}
@@ -31,12 +31,12 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import transactionConstants from '@/consts/transaction.js';
import { TransactionType } from '@/core/transaction.ts';
import {
parseDateFromUnixTime,
getMonthName
} from '@/lib/datetime.js';
import { getExpenseAndIncomeAmountColor } from '@/lib/ui.js';
import { getExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
export default {
props: [
@@ -109,7 +109,7 @@ export default {
}
}
let amountGap = maxAmount - minAmount;
const amountGap = maxAmount - minAmount;
return {
tooltip: {
@@ -274,12 +274,12 @@ export default {
if (clickData && e.seriesId === 'seriesIncome') {
this.$emit('click', {
transactionType: transactionConstants.allTransactionTypes.Income,
transactionType: TransactionType.Income,
monthStartTime: clickData.monthStartTime
});
} else if (clickData && e.seriesId === 'seriesExpense') {
this.$emit('click', {
transactionType: transactionConstants.allTransactionTypes.Expense,
transactionType: TransactionType.Expense,
monthStartTime: clickData.monthStartTime
});
}
@@ -325,12 +325,13 @@ import { useStatisticsStore } from '@/stores/statistics.js';
import datetimeConstants from '@/consts/datetime.js';
import statisticsConstants from '@/consts/statistics.js';
import { ThemeType } from '@/core/theme.ts';
import {
isDefined,
limitText,
getNameByKeyValue,
arrayItemToObjectField
} from '@/lib/common.js'
} from '@/lib/common.ts'
import { formatPercent } from '@/lib/numeral.js';
import {
getYearAndMonthFromUnixTime,
@@ -414,7 +415,7 @@ export default {
computed: {
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useStatisticsStore),
isDarkMode() {
return this.globalTheme.global.name.value === 'dark';
return this.globalTheme.global.name.value === ThemeType.Dark;
},
defaultCurrency() {
return this.userStore.currentUserDefaultCurrency;
+8 -8
View File
@@ -4,7 +4,7 @@
<v-card>
<template #title>
<div class="title-and-toolbar d-flex align-center">
<span>{{ templateType === allTemplateTypes.Schedule ? $t('Scheduled Transactions') : $t('Transaction Templates') }}</span>
<span>{{ templateType === allTemplateTypes.Schedule.type ? $t('Scheduled Transactions') : $t('Transaction Templates') }}</span>
<v-btn class="ml-3" color="default" variant="outlined"
:disabled="loading || updating" @click="add">{{ $t('Add') }}</v-btn>
<v-btn class="ml-3" color="primary" variant="tonal"
@@ -60,8 +60,8 @@
<tbody v-if="!loading && noAvailableTemplate">
<tr>
<td v-if="templateType === allTemplateTypes.Normal">{{ $t('No available template. Once you add templates, you can quickly add a new transaction using the dropdown menu of the Add button on the transaction list page') }}</td>
<td v-else-if="templateType === allTemplateTypes.Schedule">{{ $t('No available scheduled transactions') }}</td>
<td v-if="templateType === allTemplateTypes.Normal.type">{{ $t('No available template. Once you add templates, you can quickly add a new transaction using the dropdown menu of the Add button on the transaction list page') }}</td>
<td v-else-if="templateType === allTemplateTypes.Schedule.type">{{ $t('No available scheduled transactions') }}</td>
<td v-else>{{ $t('No available template') }}</td>
</tr>
</tbody>
@@ -81,9 +81,9 @@
<v-badge class="right-bottom-icon" color="secondary"
location="bottom right" offset-x="8" :icon="icons.hide"
v-if="element.hidden">
<v-icon size="20" start :icon="templateType === allTemplateTypes.Schedule ? icons.clock : icons.text"/>
<v-icon size="20" start :icon="templateType === allTemplateTypes.Schedule.type ? icons.clock : icons.text"/>
</v-badge>
<v-icon size="20" start :icon="templateType === allTemplateTypes.Schedule ? icons.clock : icons.text" v-else-if="!element.hidden"/>
<v-icon size="20" start :icon="templateType === allTemplateTypes.Schedule.type ? icons.clock : icons.text" v-else-if="!element.hidden"/>
<span class="transaction-template-name">{{ element.name }}</span>
</div>
@@ -151,7 +151,7 @@ import EditDialog from '@/views/desktop/transactions/list/dialogs/EditDialog.vue
import { mapStores } from 'pinia';
import { useTransactionTemplatesStore } from '@/stores/transactionTemplate.js';
import templateConstants from '@/consts/template.js';
import { TemplateType } from '@/core/template.ts';
import {
isNoAvailableTemplate,
getAvailableTemplateCount
@@ -181,7 +181,7 @@ export default {
],
data() {
return {
templateType: templateConstants.allTemplateTypes.Normal,
templateType: TemplateType.Normal.type,
loading: true,
updating: false,
templateHiding: {},
@@ -216,7 +216,7 @@ export default {
return getAvailableTemplateCount(this.templates, this.showHidden);
},
allTemplateTypes() {
return templateConstants.allTemplateTypes;
return TemplateType.all();
}
},
created() {
+19 -19
View File
@@ -413,12 +413,12 @@
<v-divider v-if="query.tagIds && query.tagIds !== 'none'" />
<template :key="filterType.type"
v-for="filterType in allTransactionTagFilterTypes"
v-if="query.tagIds && query.tagIds !== 'none'">
<template v-if="query.tagIds && query.tagIds !== 'none'">
<v-list-item class="text-sm" density="compact"
:key="filterType.type"
:value="filterType.type"
:append-icon="(query.tagFilterType === filterType.type ? icons.check : null)">
:append-icon="(query.tagFilterType === filterType.type ? icons.check : null)"
v-for="filterType in allTransactionTagFilterTypes">
<v-list-item-title class="cursor-pointer"
@click="changeTagFilterType(filterType.type)">
<div class="d-flex align-center">
@@ -595,12 +595,12 @@ import { useTransactionTagsStore } from '@/stores/transactionTag.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useTransactionTemplatesStore } from '@/stores/transactionTemplate.js';
import { AccountType } from '@/core/account.ts';
import { TransactionType, TransactionTagFilterType } from '@/core/transaction.ts';
import { TemplateType } from '@/core/template.ts';
import numeralConstants from '@/consts/numeral.js';
import datetimeConstants from '@/consts/datetime.js';
import accountConstants from '@/consts/account.js';
import transactionConstants from '@/consts/transaction.js';
import templateConstants from '@/consts/template.js';
import { isString, isNumber, getNameByKeyValue } from '@/lib/common.js';
import { isString, isNumber, getNameByKeyValue } from '@/lib/common.ts';
import logger from '@/lib/logger.js';
import {
getCurrentUnixTime,
@@ -629,8 +629,8 @@ import {
} from '@/lib/category.js';
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.js';
import { getTransactionDisplayAmount } from '@/lib/transaction.js';
import { isDataImportingEnabled } from '@/lib/server_settings.js';
import { scrollToSelectedItem } from '@/lib/ui.desktop.js';
import { isDataImportingEnabled } from '@/lib/server_settings.ts';
import { scrollToSelectedItem } from '@/lib/ui/desktop.js';
import {
mdiMagnify,
@@ -729,7 +729,7 @@ export default {
if (this.query.accountIds && this.queryAllFilterAccountIdsCount === 1) {
const account = this.allAccounts[this.query.accountIds];
if (account && account.type === accountConstants.allAccountTypes.MultiSubAccounts) {
if (account && account.type === AccountType.MultiSubAccounts.type) {
return false;
}
}
@@ -980,16 +980,16 @@ export default {
return numeralConstants.allAmountFilterTypeArray;
},
allTransactionTypes() {
return transactionConstants.allTransactionTypes;
return TransactionType;
},
allTransactionTagFilterTypes() {
const allTagFilterTypes = this.$locale.getAllTransactionTagFilterTypes();
const allTagFilterTypesWithIcon = [];
const tagFilterIconMap = {
[transactionConstants.allTransactionTagFilterTypes.HasAny.type]: this.icons.withAnyTags,
[transactionConstants.allTransactionTagFilterTypes.HasAll.type]: this.icons.withAllTags,
[transactionConstants.allTransactionTagFilterTypes.NotHasAny.type]: this.icons.withoutAnyTags,
[transactionConstants.allTransactionTagFilterTypes.NotHasAll.type]: this.icons.withoutAllTags
[TransactionTagFilterType.HasAny.type]: this.icons.withAnyTags,
[TransactionTagFilterType.HasAll.type]: this.icons.withAllTags,
[TransactionTagFilterType.NotHasAny.type]: this.icons.withoutAnyTags,
[TransactionTagFilterType.NotHasAll.type]: this.icons.withoutAllTags
};
for (let i = 0; i < allTagFilterTypes.length; i++) {
@@ -1055,7 +1055,7 @@ export default {
},
allTransactionTemplates() {
const allVisibleTemplates = this.transactionTemplatesStore.allVisibleTemplates;
return allVisibleTemplates[templateConstants.allTemplateTypes.Normal] || [];
return allVisibleTemplates[TemplateType.Normal.type] || [];
},
recentMonthDateRanges() {
return this.$locale.getAllRecentMonthDateRanges(this.userStore, true, true);
@@ -1147,7 +1147,7 @@ export default {
this.reload(false);
this.transactionTemplatesStore.loadAllTemplates({
templateType: templateConstants.allTemplateTypes.Normal,
templateType: TemplateType.Normal.type,
force: false
});
},
@@ -1312,7 +1312,7 @@ export default {
if (type && this.query.categoryIds) {
newCategoryFilter = '';
for (let categoryId in this.queryAllFilterCategoryIds) {
for (const categoryId in this.queryAllFilterCategoryIds) {
if (!Object.prototype.hasOwnProperty.call(this.queryAllFilterCategoryIds, categoryId)) {
continue;
}
@@ -179,10 +179,10 @@ import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionTagsStore } from '@/stores/transactionTag.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import categoryConstants from '@/consts/category.js';
import { CategoryType } from '@/core/category.ts';
import {
getNameByKeyValue
} from '@/lib/common.js';
} from '@/lib/common.ts';
import {
getTransactionPrimaryCategoryName,
getTransactionSecondaryCategoryName,
@@ -219,7 +219,7 @@ export default {
return this.userStore.currentUserDefaultCurrency;
},
allCategoryTypes() {
return categoryConstants.allCategoryTypes;
return CategoryType;
},
allAccounts() {
return this.accountsStore.allPlainAccounts;
@@ -200,7 +200,7 @@
v-model="transaction.time"
@error="showDateTimeError" />
</v-col>
<v-col cols="12" md="6" v-if="type === 'template' && transaction.templateType === allTemplateTypes.Schedule">
<v-col cols="12" md="6" v-if="type === 'template' && transaction.templateType === allTemplateTypes.Schedule.type">
<schedule-frequency-select
:readonly="mode === 'view'"
:disabled="loading || submitting"
@@ -208,7 +208,7 @@
v-model:type="transaction.scheduledFrequencyType"
v-model="transaction.scheduledFrequency" />
</v-col>
<v-col cols="12" md="6" v-if="type === 'transaction' || (type === 'template' && transaction.templateType === allTemplateTypes.Schedule)">
<v-col cols="12" md="6" v-if="type === 'transaction' || (type === 'template' && transaction.templateType === allTemplateTypes.Schedule.type)">
<v-autocomplete
class="transaction-edit-timezone"
item-title="displayNameWithUtcOffset"
@@ -400,22 +400,23 @@ import { useTransactionsStore } from '@/stores/transaction.js';
import { useTransactionTemplatesStore } from '@/stores/transactionTemplate.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import fileConstants from '@/consts/file.js';
import categoryConstants from '@/consts/category.js';
import transactionConstants from '@/consts/transaction.js';
import templateConstants from '@/consts/template.js';
import apiConstants from '@/consts/api.js';
import { CategoryType } from '@/core/category.ts';
import { TransactionType, TransactionEditScopeType } from '@/core/transaction.ts';
import { TemplateType, ScheduledTemplateFrequencyType } from '@/core/template.ts';
import { TRANSACTION_MAX_PICTURE_COUNT } from '@/consts/transaction.ts';
import { KnownErrorCode } from '@/consts/api.ts';
import { SUPPORTED_IMAGE_EXTENSIONS } from '@/consts/file.ts';
import logger from '@/lib/logger.js';
import {
isArray,
getNameByKeyValue
} from '@/lib/common.js';
} from '@/lib/common.ts';
import {
getUtcOffsetByUtcOffsetMinutes,
getTimezoneOffsetMinutes,
getCurrentUnixTime
} from '@/lib/datetime.js';
import { generateRandomUUID } from '@/lib/misc.js';
import { generateRandomUUID } from '@/lib/misc.ts';
import {
getTransactionPrimaryCategoryName,
getTransactionSecondaryCategoryName,
@@ -425,7 +426,7 @@ import { setTransactionModelByTransaction } from '@/lib/transaction.js';
import {
isTransactionPicturesEnabled,
getMapProvider
} from '@/lib/server_settings.js';
} from '@/lib/server_settings.ts';
import {
mdiDotsVertical,
@@ -496,13 +497,13 @@ export default {
} else {
return 'Transaction Detail';
}
} else if (this.type === 'template' && this.transaction.templateType === templateConstants.allTemplateTypes.Normal) {
} else if (this.type === 'template' && this.transaction.templateType === TemplateType.Normal.type) {
if (this.mode === 'add') {
return 'Add Transaction Template';
} else if (this.mode === 'edit') {
return 'Edit Transaction Template';
}
} else if (this.type === 'template' && this.transaction.templateType === templateConstants.allTemplateTypes.Schedule) {
} else if (this.type === 'template' && this.transaction.templateType === TemplateType.Schedule.type) {
if (this.mode === 'add') {
return 'Add Scheduled Transaction';
} else if (this.mode === 'edit') {
@@ -571,13 +572,13 @@ export default {
return this.userStore.currentUserDefaultAccountId;
},
allTransactionTypes() {
return transactionConstants.allTransactionTypes;
return TransactionType;
},
allCategoryTypes() {
return categoryConstants.allCategoryTypes;
return CategoryType;
},
allTemplateTypes() {
return templateConstants.allTemplateTypes;
return TemplateType.all();
},
allTimezones() {
return this.$locale.getAllTimezones(true);
@@ -607,7 +608,7 @@ export default {
return this.transactionTagsStore.allTransactionTagsMap;
},
supportedImageExtensions() {
return fileConstants.supportedImageExtensions;
return SUPPORTED_IMAGE_EXTENSIONS;
},
hasAvailableExpenseCategories() {
if (!this.allCategories || !this.allCategories[this.allCategoryTypes.Expense] || !this.allCategories[this.allCategoryTypes.Expense].length) {
@@ -702,7 +703,7 @@ export default {
return false;
}
return !isArray(this.transaction.pictures) || this.transaction.pictures.length < transactionConstants.maxPictureCount;
return !isArray(this.transaction.pictures) || this.transaction.pictures.length < TRANSACTION_MAX_PICTURE_COUNT;
},
mapProvider() {
return getMapProvider();
@@ -839,8 +840,8 @@ export default {
self.transaction.templateType = options.templateType;
}
if (self.transaction.templateType === templateConstants.allTemplateTypes.Schedule) {
self.transaction.scheduledFrequencyType = templateConstants.allTemplateScheduledFrequencyTypes.Disabled.type;
if (self.transaction.templateType === TemplateType.Schedule.type) {
self.transaction.scheduledFrequencyType = ScheduledTemplateFrequencyType.Disabled.type;
self.transaction.scheduledFrequency = '';
}
@@ -850,7 +851,7 @@ export default {
self.transaction.templateType = options.currentTemplate.templateType;
self.transaction.name = options.currentTemplate.name;
if (self.transaction.templateType === templateConstants.allTemplateTypes.Schedule) {
if (self.transaction.templateType === TemplateType.Schedule.type) {
self.transaction.scheduledFrequencyType = options.currentTemplate.scheduledFrequencyType;
self.transaction.scheduledFrequency = options.currentTemplate.scheduledFrequency;
self.transaction.utcOffset = options.currentTemplate.utcOffset;
@@ -903,7 +904,7 @@ export default {
self.transaction.templateType = template.templateType;
self.transaction.name = template.name;
if (self.transaction.templateType === templateConstants.allTemplateTypes.Schedule) {
if (self.transaction.templateType === TemplateType.Schedule.type) {
self.transaction.scheduledFrequencyType = template.scheduledFrequencyType;
self.transaction.scheduledFrequency = template.scheduledFrequency;
self.transaction.utcOffset = template.utcOffset;
@@ -974,12 +975,12 @@ export default {
}).catch(error => {
self.submitting = false;
if (error.error && (error.error.errorCode === apiConstants.transactionCannotCreateInThisTimeErrorCode || error.error.errorCode === apiConstants.transactionCannotModifyInThisTimeErrorCode)) {
if (error.error && (error.error.errorCode === KnownErrorCode.TransactionCannotCreateInThisTime || error.error.errorCode === KnownErrorCode.TransactionCannotModifyInThisTime)) {
self.$refs.confirmDialog.open('You have set this time range to prevent editing transactions. Would you like to change the editable transaction range to All?').then(() => {
self.submitting = true;
self.userStore.updateUserTransactionEditScope({
transactionEditScope: transactionConstants.allTransactionEditScopeTypes.All.type
transactionEditScope: TransactionEditScopeType.All.type
}).then(() => {
self.submitting = false;
@@ -1272,7 +1273,7 @@ export default {
self.removingPictureId = '';
self.submitting = false;
}).catch(error => {
if (error.error && error.error.errorCode === apiConstants.transactionPictureNotFoundErrorCode) {
if (error.error && error.error.errorCode === KnownErrorCode.TransactionPictureNotFound) {
for (let i = 0; i < self.transaction.pictures.length; i++) {
if (self.transaction.pictures[i].pictureId === pictureInfo.pictureId) {
self.transaction.pictures.splice(i, 1);
@@ -606,16 +606,16 @@ import { useOverviewStore } from '@/stores/overview.js';
import { useStatisticsStore } from '@/stores/statistics.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import categoryConstants from '@/consts/category.js';
import transactionConstants from '@/consts/transaction.js';
import { CategoryType } from '@/core/category.ts';
import { TransactionType } from '@/core/transaction.ts';
import {
isString,
isNumber,
getNameByKeyValue,
objectFieldToArrayItem
} from '@/lib/common.js';
import { isFileExtensionSupported } from '@/lib/file.js';
import { generateRandomUUID } from '@/lib/misc.js';
} from '@/lib/common.ts';
import { isFileExtensionSupported } from '@/lib/file.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import logger from '@/lib/logger.js';
import {
parseDateFromUnixTime,
@@ -736,10 +736,10 @@ export default {
return getNameByKeyValue(this.allSupportedImportFileTypes, this.fileType, 'type', 'subTypes');
},
allTransactionTypes() {
return transactionConstants.allTransactionTypes;
return TransactionType;
},
allCategoryTypes() {
return categoryConstants.allCategoryTypes;
return CategoryType;
},
allAccounts() {
return this.accountsStore.allPlainAccounts;
@@ -1635,7 +1635,7 @@ export default {
}
}
for (let name in invalidCategoryNames) {
for (const name in invalidCategoryNames) {
if (!Object.prototype.hasOwnProperty.call(invalidCategoryNames, name)) {
continue;
}
@@ -1666,7 +1666,7 @@ export default {
}
}
for (let name in invalidAccountNames) {
for (const name in invalidAccountNames) {
if (!Object.prototype.hasOwnProperty.call(invalidAccountNames, name)) {
continue;
}
@@ -1700,7 +1700,7 @@ export default {
}
}
for (let name in invalidTagNames) {
for (const name in invalidTagNames) {
if (!Object.prototype.hasOwnProperty.call(invalidTagNames, name)) {
continue;
}
@@ -338,12 +338,12 @@ import { useAccountsStore } from '@/stores/account.js';
import { useOverviewStore } from '@/stores/overview.js';
import datetimeConstants from '@/consts/datetime.js';
import fileConstants from '@/consts/file.js';
import { getNameByKeyValue } from '@/lib/common.js';
import { generateRandomUUID } from '@/lib/misc.js';
import { SUPPORTED_IMAGE_EXTENSIONS } from '@/consts/file.ts';
import { getNameByKeyValue } from '@/lib/common.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import { getCategorizedAccounts } from '@/lib/account.js';
import { isUserVerifyEmailEnabled } from '@/lib/server_settings.js';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui.js';
import { isUserVerifyEmailEnabled } from '@/lib/server_settings.ts';
import { setExpenseAndIncomeAmountColor } from '@/lib/ui/common.ts';
import {
mdiAccount,
@@ -460,7 +460,7 @@ export default {
return this.$locale.getAllTransactionEditScopeTypes();
},
supportedImageExtensions() {
return fileConstants.supportedImageExtensions;
return SUPPORTED_IMAGE_EXTENSIONS;
},
currentUserAvatar() {
return this.userStore.getUserAvatarUrl(this.oldProfile, this.avatarNoCacheId);
@@ -162,9 +162,9 @@ import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { isEquals } from '@/lib/common.js';
import { isDataExportingEnabled } from '@/lib/server_settings.js';
import { startDownloadFile } from '@/lib/ui.js';
import { isEquals } from '@/lib/common.ts';
import { isDataExportingEnabled } from '@/lib/server_settings.ts';
import { startDownloadFile } from '@/lib/ui/common.ts';
import {
mdiRefresh,
@@ -135,8 +135,8 @@ import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { useTokensStore } from '@/stores/token.js';
import { isEquals } from '@/lib/common.js';
import { parseSessionInfo } from '@/lib/misc.js';
import { isEquals } from '@/lib/common.ts';
import { parseSessionInfo } from '@/lib/session.ts';
import {
mdiRefresh,
@@ -106,7 +106,7 @@
import { mapStores } from 'pinia';
import { useTwoFactorAuthStore } from '@/stores/twoFactorAuth.js';
import { makeButtonCopyToClipboard, changeClipboardObjectText } from '@/lib/misc.js';
import { ClipboardHolder } from '@/lib/clipboard.ts';
import {
mdiContentCopy
@@ -157,7 +157,7 @@ export default {
watch: {
'currentBackupCode': function (newValue) {
if (this.clipboardHolder) {
changeClipboardObjectText(this.clipboardHolder, newValue);
this.clipboardHolder.setClipboardText(newValue);
}
}
},
@@ -319,7 +319,7 @@ export default {
}
if (self.$refs.copyToClipboardIcon) {
self.clipboardHolder = makeButtonCopyToClipboard({
self.clipboardHolder = ClipboardHolder.create({
el: '#copy-to-clipboard-icon',
text: self.currentBackupCode,
successCallback: function () {