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
@@ -9,34 +9,36 @@
</f7-nav-right>
</f7-navbar>
<f7-block class="combination-list-wrapper margin-vertical skeleton-text"
:key="blockIdx" v-for="blockIdx in [ 1, 2, 3 ]" v-if="loading">
<f7-accordion-item>
<f7-block-title>
<f7-accordion-toggle>
<f7-list strong inset dividers media-list
class="combination-list-header combination-list-opened">
<f7-list-item>
<template #title>
<span>Account Category</span>
<f7-icon class="combination-list-chevron-icon" f7="chevron_up"></f7-icon>
<div class="skeleton-text" v-if="loading">
<f7-block class="combination-list-wrapper margin-vertical"
:key="blockIdx" v-for="blockIdx in [ 1, 2, 3 ]">
<f7-accordion-item>
<f7-block-title>
<f7-accordion-toggle>
<f7-list strong inset dividers media-list
class="combination-list-header combination-list-opened">
<f7-list-item>
<template #title>
<span>Account Category</span>
<f7-icon class="combination-list-chevron-icon" f7="chevron_up"></f7-icon>
</template>
</f7-list-item>
</f7-list>
</f7-accordion-toggle>
</f7-block-title>
<f7-accordion-content style="height: auto">
<f7-list strong inset dividers accordion-list class="combination-list-content">
<f7-list-item checkbox class="disabled" title="Account Name"
:key="itemIdx" v-for="itemIdx in (blockIdx === 1 ? [ 1 ] : [ 1, 2 ])">
<template #media>
<f7-icon f7="app_fill"></f7-icon>
</template>
</f7-list-item>
</f7-list>
</f7-accordion-toggle>
</f7-block-title>
<f7-accordion-content style="height: auto">
<f7-list strong inset dividers accordion-list class="combination-list-content">
<f7-list-item checkbox class="disabled" title="Account Name"
:key="itemIdx" v-for="itemIdx in (blockIdx === 1 ? [ 1 ] : [ 1, 2 ])">
<template #media>
<f7-icon f7="app_fill"></f7-icon>
</template>
</f7-list-item>
</f7-list>
</f7-accordion-content>
</f7-accordion-item>
</f7-block>
</f7-accordion-content>
</f7-accordion-item>
</f7-block>
</div>
<f7-list strong inset dividers accordion-list class="margin-top" v-if="!loading && !hasAnyVisibleAccount">
<f7-list-item :title="$t('No available account')"></f7-list-item>
@@ -67,7 +69,7 @@
<f7-accordion-content :style="{ height: collapseStates[accountCategory.category].opened ? 'auto' : '' }">
<f7-list strong inset dividers accordion-list class="combination-list-content">
<f7-list-item checkbox
:class="{ 'has-child-list-item': account.type === allAccountTypes.MultiSubAccounts && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id]) }"
:class="{ 'has-child-list-item': account.type === allAccountTypes.MultiSubAccounts.type && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id]) }"
:title="account.name"
:value="account.id"
:checked="isAccountOrSubAccountsAllChecked(account, filterAccountIds)"
@@ -86,7 +88,7 @@
<template #root>
<ul class="padding-left"
v-if="account.type === allAccountTypes.MultiSubAccounts && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id])">
v-if="account.type === allAccountTypes.MultiSubAccounts.type && ((showHidden && accountCategory.allSubAccounts[account.id]) || accountCategory.allVisibleSubAccountCounts[account.id])">
<f7-list-item checkbox
:title="subAccount.name"
:value="subAccount.id"
@@ -136,8 +138,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,
@@ -183,7 +185,7 @@ export default {
}
},
allAccountTypes() {
return accountConstants.allAccountTypes;
return AccountType.all();
},
allCategorizedAccounts() {
return getCategorizedAccountsWithVisibleCount(this.accountsStore.allCategorizedAccountsMap);
@@ -212,7 +214,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;
}
@@ -231,7 +233,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;
}
@@ -268,7 +270,7 @@ export default {
let isAllSelected = true;
let finalAccountIds = '';
for (let accountId in self.filterAccountIds) {
for (const accountId in self.filterAccountIds) {
if (!Object.prototype.hasOwnProperty.call(self.filterAccountIds, accountId)) {
continue;
}
@@ -345,15 +347,12 @@ export default {
},
getCollapseStates() {
const collapseStates = {};
const allCategories = AccountCategory.values();
for (let categoryType in accountConstants.allCategories) {
if (!Object.prototype.hasOwnProperty.call(accountConstants.allCategories, categoryType)) {
continue;
}
for (let i = 0; i < allCategories.length; i++) {
const accountCategory = allCategories[i];
const accountCategory = accountConstants.allCategories[categoryType];
collapseStates[accountCategory.id] = {
collapseStates[accountCategory.type] = {
opened: true
};
}
@@ -9,44 +9,46 @@
</f7-nav-right>
</f7-navbar>
<f7-block class="combination-list-wrapper margin-vertical skeleton-text"
:key="blockIdx" v-for="blockIdx in [ 1, 2 ]" v-if="loading">
<f7-accordion-item>
<f7-block-title>
<f7-accordion-toggle>
<f7-list strong inset dividers media-list
class="combination-list-header combination-list-opened">
<f7-list-item>
<template #title>
<span>Transaction Category</span>
<f7-icon class="combination-list-chevron-icon" f7="chevron_up"></f7-icon>
<div class="skeleton-text" v-if="loading">
<f7-block class="combination-list-wrapper margin-vertical"
:key="blockIdx" v-for="blockIdx in [ 1, 2 ]">
<f7-accordion-item>
<f7-block-title>
<f7-accordion-toggle>
<f7-list strong inset dividers media-list
class="combination-list-header combination-list-opened">
<f7-list-item>
<template #title>
<span>Transaction Category</span>
<f7-icon class="combination-list-chevron-icon" f7="chevron_up"></f7-icon>
</template>
</f7-list-item>
</f7-list>
</f7-accordion-toggle>
</f7-block-title>
<f7-accordion-content style="height: auto">
<f7-list strong inset dividers accordion-list class="combination-list-content">
<f7-list-item checkbox class="disabled" title="Category Name"
:key="itemIdx" v-for="itemIdx in [ 1, 2 ]">
<template #media>
<f7-icon f7="app_fill"></f7-icon>
</template>
<template #root>
<ul class="padding-left">
<f7-list-item checkbox class="disabled" title="Sub Category Name"
:key="subItemIdx" v-for="subItemIdx in [ 1, 2, 3 ]">
<template #media>
<f7-icon f7="app_fill"></f7-icon>
</template>
</f7-list-item>
</ul>
</template>
</f7-list-item>
</f7-list>
</f7-accordion-toggle>
</f7-block-title>
<f7-accordion-content style="height: auto">
<f7-list strong inset dividers accordion-list class="combination-list-content">
<f7-list-item checkbox class="disabled" title="Category Name"
:key="itemIdx" v-for="itemIdx in [ 1, 2 ]">
<template #media>
<f7-icon f7="app_fill"></f7-icon>
</template>
<template #root>
<ul class="padding-left">
<f7-list-item checkbox class="disabled" title="Sub Category Name"
:key="subItemIdx" v-for="subItemIdx in [ 1, 2, 3 ]">
<template #media>
<f7-icon f7="app_fill"></f7-icon>
</template>
</f7-list-item>
</ul>
</template>
</f7-list-item>
</f7-list>
</f7-accordion-content>
</f7-accordion-item>
</f7-block>
</f7-accordion-content>
</f7-accordion-item>
</f7-block>
</div>
<f7-block class="combination-list-wrapper margin-vertical"
:key="transactionType.type"
@@ -143,8 +145,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,
@@ -220,7 +222,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;
}
@@ -243,7 +245,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;
}
@@ -283,7 +285,7 @@ export default {
let isAllSelected = true;
let finalCategoryIds = '';
for (let categoryId in self.filterCategoryIds) {
for (const categoryId in self.filterCategoryIds) {
if (!Object.prototype.hasOwnProperty.call(self.filterCategoryIds, categoryId)) {
continue;
}
@@ -347,11 +349,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');
@@ -369,12 +371,12 @@ export default {
getCollapseStates() {
const collapseStates = {};
for (let categoryTypeField in categoryConstants.allCategoryTypes) {
if (!Object.prototype.hasOwnProperty.call(categoryConstants.allCategoryTypes, categoryTypeField)) {
for (const categoryTypeField in CategoryType) {
if (!Object.prototype.hasOwnProperty.call(CategoryType, categoryTypeField)) {
continue;
}
const categoryType = categoryConstants.allCategoryTypes[categoryTypeField];
const categoryType = CategoryType[categoryTypeField];
collapseStates[categoryType] = {
opened: true
@@ -116,9 +116,9 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import fontConstants from '@/consts/font.js';
import { FontSize } from '@/core/font.ts';
import { getCurrentUnixTime, getDay, getDayOfWeekName } from '@/lib/datetime.js';
import { setAppFontSize, getFontSizePreviewClassName } from '@/lib/ui.mobile.js';
import { setAppFontSize, getFontSizePreviewClassName } from '@/lib/ui/mobile.js';
export default {
props: [
@@ -135,10 +135,10 @@ export default {
computed: {
...mapStores(useSettingsStore, useUserStore),
minFontSizeType() {
return 0;
return FontSize.MinimumFontSize.type;
},
maxFontSizeType() {
return fontConstants.allFontSizeArray.length - 1;
return FontSize.MaximumFontSize.type;
},
fontSizePreviewClassName() {
return getFontSizePreviewClassName(this.fontSize);
@@ -116,13 +116,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';
export default {
props: [
@@ -135,7 +135,7 @@ export default {
loadingError: null,
type: null,
filterTagIds: {},
tagFilterType: transactionConstants.defaultTransactionTagFilterType.type,
tagFilterType: TransactionTagFilterType.Default.type,
showHidden: false,
collapseStates: {
'default': {
@@ -183,7 +183,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;
}
@@ -193,7 +193,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];
@@ -206,7 +206,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;
}
@@ -243,7 +243,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;
}