From 9a037ace5ae6ebb1e1b3570dfb3e828543acc2ff Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 5 Jan 2026 00:48:47 +0800 Subject: [PATCH] remember last selected file type in import transaction dialog (#412) --- pkg/models/user_app_cloud_setting.go | 3 + src/core/setting.ts | 9 +++ src/locales/de.json | 2 + src/locales/en.json | 2 + src/locales/es.json | 2 + src/locales/fr.json | 2 + src/locales/it.json | 2 + src/locales/ja.json | 2 + src/locales/kn.json | 2 + src/locales/ko.json | 2 + src/locales/nl.json | 2 + src/locales/pt_BR.json | 2 + src/locales/ru.json | 2 + src/locales/sl.json | 2 + src/locales/th.json | 2 + src/locales/tr.json | 2 + src/locales/uk.json | 2 + src/locales/vi.json | 2 + src/locales/zh_Hans.json | 2 + src/locales/zh_Hant.json | 2 + src/stores/setting.ts | 24 ++++++++ .../base/settings/AppCloudSyncPageBase.ts | 45 ++++++++++++++- .../app/settings/tabs/AppBasicSettingTab.vue | 27 +++++++++ .../settings/tabs/AppCloudSyncSettingTab.vue | 3 +- .../transactions/import/ImportDialog.vue | 55 ++++++++++++++++++- .../ApplicationCloudSyncSettingsPage.vue | 3 +- 26 files changed, 201 insertions(+), 4 deletions(-) diff --git a/pkg/models/user_app_cloud_setting.go b/pkg/models/user_app_cloud_setting.go index 6b512473..3817bd6a 100644 --- a/pkg/models/user_app_cloud_setting.go +++ b/pkg/models/user_app_cloud_setting.go @@ -29,6 +29,9 @@ var ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES = map[string]UserApplicationClo "autoSaveTransactionDraft": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING, "autoGetCurrentGeoLocation": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN, "alwaysShowTransactionPicturesInMobileTransactionEditPage": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN, + // Import Transaction Dialog + "rememberLastSelectedFileTypeInImportTransactionDialog": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN, + "lastSelectedFileTypeInImportTransactionDialog": USER_APPLICATION_CLOUD_SETTING_TYPE_STRING, // Insights Explorer Page "insightsExplorerDefaultDateRangeType": USER_APPLICATION_CLOUD_SETTING_TYPE_NUMBER, "showTagInInsightsExplorerPage": USER_APPLICATION_CLOUD_SETTING_TYPE_BOOLEAN, diff --git a/src/core/setting.ts b/src/core/setting.ts index 61c4babc..71467168 100644 --- a/src/core/setting.ts +++ b/src/core/setting.ts @@ -50,6 +50,9 @@ export interface ApplicationSettings extends BaseApplicationSetting { autoSaveTransactionDraft: string; autoGetCurrentGeoLocation: boolean; alwaysShowTransactionPicturesInMobileTransactionEditPage: boolean; + // Import Transaction Dialog + rememberLastSelectedFileTypeInImportTransactionDialog: boolean; + lastSelectedFileTypeInImportTransactionDialog: string; // Insights Explorer Page insightsExplorerDefaultDateRangeType: number; showTagInInsightsExplorerPage: boolean; @@ -117,6 +120,9 @@ export const ALL_ALLOWED_CLOUD_SYNC_APP_SETTING_KEY_TYPES: Record { updateUserApplicationCloudSettingValue('alwaysShowTransactionPicturesInMobileTransactionEditPage', value); } + // Import Transaction Dialog + function setRememberLastSelectedFileTypeInImportTransactionDialog(value: boolean): void { + updateApplicationSettingsValue('rememberLastSelectedFileTypeInImportTransactionDialog', value); + appSettings.value.rememberLastSelectedFileTypeInImportTransactionDialog = value; + updateUserApplicationCloudSettingValue('rememberLastSelectedFileTypeInImportTransactionDialog', value); + + if (!value) { + setLastSelectedFileTypeInImportTransactionDialog(''); + } + } + + function setLastSelectedFileTypeInImportTransactionDialog(value: string): void { + if (!appSettings.value.rememberLastSelectedFileTypeInImportTransactionDialog) { + value = ''; + } + + updateApplicationSettingsValue('lastSelectedFileTypeInImportTransactionDialog', value); + appSettings.value.lastSelectedFileTypeInImportTransactionDialog = value; + updateUserApplicationCloudSettingValue('lastSelectedFileTypeInImportTransactionDialog', value); + } + // Insights Explorer Page function setInsightsExplorerDefaultDateRangeType(value: number): void { updateApplicationSettingsValue('insightsExplorerDefaultDateRangeType', value); @@ -498,6 +519,9 @@ export const useSettingsStore = defineStore('settings', () => { setAutoSaveTransactionDraft, setAutoGetCurrentGeoLocation, setAlwaysShowTransactionPicturesInMobileTransactionEditPage, + // -- Import Transaction Dialog + setRememberLastSelectedFileTypeInImportTransactionDialog, + setLastSelectedFileTypeInImportTransactionDialog, // -- Insights Explorer Page setInsightsExplorerDefaultDateRangeType, setShowTagInInsightsExplorerPage, diff --git a/src/views/base/settings/AppCloudSyncPageBase.ts b/src/views/base/settings/AppCloudSyncPageBase.ts index 10df3563..d25cf44e 100644 --- a/src/views/base/settings/AppCloudSyncPageBase.ts +++ b/src/views/base/settings/AppCloudSyncPageBase.ts @@ -13,6 +13,7 @@ export interface CategorizedApplicationCloudSettingItems { export interface ApplicationCloudSettingItem { readonly settingKey: string; + readonly relatedSettingKeys?: string[]; readonly settingName: string; readonly mobile: boolean; readonly desktop: boolean; @@ -50,6 +51,12 @@ export const ALL_APPLICATION_CLOUD_SETTINGS: CategorizedApplicationCloudSettingI { settingKey: 'alwaysShowTransactionPicturesInMobileTransactionEditPage', settingName: 'Always Show Transaction Pictures', mobile: true, desktop: false } ] }, + { + categoryName: 'Import Transaction Dialog', + items: [ + { settingKey: 'rememberLastSelectedFileTypeInImportTransactionDialog', relatedSettingKeys: ['lastSelectedFileTypeInImportTransactionDialog'], settingName: 'Remember Last Selected File Type', mobile: false, desktop: true } + ] + }, { categoryName: 'Insights Explorer Page', items: [ @@ -161,6 +168,22 @@ export function useAppCloudSyncBase() { function updateSettingsSelected(categorizedItems: CategorizedApplicationCloudSettingItems, value: boolean): void { for (const item of categorizedItems.items) { enabledApplicationCloudSettings.value[item.settingKey] = value; + + if (item.relatedSettingKeys) { + for (const relatedKey of item.relatedSettingKeys) { + enabledApplicationCloudSettings.value[relatedKey] = value; + } + } + } + } + + function updateSettingSelected(settingItem: ApplicationCloudSettingItem, value: boolean): void { + enabledApplicationCloudSettings.value[settingItem.settingKey] = value; + + if (settingItem.relatedSettingKeys) { + for (const relatedKey of settingItem.relatedSettingKeys) { + enabledApplicationCloudSettings.value[relatedKey] = value; + } } } @@ -168,6 +191,12 @@ export function useAppCloudSyncBase() { for (const categorizedItems of ALL_APPLICATION_CLOUD_SETTINGS) { for (const item of categorizedItems.items) { enabledApplicationCloudSettings.value[item.settingKey] = true; + + if (item.relatedSettingKeys) { + for (const relatedKey of item.relatedSettingKeys) { + enabledApplicationCloudSettings.value[relatedKey] = true; + } + } } } } @@ -176,6 +205,12 @@ export function useAppCloudSyncBase() { for (const categorizedItems of ALL_APPLICATION_CLOUD_SETTINGS) { for (const item of categorizedItems.items) { enabledApplicationCloudSettings.value[item.settingKey] = false; + + if (item.relatedSettingKeys) { + for (const relatedKey of item.relatedSettingKeys) { + enabledApplicationCloudSettings.value[relatedKey] = false; + } + } } } } @@ -183,7 +218,14 @@ export function useAppCloudSyncBase() { function selectInvertSettings(): void { for (const categorizedItems of ALL_APPLICATION_CLOUD_SETTINGS) { for (const item of categorizedItems.items) { - enabledApplicationCloudSettings.value[item.settingKey] = !enabledApplicationCloudSettings.value[item.settingKey]; + const newValue = !enabledApplicationCloudSettings.value[item.settingKey]; + enabledApplicationCloudSettings.value[item.settingKey] = newValue; + + if (item.relatedSettingKeys) { + for (const relatedKey of item.relatedSettingKeys) { + enabledApplicationCloudSettings.value[relatedKey] = newValue; + } + } } } } @@ -219,6 +261,7 @@ export function useAppCloudSyncBase() { isAllSettingsSelected, hasSettingSelectedButNotAllChecked, updateSettingsSelected, + updateSettingSelected, selectAllSettings, selectNoneSettings, selectInvertSettings, diff --git a/src/views/desktop/app/settings/tabs/AppBasicSettingTab.vue b/src/views/desktop/app/settings/tabs/AppBasicSettingTab.vue index fe8dc795..7b06c5c3 100644 --- a/src/views/desktop/app/settings/tabs/AppBasicSettingTab.vue +++ b/src/views/desktop/app/settings/tabs/AppBasicSettingTab.vue @@ -224,6 +224,28 @@ + + + + + + + + + + + + + + @@ -441,6 +463,11 @@ const showAddTransactionButtonInDesktopNavbar = computed({ set: (value) => settingsStore.setShowAddTransactionButtonInDesktopNavbar(value) }); +const rememberLastSelectedFileTypeInImportTransactionDialog = computed({ + get: () => settingsStore.appSettings.rememberLastSelectedFileTypeInImportTransactionDialog, + set: (value) => settingsStore.setRememberLastSelectedFileTypeInImportTransactionDialog(value) +}); + const insightsExplorerDefaultDateRangeType = computed({ get: () => settingsStore.appSettings.insightsExplorerDefaultDateRangeType, set: (value) => settingsStore.setInsightsExplorerDefaultDateRangeType(value) diff --git a/src/views/desktop/app/settings/tabs/AppCloudSyncSettingTab.vue b/src/views/desktop/app/settings/tabs/AppCloudSyncSettingTab.vue index e439a5b3..efca05c1 100644 --- a/src/views/desktop/app/settings/tabs/AppCloudSyncSettingTab.vue +++ b/src/views/desktop/app/settings/tabs/AppCloudSyncSettingTab.vue @@ -82,7 +82,7 @@