diff --git a/src/locales/de.json b/src/locales/de.json index 64787770..a6fd133a 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -1924,9 +1924,10 @@ "Data Management": "Datenverwaltung", "Unable to retrieve user statistics data": "Benutzerstatistikdaten können nicht abgerufen werden", "Export Data": "Daten exportieren", - "Field Separator": "Field Separator", + "File Format": "File Format", "CSV (Comma-separated values) File": "CSV (Kommagetrennte Werte) Datei", "TSV (Tab-separated values) File": "TSV (Tabulatorgetrennte Werte) Datei", + "Markdown File": "Markdown File", "Clear User Data": "Benutzerdaten löschen", "Export all transaction data to file.": "Alle Transaktionsdaten in Datei exportieren.", "Are you sure you want to export all transaction data to file?": "Sind Sie sicher, dass Sie alle Transaktionsdaten in eine Datei exportieren möchten?", diff --git a/src/locales/en.json b/src/locales/en.json index da979f5c..cfce970c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1924,9 +1924,10 @@ "Data Management": "Data Management", "Unable to retrieve user statistics data": "Unable to retrieve user statistics data", "Export Data": "Export Data", - "Field Separator": "Field Separator", + "File Format": "File Format", "CSV (Comma-separated values) File": "CSV (Comma-separated values) File", "TSV (Tab-separated values) File": "TSV (Tab-separated values) File", + "Markdown File": "Markdown File", "Clear User Data": "Clear User Data", "Export all transaction data to file.": "Export all transaction data to file.", "Are you sure you want to export all transaction data to file?": "Are you sure you want to export all transaction data to file?", diff --git a/src/locales/es.json b/src/locales/es.json index 3b1fe7f1..8b48abea 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -1924,9 +1924,10 @@ "Data Management": "Gestión de datos", "Unable to retrieve user statistics data": "No se pueden recuperar datos de estadísticas de usuario", "Export Data": "Exportar datos", - "Field Separator": "Field Separator", + "File Format": "File Format", "CSV (Comma-separated values) File": "Archivo CSV (valores separados por comas)", "TSV (Tab-separated values) File": "Archivo TSV (valores separados por tabulaciones)", + "Markdown File": "Markdown File", "Clear User Data": "Borrar datos de usuario", "Export all transaction data to file.": "Exportar todos los datos de la transacción a un archivo.", "Are you sure you want to export all transaction data to file?": "¿Está seguro de que desea exportar todos los datos de la transacción al archivo?", diff --git a/src/locales/it.json b/src/locales/it.json index 33650bea..13045206 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -1924,9 +1924,10 @@ "Data Management": "Gestione dati", "Unable to retrieve user statistics data": "Impossibile recuperare i dati statistici dell'utente", "Export Data": "Esporta dati", - "Field Separator": "Field Separator", + "File Format": "File Format", "CSV (Comma-separated values) File": "File CSV (valori separati da virgola)", "TSV (Tab-separated values) File": "File TSV (valori separati da tabulazione)", + "Markdown File": "Markdown File", "Clear User Data": "Cancella dati utente", "Export all transaction data to file.": "Esporta tutti i dati delle transazioni in un file.", "Are you sure you want to export all transaction data to file?": "Sei sicuro di voler esportare tutti i dati delle transazioni in un file?", diff --git a/src/locales/ja.json b/src/locales/ja.json index bf8f3bc7..7a1985ff 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -1924,9 +1924,10 @@ "Data Management": "データ管理", "Unable to retrieve user statistics data": "ユーザー統計データを取得できません", "Export Data": "データのエクスポート", - "Field Separator": "Field Separator", + "File Format": "File Format", "CSV (Comma-separated values) File": "CSV(コンマ区切り)ファイル", "TSV (Tab-separated values) File": "TSV(タブ区切り)ファイル", + "Markdown File": "Markdown File", "Clear User Data": "ユーザーデータをクリア", "Export all transaction data to file.": "すべての取引データをファイルにエクスポートします。", "Are you sure you want to export all transaction data to file?": "取引データをファイルにエクスポートしますか?", diff --git a/src/locales/ru.json b/src/locales/ru.json index c695b90b..bc400cc7 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -1924,9 +1924,10 @@ "Data Management": "Управление данными", "Unable to retrieve user statistics data": "Не удалось получить статистические данные пользователя", "Export Data": "Экспорт данных", - "Field Separator": "Field Separator", + "File Format": "File Format", "CSV (Comma-separated values) File": "Файл CSV (значения, разделенные запятыми)", "TSV (Tab-separated values) File": "Файл TSV (значения, разделенные табуляцией)", + "Markdown File": "Markdown File", "Clear User Data": "Очистить данные пользователя", "Export all transaction data to file.": "Экспортировать все данные о транзакциях в файл.", "Are you sure you want to export all transaction data to file?": "Вы уверены, что хотите экспортировать все данные о транзакциях в файл?", diff --git a/src/locales/uk.json b/src/locales/uk.json index da1f9151..111e5436 100644 --- a/src/locales/uk.json +++ b/src/locales/uk.json @@ -1924,9 +1924,10 @@ "Data Management": "Керування даними", "Unable to retrieve user statistics data": "Не вдалося отримати статистику користувача", "Export Data": "Експорт даних", - "Field Separator": "Field Separator", + "File Format": "File Format", "CSV (Comma-separated values) File": "Файл CSV (значення, розділені комами)", "TSV (Tab-separated values) File": "Файл TSV (значення, розділені табуляцією)", + "Markdown File": "Markdown File", "Clear User Data": "Очистити дані користувача", "Export all transaction data to file.": "Експортувати всі транзакції у файл.", "Are you sure you want to export all transaction data to file?": "Ви впевнені, що хочете експортувати всі транзакції?", diff --git a/src/locales/vi.json b/src/locales/vi.json index fbadba95..669b4835 100644 --- a/src/locales/vi.json +++ b/src/locales/vi.json @@ -1924,9 +1924,10 @@ "Data Management": "Quản lý dữ liệu", "Unable to retrieve user statistics data": "Không thể lấy dữ liệu thống kê người dùng", "Export Data": "Xuất dữ liệu", - "Field Separator": "Field Separator", + "File Format": "File Format", "CSV (Comma-separated values) File": "Tệp CSV (Giá trị phân cách bằng dấu phẩy)", "TSV (Tab-separated values) File": "Tệp TSV (Giá trị phân cách bằng tab)", + "Markdown File": "Markdown File", "Clear User Data": "Xóa dữ liệu người dùng", "Export all transaction data to file.": "Xuất tất cả dữ liệu giao dịch sang tệp.", "Are you sure you want to export all transaction data to file?": "Bạn có chắc chắn muốn xuất tất cả dữ liệu giao dịch sang tệp không?", diff --git a/src/locales/zh_Hans.json b/src/locales/zh_Hans.json index 2c438f82..7ce067a4 100644 --- a/src/locales/zh_Hans.json +++ b/src/locales/zh_Hans.json @@ -1924,9 +1924,10 @@ "Data Management": "数据管理", "Unable to retrieve user statistics data": "无法获取用户统计数据", "Export Data": "导出数据", - "Field Separator": "字段分隔符", + "File Format": "文件格式", "CSV (Comma-separated values) File": "CSV (逗号分隔的值) 文件", "TSV (Tab-separated values) File": "TSV (制表符分隔的值) 文件", + "Markdown File": "Markdown 文件", "Clear User Data": "清除用户数据", "Export all transaction data to file.": "导出所有交易数据到文件。", "Are you sure you want to export all transaction data to file?": "您确定要导出所有交易数据到文件?", diff --git a/src/locales/zh_Hant.json b/src/locales/zh_Hant.json index 26b43cf4..994563a3 100644 --- a/src/locales/zh_Hant.json +++ b/src/locales/zh_Hant.json @@ -1924,9 +1924,10 @@ "Data Management": "資料管理", "Unable to retrieve user statistics data": "無法取得使用者統計資料", "Export Data": "匯出資料", - "Field Separator": "欄位分隔符", + "File Format": "檔案格式", "CSV (Comma-separated values) File": "CSV (逗號分隔的值) 檔案", "TSV (Tab-separated values) File": "TSV (定位點分隔的值) 檔案", + "Markdown File": "Markdown 檔案", "Clear User Data": "清除使用者資料", "Export all transaction data to file.": "匯出所有交易資料到檔案。", "Are you sure you want to export all transaction data to file?": "您確定要匯出所有交易資料到檔案?", diff --git a/src/views/desktop/statistics/transaction/dialogs/ExportDialog.vue b/src/views/desktop/statistics/transaction/dialogs/ExportDialog.vue index 3fae38d0..93e16b16 100644 --- a/src/views/desktop/statistics/transaction/dialogs/ExportDialog.vue +++ b/src/views/desktop/statistics/transaction/dialogs/ExportDialog.vue @@ -10,15 +10,19 @@ - + + :append-icon="fileFormat === 'csv' ? mdiCheck : undefined" + :title="tt('CSV (Comma-separated values) File')" + @click="fileFormat = 'csv'"> + :append-icon="fileFormat === 'tsv' ? mdiCheck : undefined" + :title="tt('TSV (Tab-separated values) File')" + @click="fileFormat = 'tsv'"> + @@ -87,6 +91,7 @@ import { useI18n } from '@/locales/helpers.ts'; import { useUserStore } from '@/stores/user.ts'; +import { replaceAll } from '@/lib/common.ts'; import { copyTextToClipboard, startDownloadFile } from '@/lib/ui/common.ts'; import { @@ -94,6 +99,7 @@ import { mdiCheck, mdiComma, mdiKeyboardTab, + mdiLanguageMarkdownOutline, mdiMenuDown } from '@mdi/js'; @@ -109,7 +115,7 @@ const snackbar = useTemplateRef('snackbar'); const showState = ref(false); const headers = ref([]); const data = ref([]); -const separator = ref(','); +const fileFormat = ref('csv'); const showRawData = ref(false); const dataTableHeaders = computed(() => { @@ -137,14 +143,32 @@ const dataTableItems = computed(() => { const exportedData = computed(() => { let ret = ''; - if (headers.value.length > 0) { - ret += headers.value.join(separator.value); + if (fileFormat.value === 'csv' || fileFormat.value === 'tsv') { + let separator = ','; + + if (fileFormat.value === 'tsv') { + separator = '\t'; + } + + if (headers.value.length > 0) { + ret += headers.value.map(item => replaceAll(item, separator, ' ')).join(separator); + } + + for (const row of data.value) { + ret += '\n'; + ret += row.map(item => replaceAll(item, separator, ' ')).join(separator); + } + } else if (fileFormat.value === 'md') { + ret += '| ' + headers.value.map(item => replaceAll(item, '|', ' ')).join(' | ') + ' |'; + ret += '\n'; + ret += '| ' + headers.value.map(() => '---').join(' | ') + ' |'; + + for (const row of data.value) { + ret += '\n'; + ret += '| ' + row.map(item => replaceAll(item, '|', ' ')).join(' | ') + ' |'; + } } - for (const row of data.value) { - ret += '\n'; - ret += row.join(separator.value); - } return ret; }); @@ -164,7 +188,7 @@ function getExportFileName(fileExtension: string): string { function open(options: { headers: string[], data: string[][] }): void { headers.value = options.headers || []; data.value = options.data || []; - separator.value = ','; + fileFormat.value = 'csv'; showRawData.value = false; showState.value = true; } @@ -175,15 +199,15 @@ function copy(): void { } function save(): void { - let fileExtension = 'csv'; let contentType = 'text/csv'; - if (separator.value === '\t') { - fileExtension = 'tsv'; + if (fileFormat.value === 'tsv') { contentType = 'text/tab-separated-values'; + } else if (fileFormat.value === 'md') { + contentType = 'text/markdown'; } - startDownloadFile(getExportFileName(fileExtension), new Blob([exportedData.value], { type: contentType })); + startDownloadFile(getExportFileName(fileFormat.value), new Blob([exportedData.value], { type: contentType })); } function cancel(): void {