You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.0 KiB

  1. <template>
  2. <base-card
  3. :disabled="!valid"
  4. title="Export Data"
  5. agree-text="Export"
  6. cancel-text="Cancel"
  7. @agree="download"
  8. @cancel="cancel"
  9. >
  10. <template #content>
  11. <v-form
  12. ref="form"
  13. v-model="valid"
  14. >
  15. <h2>{{ $t('dataset.importDataMessage1') }}</h2>
  16. <v-radio-group
  17. ref="format"
  18. v-model="selectedFormat"
  19. :rules="fileFormatRules($t('rules.fileFormatRules'))"
  20. >
  21. <v-radio
  22. v-for="(format, i) in formats"
  23. :key="i"
  24. :label="format.text"
  25. :value="format"
  26. />
  27. </v-radio-group>
  28. <v-sheet
  29. v-if="selectedFormat"
  30. :dark="!$vuetify.theme.dark"
  31. :light="$vuetify.theme.dark"
  32. class="mb-5 pa-5"
  33. >
  34. <pre>{{ selectedFormat.example }}</pre>
  35. </v-sheet>
  36. <h2>{{ $t('dataset.exportDataMessage2') }}</h2>
  37. <v-text-field
  38. v-model="filename"
  39. placeholder="Name the file"
  40. :rules="[v => !!v || 'File name is required']"
  41. />
  42. <v-checkbox
  43. v-model="onlyApproved"
  44. label="Export only approved documents"
  45. color="success"
  46. hide-details
  47. />
  48. </v-form>
  49. </template>
  50. </base-card>
  51. </template>
  52. <script lang="ts">
  53. import Vue from 'vue'
  54. import BaseCard from '@/components/utils/BaseCard.vue'
  55. import { fileFormatRules } from '@/rules/index'
  56. export default Vue.extend({
  57. components: {
  58. BaseCard
  59. },
  60. props: {
  61. formats: {
  62. type: Array,
  63. default: () => [],
  64. required: true
  65. }
  66. },
  67. data() {
  68. return {
  69. file: null,
  70. filename: null,
  71. fileFormatRules,
  72. onlyApproved: false,
  73. selectedFormat: null,
  74. valid: false,
  75. }
  76. },
  77. methods: {
  78. cancel() {
  79. (this.$refs.format as HTMLFormElement).reset()
  80. this.$emit('cancel')
  81. },
  82. download() {
  83. this.$emit('download', this.selectedFormat, this.filename, this.onlyApproved)
  84. this.cancel()
  85. }
  86. }
  87. })
  88. </script>