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.

98 lines
2.6 KiB

  1. <template>
  2. <v-data-table
  3. :value="value"
  4. :headers="headers"
  5. :items="items"
  6. :search="search"
  7. :loading="isLoading"
  8. :loading-text="$t('generic.loading')"
  9. :no-data-text="$t('vuetify.noDataAvailable')"
  10. :footer-props="{
  11. 'showFirstLastPage': true,
  12. 'items-per-page-options': [5, 10, 15, 100],
  13. 'items-per-page-text': $t('vuetify.itemsPerPageText'),
  14. 'page-text': $t('dataset.pageText')
  15. }"
  16. item-key="id"
  17. show-select
  18. @input="$emit('input', $event)"
  19. >
  20. <template v-slot:[`item.createdAt`]="{ item }">
  21. <span>{{ item.createdAt | dateParse('YYYY-MM-DDTHH:mm:ss') | dateFormat('DD/MM/YYYY HH:mm') }}</span>
  22. </template>
  23. <template v-slot:top>
  24. <v-text-field
  25. v-model="search"
  26. prepend-inner-icon="search"
  27. :label="$t('generic.search')"
  28. single-line
  29. hide-details
  30. filled
  31. />
  32. </template>
  33. <template v-slot:[`item.action`]="{ item }">
  34. <v-btn
  35. small
  36. color="primary text-capitalize"
  37. @click="toLabeling(item)"
  38. >
  39. {{ $t('dataset.annotate') }}
  40. </v-btn>
  41. </template>
  42. </v-data-table>
  43. </template>
  44. <script lang="ts">
  45. import Vue, { PropType } from 'vue'
  46. import VueFilterDateFormat from '@vuejs-community/vue-filter-date-format'
  47. import VueFilterDateParse from '@vuejs-community/vue-filter-date-parse'
  48. import { CommentReadDTO } from '~/services/application/comment/commentData'
  49. import { ExampleDTO } from '~/services/application/example/exampleData'
  50. Vue.use(VueFilterDateFormat)
  51. Vue.use(VueFilterDateParse)
  52. export default Vue.extend({
  53. props: {
  54. isLoading: {
  55. type: Boolean,
  56. default: false,
  57. required: true
  58. },
  59. examples: {
  60. type: Array as PropType<ExampleDTO[]>,
  61. default: () => [],
  62. required: true
  63. },
  64. items: {
  65. type: Array as PropType<CommentReadDTO[]>,
  66. default: () => [],
  67. required: true
  68. },
  69. value: {
  70. type: Array as PropType<CommentReadDTO[]>,
  71. default: () => [],
  72. required: true
  73. }
  74. },
  75. data() {
  76. return {
  77. search: '',
  78. headers: [
  79. { text: this.$t('dataset.text'), value: 'text' },
  80. { text: this.$t('user.username'), value: 'username' },
  81. { text: this.$t('comments.created_at'), value: 'createdAt' },
  82. { text: this.$t('dataset.action'), value: 'action' },
  83. ]
  84. }
  85. },
  86. methods: {
  87. toLabeling(item: CommentReadDTO) {
  88. const index = this.examples.findIndex((example: ExampleDTO) => example.id === item.example)
  89. const page = (index + 1).toString()
  90. this.$emit('click:labeling', { page, q: this.search })
  91. }
  92. }
  93. })
  94. </script>