Browse Source

Added dynamic filename and more precise default filename when exporting

pull/1116/head
Paul 3 years ago
parent
commit
27503b8625
3 changed files with 8 additions and 2 deletions
  1. 7
      frontend/components/organisms/documents/DocumentExportForm.vue
  2. 1
      frontend/i18n/en/projects/dataset.js
  3. 2
      frontend/store/documents.js

7
frontend/components/organisms/documents/DocumentExportForm.vue

@ -14,6 +14,7 @@
>
<h2>{{ $t('dataset.importDataMessage1') }}</h2>
<v-radio-group
ref="format"
v-model="selectedFormat"
:rules="fileFormatRules($t('rules.fileFormatRules'))"
>
@ -34,6 +35,8 @@
{{ example }}<br>
</span>
</v-sheet>
<h2>{{ $t('dataset.exportDataMessage2') }}</h2>
<v-text-field v-model="selectedFileName" placeholder="Name the file" />
</v-form>
</template>
</base-card>
@ -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()

1
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}'

2
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()
})

Loading…
Cancel
Save