WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 8b34750

Browse files
committed
fix the incorrect display type name of transaction categories
1 parent 32cb2b2 commit 8b34750

File tree

8 files changed

+24
-26
lines changed

8 files changed

+24
-26
lines changed

src/lib/category.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
189189
}
190190
}
191191

192-
ret[categoryType] = {
192+
ret[`${categoryType}`] = {
193193
type: categoryType,
194194
allCategories: allCategories,
195195
allVisibleCategoryCount: allVisibleCategoryCount,
@@ -374,7 +374,7 @@ export function getLastShowingId(categories: TransactionCategory[], showHidden:
374374
return null;
375375
}
376376

377-
export function containsAnyAvailableCategory(allTransactionCategories: Record<number, TransactionCategoriesWithVisibleCount>, showHidden: boolean): boolean {
377+
export function containsAnyAvailableCategory(allTransactionCategories: Record<string, TransactionCategoriesWithVisibleCount>, showHidden: boolean): boolean {
378378
for (const categoryType of values(allTransactionCategories)) {
379379
if (showHidden) {
380380
if (categoryType.allCategories && categoryType.allCategories.length > 0) {
@@ -390,7 +390,7 @@ export function containsAnyAvailableCategory(allTransactionCategories: Record<nu
390390
return false;
391391
}
392392

393-
export function containsAvailableCategory(allTransactionCategories: Record<number, TransactionCategoriesWithVisibleCount>, showHidden: boolean): Record<number, boolean> {
393+
export function containsAvailableCategory(allTransactionCategories: Record<string, TransactionCategoriesWithVisibleCount>, showHidden: boolean): Record<number, boolean> {
394394
const result: Record<number, boolean> = {};
395395

396396
for (const [type, categoryType] of entries(allTransactionCategories)) {

src/locales/helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useI18n as useVueI18n } from 'vue-i18n';
22
import moment from 'moment-timezone';
33
import 'moment-timezone/moment-timezone-utils';
44

5-
import type { PartialRecord, NameValue, TypeAndName, TypeAndDisplayName, LocalizedSwitchOption } from '@/core/base.ts';
5+
import type { NameValue, TypeAndName, TypeAndDisplayName, LocalizedSwitchOption } from '@/core/base.ts';
66

77
import {
88
type LanguageInfo,
@@ -1341,8 +1341,8 @@ export function useI18n() {
13411341
return ret;
13421342
}
13431343

1344-
function getAllTransactionDefaultCategories(categoryType: 0 | CategoryType, locale: string): PartialRecord<CategoryType, LocalizedPresetCategory[]> {
1345-
const allCategories: PartialRecord<CategoryType, LocalizedPresetCategory[]> = {};
1344+
function getAllTransactionDefaultCategories(categoryType: 0 | CategoryType, locale: string): Record<string, LocalizedPresetCategory[]> {
1345+
const allCategories: Record<string, LocalizedPresetCategory[]> = {};
13461346
const categoryTypes: CategoryType[] = [];
13471347

13481348
if (categoryType === 0) {
@@ -1386,7 +1386,7 @@ export function useI18n() {
13861386
categories.push(submitCategory);
13871387
}
13881388

1389-
allCategories[categoryType] = categories;
1389+
allCategories[`${categoryType}`] = categories;
13901390
}
13911391

13921392
return allCategories;

src/views/base/SignupPageBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function useSignupPageBase() {
9393
const inputIsEmpty = computed<boolean>(() => !!inputEmptyProblemMessage.value);
9494
const inputIsInvalid = computed<boolean>(() => !!inputInvalidProblemMessage.value);
9595

96-
function getCategoryTypeName(categoryType: CategoryType): string {
96+
function getCategoryTypeName(categoryType: number): string {
9797
switch (categoryType) {
9898
case CategoryType.Income:
9999
return tt('Income Categories');

src/views/base/settings/CategoryFilterSettingPageBase.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allo
5656
}
5757
});
5858

59-
const allTransactionCategories = computed<Record<number, TransactionCategoriesWithVisibleCount>>(() => allTransactionCategoriesWithVisibleCount(transactionCategoriesStore.allTransactionCategories, allowCategoryTypes));
59+
const allTransactionCategories = computed<Record<string, TransactionCategoriesWithVisibleCount>>(() => allTransactionCategoriesWithVisibleCount(transactionCategoriesStore.allTransactionCategories, allowCategoryTypes));
6060
const hasAnyAvailableCategory = computed<boolean>(() => containsAnyAvailableCategory(allTransactionCategories.value, true));
6161
const hasAnyVisibleCategory = computed<boolean>(() => containsAnyAvailableCategory(allTransactionCategories.value, showHidden.value));
6262
const hasAvailableCategory = computed<Record<number, boolean>>(() => containsAvailableCategory(allTransactionCategories.value, showHidden.value));
@@ -65,7 +65,7 @@ export function useCategoryFilterSettingPageBase(type?: CategoryFilterType, allo
6565
return !filterCategoryIds[category.id];
6666
}
6767

68-
function getCategoryTypeName(categoryType: CategoryType): string {
68+
function getCategoryTypeName(categoryType: number): string {
6969
switch (categoryType) {
7070
case CategoryType.Income:
7171
return tt('Income Categories');

src/views/desktop/SignupPage.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<div class="overflow-y-auto px-3" :class="{ 'disabled': !usePresetCategories || submitting || navigateToHomePage }" style="max-height: 323px">
140140
<v-row :key="categoryType" v-for="(categories, categoryType) in allPresetCategories">
141141
<v-col cols="12" md="12">
142-
<h4 class="mb-3">{{ getCategoryTypeName(categoryType) }}</h4>
142+
<h4 class="mb-3">{{ getCategoryTypeName(parseInt(categoryType)) }}</h4>
143143

144144
<v-expansion-panels class="border rounded" variant="accordion" multiple>
145145
<v-expansion-panel :key="idx" v-for="(category, idx) in categories">
@@ -220,8 +220,8 @@ import { useSignupPageBase } from '@/views/base/SignupPageBase.ts';
220220
221221
import { useRootStore } from '@/stores/index.ts';
222222
223-
import type { PartialRecord, TypeAndDisplayName } from '@/core/base.ts';
224-
import { type LocalizedPresetCategory, CategoryType } from '@/core/category.ts';
223+
import type { TypeAndDisplayName } from '@/core/base.ts';
224+
import { type LocalizedPresetCategory } from '@/core/category.ts';
225225
import { ThemeType } from '@/core/theme.ts';
226226
import { APPLICATION_LOGO_PATH } from '@/consts/asset.ts';
227227
@@ -262,7 +262,7 @@ const finalResultMessage = ref<string | null>(null);
262262
const navigateToHomePage = ref<boolean>(false);
263263
264264
const allWeekDays = computed<TypeAndDisplayName[]>(() => getAllWeekDays());
265-
const allPresetCategories = computed<PartialRecord<CategoryType, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(0, currentLocale.value));
265+
const allPresetCategories = computed<Record<string, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(0, currentLocale.value));
266266
const isDarkMode = computed<boolean>(() => theme.global.name.value === ThemeType.Dark);
267267
268268
const allSteps = computed<StepBarItem[]>(() => {

src/views/desktop/categories/list/dialogs/PresetDialog.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<v-card-text class="preset-transaction-categories mt-sm-2 mt-md-4 pt-0">
1010
<template :key="categoryType" v-for="(categories, categoryType) in allPresetCategories">
1111
<div class="d-flex align-center mb-1">
12-
<h4>{{ getCategoryTypeName(categoryType) }}</h4>
12+
<h4>{{ getCategoryTypeName(parseInt(categoryType)) }}</h4>
1313
<v-spacer/>
1414
<language-select-button :disabled="submitting"
1515
:use-model-value="true" v-model="currentLocale" />
@@ -64,7 +64,6 @@ import { useI18n } from '@/locales/helpers.ts';
6464
6565
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
6666
67-
import type { PartialRecord } from '@/core/base.ts';
6867
import { type LocalizedPresetCategory, CategoryType } from '@/core/category.ts';
6968
import { categorizedArrayToPlainArray } from '@/lib/common.ts';
7069
import { localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories } from '@/lib/category.ts';
@@ -90,14 +89,14 @@ const snackbar = useTemplateRef<SnackBarType>('snackbar');
9089
const currentLocale = ref<string>(getCurrentLanguageTag());
9190
const submitting = ref<boolean>(false);
9291
93-
const allPresetCategories = computed<PartialRecord<CategoryType, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(props.categoryType, currentLocale.value));
92+
const allPresetCategories = computed<Record<string, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(props.categoryType, currentLocale.value));
9493
9594
const showState = computed<boolean>({
9695
get: () => props.show,
9796
set: (value) => emit('update:show', value)
9897
});
9998
100-
function getCategoryTypeName(categoryType: CategoryType): string {
99+
function getCategoryTypeName(categoryType: number): string {
101100
switch (categoryType) {
102101
case CategoryType.Income:
103102
return tt('Income Categories');

src/views/mobile/SignupPage.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
</f7-navbar>
147147
<f7-block class="no-padding no-margin"
148148
:key="categoryType" v-for="(categories, categoryType) in allPresetCategories">
149-
<f7-block-title class="margin-top margin-horizontal">{{ getCategoryTypeName(categoryType) }}</f7-block-title>
149+
<f7-block-title class="margin-top margin-horizontal">{{ getCategoryTypeName(parseInt(categoryType)) }}</f7-block-title>
150150
<f7-list strong inset dividers v-if="showPresetCategories">
151151
<f7-list-item :title="category.name"
152152
:accordion-item="!!category.subCategories.length"
@@ -203,9 +203,9 @@ import { useSignupPageBase } from '@/views/base/SignupPageBase.ts';
203203
204204
import { useRootStore } from '@/stores/index.ts';
205205
206-
import type { PartialRecord, TypeAndDisplayName } from '@/core/base.ts';
206+
import type { TypeAndDisplayName } from '@/core/base.ts';
207207
import type { LocalizedCurrencyInfo } from '@/core/currency.ts';
208-
import { type LocalizedPresetCategory, CategoryType } from '@/core/category.ts';
208+
import { type LocalizedPresetCategory } from '@/core/category.ts';
209209
210210
import { findDisplayNameByType, categorizedArrayToPlainArray } from '@/lib/common.ts';
211211
import { isUserLogined } from '@/lib/userstate.ts';
@@ -244,7 +244,7 @@ const showPresetCategoriesChangeLocaleSheet = ref<boolean>(false);
244244
const allLanguages = computed<LanguageOption[]>(() => getAllLanguageOptions(false));
245245
const allCurrencies = computed<LocalizedCurrencyInfo[]>(() => getAllCurrencies());
246246
const allWeekDays = computed<TypeAndDisplayName[]>(() => getAllWeekDays());
247-
const allPresetCategories = computed<PartialRecord<CategoryType, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(0, currentLocale.value));
247+
const allPresetCategories = computed<Record<string, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(0, currentLocale.value));
248248
const currentDayOfWeekName = computed<string | null>(() => findDisplayNameByType(allWeekDays.value, user.value.firstDayOfWeek));
249249
250250
function submit(): void {

src/views/mobile/categories/PresetPage.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</f7-navbar>
1111

1212
<f7-block class="no-padding no-margin" :key="categoryType" v-for="(categories, categoryType) in allPresetCategories">
13-
<f7-block-title class="margin-top margin-horizontal">{{ getCategoryTypeName(categoryType) }}</f7-block-title>
13+
<f7-block-title class="margin-top margin-horizontal">{{ getCategoryTypeName(parseInt(categoryType)) }}</f7-block-title>
1414

1515
<f7-list strong inset dividers class="margin-top">
1616
<f7-list-item :title="category.name"
@@ -64,7 +64,6 @@ import type { Router } from 'framework7/types';
6464
import { useI18n } from '@/locales/helpers.ts';
6565
import { useI18nUIComponents, showLoading, hideLoading } from '@/lib/ui/mobile.ts';
6666
67-
import type { PartialRecord } from '@/core/base.ts';
6867
import type { LanguageOption } from '@/locales/index.ts';
6968
import { type LocalizedPresetCategory, CategoryType } from '@/core/category.ts';
7069
import { getObjectOwnFieldCount, categorizedArrayToPlainArray } from '@/lib/common.ts';
@@ -88,10 +87,10 @@ const showMoreActionSheet = ref<boolean>(false);
8887
const showChangeLocaleSheet = ref<boolean>(false);
8988
9089
const allLanguages = computed<LanguageOption[]>(() => getAllLanguageOptions(false));
91-
const allPresetCategories = computed<PartialRecord<CategoryType, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(categoryType.value, currentLocale.value));
90+
const allPresetCategories = computed<Record<string, LocalizedPresetCategory[]>>(() => getAllTransactionDefaultCategories(categoryType.value, currentLocale.value));
9291
const isPresetHasCategories = computed<boolean>(() => getObjectOwnFieldCount(allPresetCategories.value) > 0);
9392
94-
function getCategoryTypeName(categoryType: CategoryType): string {
93+
function getCategoryTypeName(categoryType: number): string {
9594
switch (categoryType) {
9695
case CategoryType.Income:
9796
return tt('Income Categories');

0 commit comments

Comments
 (0)