mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 16:07:33 +08:00
migrate transaction category store to composition API and typescript
This commit is contained in:
@@ -179,7 +179,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 { CategoryType } from '@/core/category.ts';
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<script>
|
||||
import { mapStores } from 'pinia';
|
||||
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
|
||||
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<template #default>
|
||||
<div class="grid grid-cols-2">
|
||||
<div class="list-item-subitem no-chevron">
|
||||
<a class="item-link" href="#" @click="category.showIconSelectionSheet = true">
|
||||
<a class="item-link" href="#" @click="showIconSelectionSheet = true">
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-header">
|
||||
@@ -100,12 +100,12 @@
|
||||
|
||||
<icon-selection-sheet :all-icon-infos="allCategoryIcons"
|
||||
:color="category.color"
|
||||
v-model:show="category.showIconSelectionSheet"
|
||||
v-model:show="showIconSelectionSheet"
|
||||
v-model="category.icon"
|
||||
></icon-selection-sheet>
|
||||
</div>
|
||||
<div class="list-item-subitem no-chevron">
|
||||
<a class="item-link" href="#" @click="category.showColorSelectionSheet = true">
|
||||
<a class="item-link" href="#" @click="showColorSelectionSheet = true">
|
||||
<div class="item-content">
|
||||
<div class="item-inner">
|
||||
<div class="item-header">
|
||||
@@ -121,7 +121,7 @@
|
||||
</a>
|
||||
|
||||
<color-selection-sheet :all-color-infos="allCategoryColors"
|
||||
v-model:show="category.showColorSelectionSheet"
|
||||
v-model:show="showColorSelectionSheet"
|
||||
v-model="category.color"
|
||||
></color-selection-sheet>
|
||||
</div>
|
||||
@@ -147,17 +147,19 @@
|
||||
|
||||
<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 { getNameByKeyValue } from '@/lib/common.ts';
|
||||
import { generateRandomUUID } from '@/lib/misc.ts';
|
||||
import {
|
||||
setCategoryModelByAnotherCategory,
|
||||
allVisiblePrimaryTransactionCategoriesByType
|
||||
} from '@/lib/category.js';
|
||||
} from '@/lib/category.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -165,19 +167,17 @@ export default {
|
||||
'f7router'
|
||||
],
|
||||
data() {
|
||||
const transactionCategoriesStore = useTransactionCategoriesStore();
|
||||
const query = this.f7route.query;
|
||||
const newTransactionCategory = transactionCategoriesStore.generateNewTransactionCategoryModel(parseInt(query.type), query.parentId);
|
||||
newTransactionCategory.showIconSelectionSheet = false;
|
||||
newTransactionCategory.showColorSelectionSheet = false;
|
||||
|
||||
return {
|
||||
editCategoryId: null,
|
||||
clientSessionId: '',
|
||||
loading: false,
|
||||
loadingError: null,
|
||||
category: newTransactionCategory,
|
||||
category: TransactionCategory.createNewCategory(parseInt(query.type), query.parentId),
|
||||
showPrimaryCategorySheet: false,
|
||||
showIconSelectionSheet: false,
|
||||
showColorSelectionSheet: false,
|
||||
submitting: false
|
||||
};
|
||||
},
|
||||
|
||||
@@ -88,14 +88,14 @@
|
||||
|
||||
<script>
|
||||
import { mapStores } from 'pinia';
|
||||
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
|
||||
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
|
||||
|
||||
import { CategoryType } from '@/core/category.ts';
|
||||
import {
|
||||
isNoAvailableCategory,
|
||||
getFirstShowingId,
|
||||
getLastShowingId
|
||||
} from '@/lib/category.js';
|
||||
} from '@/lib/category.ts';
|
||||
import { onSwipeoutDeleted } from '@/lib/ui/mobile.ts';
|
||||
|
||||
export default {
|
||||
|
||||
@@ -57,7 +57,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 { getObjectOwnFieldCount, categorizedArrayToPlainArray } from '@/lib/common.ts';
|
||||
|
||||
@@ -141,7 +141,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';
|
||||
|
||||
@@ -158,7 +158,7 @@ import {
|
||||
isCategoryOrSubCategoriesAllChecked,
|
||||
isSubCategoriesAllChecked,
|
||||
isSubCategoriesHasButNotAllChecked
|
||||
} from '@/lib/category.js';
|
||||
} from '@/lib/category.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -357,11 +357,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');
|
||||
|
||||
@@ -328,7 +328,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';
|
||||
|
||||
@@ -434,7 +434,7 @@ import { useSettingsStore } from '@/stores/setting.ts';
|
||||
import { useEnvironmentsStore } from '@/stores/environment.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';
|
||||
@@ -463,7 +463,7 @@ import {
|
||||
getTransactionPrimaryCategoryName,
|
||||
getTransactionSecondaryCategoryName,
|
||||
getFirstAvailableCategoryId
|
||||
} from '@/lib/category.js';
|
||||
} from '@/lib/category.ts';
|
||||
import { setTransactionModelByTransaction } from '@/lib/transaction.js';
|
||||
import {
|
||||
isTransactionPicturesEnabled,
|
||||
|
||||
@@ -524,7 +524,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';
|
||||
|
||||
@@ -548,7 +548,7 @@ import {
|
||||
getDateRangeByDateType,
|
||||
getDateRangeByBillingCycleDateType
|
||||
} from '@/lib/datetime.ts';
|
||||
import { categoryTypeToTransactionType, transactionTypeToCategoryType } from '@/lib/category.js';
|
||||
import { categoryTypeToTransactionType, transactionTypeToCategoryType } from '@/lib/category.ts';
|
||||
import { getUnifiedSelectedAccountsCurrencyOrDefaultCurrency } from '@/lib/account.js';
|
||||
import { getTransactionDisplayAmount } from '@/lib/transaction.js';
|
||||
import { onSwipeoutDeleted, scrollToSelectedItem } from '@/lib/ui/mobile.ts';
|
||||
|
||||
Reference in New Issue
Block a user