From 27503b862505b45df78d179ce9e1619a2be0d063 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 14 Dec 2020 22:15:59 +0100 Subject: [PATCH] Added dynamic filename and more precise default filename when exporting --- .../components/organisms/documents/DocumentExportForm.vue | 7 ++++++- frontend/i18n/en/projects/dataset.js | 1 + frontend/store/documents.js | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/components/organisms/documents/DocumentExportForm.vue b/frontend/components/organisms/documents/DocumentExportForm.vue index 9bdc63f3..08a81db5 100644 --- a/frontend/components/organisms/documents/DocumentExportForm.vue +++ b/frontend/components/organisms/documents/DocumentExportForm.vue @@ -14,6 +14,7 @@ >

{{ $t('dataset.importDataMessage1') }}

@@ -34,6 +35,8 @@ {{ example }}
+

{{ $t('dataset.exportDataMessage2') }}

+ @@ -64,6 +67,7 @@ export default { valid: false, file: null, selectedFormat: null, + selectedFileName: 'project_' + this.$route.params.id + '_dataset', fileFormatRules, uploadFileRules } @@ -87,12 +91,13 @@ export default { return this.$refs.form.validate() }, reset() { - this.$refs.form.reset() + this.$refs.format.reset() }, download() { if (this.validate()) { this.exportDocument({ projectId: this.$route.params.id, + fileName: this.selectedFileName, format: this.selectedFormat.type }) this.reset() diff --git a/frontend/i18n/en/projects/dataset.js b/frontend/i18n/en/projects/dataset.js index ac8cccd1..276daf4e 100644 --- a/frontend/i18n/en/projects/dataset.js +++ b/frontend/i18n/en/projects/dataset.js @@ -13,6 +13,7 @@ export default { importDataPlaceholder: 'File input', exportDataTitle: 'Export Data', exportDataMessage: 'Select a file format', + exportDataMessage2: 'Select a file name', deleteDocumentsTitle: 'Delete Document', deleteDocumentsMessage: 'Are you sure you want to delete these documents from this project?', pageText: '{0}-{1} of {2}' diff --git a/frontend/store/documents.js b/frontend/store/documents.js index 141afe42..d27ae6d7 100644 --- a/frontend/store/documents.js +++ b/frontend/store/documents.js @@ -126,7 +126,7 @@ export const actions = { const url = window.URL.createObjectURL(new Blob([response.data])) const link = document.createElement('a') link.href = url - link.setAttribute('download', 'file.' + data.format) + link.setAttribute('download', data.fileName + '.' + data.format) document.body.appendChild(link) link.click() })