From 26e9a0ef2ae976733c8b8340dbcb0e54a243d854 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 15 Jul 2024 01:25:33 +0800 Subject: [PATCH] only show chart data type of categorical analysis in statistics setting page --- src/lib/i18n.js | 9 +++++++-- .../app/settings/tabs/AppStatisticsSettingTab.vue | 3 ++- src/views/mobile/statistics/SettingsPage.vue | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib/i18n.js b/src/lib/i18n.js index 8244965e..a74563f4 100644 --- a/src/lib/i18n.js +++ b/src/lib/i18n.js @@ -13,6 +13,7 @@ import statisticsConstants from '@/consts/statistics.js'; import apiConstants from '@/consts/api.js'; import { + isDefined, isString, isNumber, isBoolean, @@ -995,7 +996,7 @@ function getAllTrendChartTypes(translateFn) { return allChartTypes; } -function getAllStatisticsChartDataTypes(translateFn) { +function getAllStatisticsChartDataTypes(translateFn, analysisType) { const allChartDataTypes = []; for (const dataTypeField in statisticsConstants.allChartDataTypes) { @@ -1005,6 +1006,10 @@ function getAllStatisticsChartDataTypes(translateFn) { const chartDataType = statisticsConstants.allChartDataTypes[dataTypeField]; + if (isDefined(analysisType) && !chartDataType.availableAnalysisTypes[analysisType]) { + continue; + } + allChartDataTypes.push({ type: chartDataType.type, displayName: translateFn(chartDataType.name), @@ -1468,7 +1473,7 @@ export function i18nFunctions(i18nGlobal) { getAllAccountTypes: () => getAllAccountTypes(i18nGlobal.t), getAllCategoricalChartTypes: () => getAllCategoricalChartTypes(i18nGlobal.t), getAllTrendChartTypes: () => getAllTrendChartTypes(i18nGlobal.t), - getAllStatisticsChartDataTypes: () => getAllStatisticsChartDataTypes(i18nGlobal.t), + getAllStatisticsChartDataTypes: (analysisType) => getAllStatisticsChartDataTypes(i18nGlobal.t, analysisType), getAllStatisticsSortingTypes: () => getAllStatisticsSortingTypes(i18nGlobal.t), getAllTransactionEditScopeTypes: () => getAllTransactionEditScopeTypes(i18nGlobal.t), getAllTransactionDefaultCategories: (categoryType, locale) => getAllTransactionDefaultCategories(categoryType, locale, i18nGlobal.t), diff --git a/src/views/desktop/app/settings/tabs/AppStatisticsSettingTab.vue b/src/views/desktop/app/settings/tabs/AppStatisticsSettingTab.vue index 6c778be6..1f39cb54 100644 --- a/src/views/desktop/app/settings/tabs/AppStatisticsSettingTab.vue +++ b/src/views/desktop/app/settings/tabs/AppStatisticsSettingTab.vue @@ -129,6 +129,7 @@ import { mapStores } from 'pinia'; import { useSettingsStore } from '@/stores/setting.js'; import datetimeConstants from '@/consts/datetime.js'; +import statisticsConstants from '@/consts/statistics.js'; import AccountFilterSettingsCard from '@/views/desktop/common/cards/AccountFilterSettingsCard.vue'; import CategoryFilterSettingsCard from '@/views/desktop/common/cards/CategoryFilterSettingsCard.vue'; @@ -141,7 +142,7 @@ export default { computed: { ...mapStores(useSettingsStore), allChartDataTypes() { - return this.$locale.getAllStatisticsChartDataTypes(); + return this.$locale.getAllStatisticsChartDataTypes(statisticsConstants.allAnalysisTypes.CategoricalAnalysis); }, allTimezoneTypesUsedForStatistics() { return this.$locale.getAllTimezoneTypesUsedForStatistics(); diff --git a/src/views/mobile/statistics/SettingsPage.vue b/src/views/mobile/statistics/SettingsPage.vue index 150bd175..322e4778 100644 --- a/src/views/mobile/statistics/SettingsPage.vue +++ b/src/views/mobile/statistics/SettingsPage.vue @@ -92,12 +92,13 @@ import { mapStores } from 'pinia'; import { useSettingsStore } from '@/stores/setting.js'; import datetimeConstants from '@/consts/datetime.js'; +import statisticsConstants from '@/consts/statistics.js'; export default { computed: { ...mapStores(useSettingsStore), allChartDataTypes() { - return this.$locale.getAllStatisticsChartDataTypes(); + return this.$locale.getAllStatisticsChartDataTypes(statisticsConstants.allAnalysisTypes.CategoricalAnalysis); }, allTimezoneTypesUsedForStatistics() { return this.$locale.getAllTimezoneTypesUsedForStatistics();