diff --git a/src/models/data_management.ts b/src/models/data_management.ts index 900226d4..521f6bc5 100644 --- a/src/models/data_management.ts +++ b/src/models/data_management.ts @@ -3,11 +3,21 @@ export interface ClearDataRequest { } export interface DataStatisticsResponse { - readonly totalAccountCount: number; - readonly totalTransactionCategoryCount: number; - readonly totalTransactionTagCount: number; - readonly totalTransactionCount: number; - readonly totalTransactionPictureCount: number; - readonly totalTransactionTemplateCount: number; - readonly totalScheduledTransactionCount: number; + readonly totalAccountCount: string; + readonly totalTransactionCategoryCount: string; + readonly totalTransactionTagCount: string; + readonly totalTransactionCount: string; + readonly totalTransactionPictureCount: string; + readonly totalTransactionTemplateCount: string; + readonly totalScheduledTransactionCount: string; +} + +export interface DisplayDataStatistics { + readonly totalAccountCount: string; + readonly totalTransactionCategoryCount: string; + readonly totalTransactionTagCount: string; + readonly totalTransactionCount: string; + readonly totalTransactionPictureCount: string; + readonly totalTransactionTemplateCount: string; + readonly totalScheduledTransactionCount: string; } diff --git a/src/views/base/users/DataManagementPageBase.ts b/src/views/base/users/DataManagementPageBase.ts new file mode 100644 index 00000000..8cf293c9 --- /dev/null +++ b/src/views/base/users/DataManagementPageBase.ts @@ -0,0 +1,52 @@ +import { ref, computed } from 'vue'; + +import { useI18n } from '@/locales/helpers.ts'; + +import { useUserStore } from '@/stores/user.ts'; + +import type { DataStatisticsResponse, DisplayDataStatistics } from '@/models/data_management.ts'; + +export function useDataManagementPageBase() { + const { tt, appendDigitGroupingSymbol } = useI18n(); + + const userStore = useUserStore(); + + const dataStatistics = ref(null); + + const displayDataStatistics = computed(() => { + if (!dataStatistics.value) { + return null; + } + + return { + totalTransactionCount: appendDigitGroupingSymbol(dataStatistics.value.totalTransactionCount), + totalAccountCount: appendDigitGroupingSymbol(dataStatistics.value.totalAccountCount), + totalTransactionCategoryCount: appendDigitGroupingSymbol(dataStatistics.value.totalTransactionCategoryCount), + totalTransactionTagCount: appendDigitGroupingSymbol(dataStatistics.value.totalTransactionTagCount), + totalTransactionPictureCount: appendDigitGroupingSymbol(dataStatistics.value.totalTransactionPictureCount), + totalTransactionTemplateCount: appendDigitGroupingSymbol(dataStatistics.value.totalTransactionTemplateCount), + totalScheduledTransactionCount: appendDigitGroupingSymbol(dataStatistics.value.totalScheduledTransactionCount) + }; + }); + + function getExportFileName(fileExtension: string): string { + const nickname = userStore.currentUserNickname; + + if (nickname) { + return tt('dataExport.exportFilename', { + nickname: nickname + }) + '.' + fileExtension; + } + + return tt('dataExport.defaultExportFilename') + '.' + fileExtension; + } + + return { + // states + dataStatistics, + // computed states + displayDataStatistics, + // functions + getExportFileName + } +} diff --git a/src/views/desktop/user/settings/tabs/UserDataManagementSettingTab.vue b/src/views/desktop/user/settings/tabs/UserDataManagementSettingTab.vue index bcbe50f8..81ac267a 100644 --- a/src/views/desktop/user/settings/tabs/UserDataManagementSettingTab.vue +++ b/src/views/desktop/user/settings/tabs/UserDataManagementSettingTab.vue @@ -4,14 +4,14 @@ @@ -70,7 +70,7 @@
- {{ $t(item.title) }} + {{ tt(item.title) }} {{ item.count }}
@@ -81,25 +81,24 @@
- - + + - {{ $t('Export all transaction data to file.') }} {{ $t('It may take a long time, please wait for a few minutes.') }} + {{ tt('Export all transaction data to file.') }} {{ tt('It may take a long time, please wait for a few minutes.') }} - - - {{ $t('Export Data') }} + + + {{ tt('Export Data') }} - {{ $t('CSV (Comma-separated values) File') }} + {{ tt('CSV (Comma-separated values) File') }} - {{ $t('TSV (Tab-separated values) File') }} + {{ tt('TSV (Tab-separated values) File') }} @@ -112,14 +111,14 @@ - {{ $t('You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.') }} + {{ tt('You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.') }} @@ -133,7 +132,7 @@ variant="underlined" color="error" :disabled="loadingDataStatistics || clearingData" - :placeholder="$t('Current Password')" + :placeholder="tt('Current Password')" v-model="currentPasswordForClearData" @keyup.enter="clearData" /> @@ -143,7 +142,7 @@ - {{ $t('Clear User Data') }} + {{ tt('Clear User Data') }} @@ -156,10 +155,16 @@ - diff --git a/src/views/mobile/users/DataManagementPage.vue b/src/views/mobile/users/DataManagementPage.vue index 2bec6756..b2c6ef11 100644 --- a/src/views/mobile/users/DataManagementPage.vue +++ b/src/views/mobile/users/DataManagementPage.vue @@ -1,6 +1,6 @@ -