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> <h2>{{ $t('dataset.importDataMessage1') }}</h2>
<v-radio-group <v-radio-group
ref="format"
v-model="selectedFormat" v-model="selectedFormat"
:rules="fileFormatRules($t('rules.fileFormatRules'))" :rules="fileFormatRules($t('rules.fileFormatRules'))"
> >
@ -34,6 +35,8 @@
{{ example }}<br> {{ example }}<br>
</span> </span>
</v-sheet> </v-sheet>
<h2>{{ $t('dataset.exportDataMessage2') }}</h2>
<v-text-field v-model="selectedFileName" placeholder="Name the file" />
</v-form> </v-form>
</template> </template>
</base-card> </base-card>
@ -64,6 +67,7 @@ export default {
valid: false, valid: false,
file: null, file: null,
selectedFormat: null, selectedFormat: null,
selectedFileName: 'project_' + this.$route.params.id + '_dataset',
fileFormatRules, fileFormatRules,
uploadFileRules uploadFileRules
} }
@ -87,12 +91,13 @@ export default {
return this.$refs.form.validate() return this.$refs.form.validate()
}, },
reset() { reset() {
this.$refs.form.reset()
this.$refs.format.reset()
}, },
download() { download() {
if (this.validate()) { if (this.validate()) {
this.exportDocument({ this.exportDocument({
projectId: this.$route.params.id, projectId: this.$route.params.id,
fileName: this.selectedFileName,
format: this.selectedFormat.type format: this.selectedFormat.type
}) })
this.reset() this.reset()

1
frontend/i18n/en/projects/dataset.js

@ -13,6 +13,7 @@ export default {
importDataPlaceholder: 'File input', importDataPlaceholder: 'File input',
exportDataTitle: 'Export Data', exportDataTitle: 'Export Data',
exportDataMessage: 'Select a file format', exportDataMessage: 'Select a file format',
exportDataMessage2: 'Select a file name',
deleteDocumentsTitle: 'Delete Document', deleteDocumentsTitle: 'Delete Document',
deleteDocumentsMessage: 'Are you sure you want to delete these documents from this project?', deleteDocumentsMessage: 'Are you sure you want to delete these documents from this project?',
pageText: '{0}-{1} of {2}' 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 url = window.URL.createObjectURL(new Blob([response.data]))
const link = document.createElement('a') const link = document.createElement('a')
link.href = url link.href = url
link.setAttribute('download', 'file.' + data.format)
link.setAttribute('download', data.fileName + '.' + data.format)
document.body.appendChild(link) document.body.appendChild(link)
link.click() link.click()
}) })

Loading…
Cancel
Save