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.

82 lines
1.7 KiB

  1. <template>
  2. <v-card>
  3. <v-card-title v-text="$t('labels.importLabels')" />
  4. <v-card-text>
  5. <v-form
  6. ref="form"
  7. v-model="valid"
  8. >
  9. <h3>{{ $t('labels.importMessage1') }}</h3>
  10. <v-sheet
  11. v-if="exampleFormat"
  12. :dark="!$vuetify.theme.dark"
  13. :light="$vuetify.theme.dark"
  14. class="mb-5 pa-5"
  15. >
  16. <pre>{{ exampleFormat }}</pre>
  17. </v-sheet>
  18. <v-file-input
  19. v-model="file"
  20. accept=".json"
  21. :error-messages="errorMessage"
  22. :label="$t('labels.filePlaceholder')"
  23. :rules="uploadSingleFileRules($t('rules.uploadFileRules'))"
  24. outlined
  25. prepend-icon=""
  26. @change="$emit('clear')"
  27. @click:clear="$emit('clear')"
  28. />
  29. <v-btn
  30. :disabled="!valid"
  31. color="primary"
  32. class="text-capitalize"
  33. @click="$emit('upload', file)"
  34. >
  35. Import
  36. </v-btn>
  37. </v-form>
  38. </v-card-text>
  39. </v-card>
  40. </template>
  41. <script lang="ts">
  42. import Vue from 'vue'
  43. import { uploadSingleFileRules } from '@/rules/index'
  44. export default Vue.extend({
  45. props: {
  46. errorMessage: {
  47. type: String,
  48. default: ''
  49. }
  50. },
  51. data() {
  52. return {
  53. file: null,
  54. valid: false,
  55. uploadSingleFileRules,
  56. }
  57. },
  58. computed: {
  59. exampleFormat() {
  60. const data = [
  61. {
  62. text: 'Dog',
  63. suffix_key: 'a',
  64. background_color: '#FF0000',
  65. text_color: '#ffffff'
  66. },
  67. {
  68. text: 'Cat',
  69. suffix_key: 'c',
  70. background_color: '#FF0000',
  71. text_color: '#ffffff'
  72. }
  73. ]
  74. return JSON.stringify(data, null, 4)
  75. }
  76. }
  77. })
  78. </script>