migrate transaction category store to composition API and typescript

This commit is contained in:
MaysWind
2025-01-12 23:47:56 +08:00
parent abb26ac410
commit 2be329974e
28 changed files with 818 additions and 663 deletions
+1 -1
View File
@@ -241,7 +241,7 @@ import { mapStores } from 'pinia';
import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.ts';
import { useUserStore } from '@/stores/user.ts';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { useExchangeRatesStore } from '@/stores/exchangeRates.ts';
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
+2 -2
View File
@@ -198,13 +198,13 @@ import PresetDialog from './list/dialogs/PresetDialog.vue';
import { useDisplay } from 'vuetify';
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { CategoryType } from '@/core/category.ts';
import {
isNoAvailableCategory,
getAvailableCategoryCount
} from '@/lib/category.js';
} from '@/lib/category.ts';
import { getNavSideBarOuterHeight } from '@/lib/ui/desktop.ts';
import {
@@ -95,16 +95,18 @@
<script>
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { CategoryType } from '@/core/category.ts';
import { ALL_CATEGORY_ICONS } from '@/consts/icon.ts';
import { ALL_CATEGORY_COLORS } from '@/consts/color.ts';
import { TransactionCategory } from '@/models/transaction_category.ts';
import { generateRandomUUID } from '@/lib/misc.ts';
import {
setCategoryModelByAnotherCategory,
allVisiblePrimaryTransactionCategoriesByType
} from '@/lib/category.js';
} from '@/lib/category.ts';
export default {
props: [
@@ -115,15 +117,12 @@ export default {
'open'
],
data() {
const transactionCategoriesStore = useTransactionCategoriesStore();
const newTransactionCategory = transactionCategoriesStore.generateNewTransactionCategoryModel();
return {
showState: false,
editCategoryId: null,
clientSessionId: '',
loading: false,
category: newTransactionCategory,
category: TransactionCategory.createNewCategory(),
submitting: false,
resolve: null,
reject: null
@@ -176,7 +175,7 @@ export default {
self.loading = true;
self.submitting = false;
const newTransactionCategory = self.transactionCategoriesStore.generateNewTransactionCategoryModel();
const newTransactionCategory = TransactionCategory.createNewCategory();
setCategoryModelByAnotherCategory(self.category, newTransactionCategory);
if (options.id) {
@@ -68,7 +68,7 @@
<script>
import { mapStores } from 'pinia';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { CategoryType } from '@/core/category.ts';
import { categorizedArrayToPlainArray } from '@/lib/common.ts';
@@ -145,7 +145,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.ts';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useStatisticsStore } from '@/stores/statistics.js';
@@ -162,7 +162,7 @@ import {
isCategoryOrSubCategoriesAllChecked,
isSubCategoriesAllChecked,
isSubCategoriesHasButNotAllChecked
} from '@/lib/category.js';
} from '@/lib/category.ts';
import {
mdiSelectAll,
@@ -187,9 +187,9 @@ export default {
return {
loading: true,
expandCategoryTypes: [
CategoryType.Income.toString(),
CategoryType.Expense.toString(),
CategoryType.Transfer.toString()
CategoryType.Income,
CategoryType.Expense,
CategoryType.Transfer
],
filterCategoryIds: {},
showHidden: false,
@@ -388,11 +388,11 @@ export default {
},
getCategoryTypeName(categoryType) {
switch (categoryType) {
case CategoryType.Income.toString():
case CategoryType.Income:
return this.$t('Income Categories');
case CategoryType.Expense.toString():
case CategoryType.Expense:
return this.$t('Expense Categories');
case CategoryType.Transfer.toString():
case CategoryType.Transfer:
return this.$t('Transfer Categories');
default:
return this.$t('Transaction Categories');
@@ -322,7 +322,7 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.ts';
import { useUserStore } from '@/stores/user.ts';
import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { useStatisticsStore } from '@/stores/statistics.js';
import { DateRangeScene, DateRange } from '@/core/datetime.ts';
+2 -2
View File
@@ -591,7 +591,7 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.ts';
import { useUserStore } from '@/stores/user.ts';
import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { useTransactionTagsStore } from '@/stores/transactionTag.ts';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useTransactionTemplatesStore } from '@/stores/transactionTemplate.js';
@@ -627,7 +627,7 @@ import {
import {
categoryTypeToTransactionType,
transactionTypeToCategoryType
} from '@/lib/category.js';
} from '@/lib/category.ts';
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.js';
import { getTransactionDisplayAmount } from '@/lib/transaction.js';
import { isDataImportingEnabled } from '@/lib/server_settings.ts';
@@ -175,7 +175,7 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.ts';
import { useUserStore } from '@/stores/user.ts';
import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { useTransactionTagsStore } from '@/stores/transactionTag.ts';
import { useExchangeRatesStore } from '@/stores/exchangeRates.ts';
@@ -187,7 +187,7 @@ import {
getTransactionPrimaryCategoryName,
getTransactionSecondaryCategoryName,
getFirstAvailableCategoryId
} from '@/lib/category.js';
} from '@/lib/category.ts';
import {
mdiPound
@@ -394,7 +394,7 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.ts';
import { useUserStore } from '@/stores/user.ts';
import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { useTransactionTagsStore } from '@/stores/transactionTag.ts';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useTransactionTemplatesStore } from '@/stores/transactionTemplate.js';
@@ -421,7 +421,7 @@ import {
getTransactionPrimaryCategoryName,
getTransactionSecondaryCategoryName,
getFirstAvailableCategoryId
} from '@/lib/category.js';
} from '@/lib/category.ts';
import { setTransactionModelByTransaction } from '@/lib/transaction.js';
import {
isTransactionPicturesEnabled,
@@ -600,7 +600,7 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.ts';
import { useUserStore } from '@/stores/user.ts';
import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import { useTransactionTagsStore } from '@/stores/transactionTag.ts';
import { useTransactionsStore } from '@/stores/transaction.js';
import { useOverviewStore } from '@/stores/overview.ts';
@@ -628,7 +628,7 @@ import {
getTransactionPrimaryCategoryName,
getTransactionSecondaryCategoryName,
getFirstAvailableCategoryId
} from '@/lib/category.js';
} from '@/lib/category.ts';
import {
mdiFilterOutline,