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.

79 lines
1.7 KiB

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