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.

130 lines
3.3 KiB

3 years ago
3 years ago
3 years ago
  1. <template>
  2. <v-data-table
  3. :value="value"
  4. :headers="headers"
  5. :items="items"
  6. :options.sync="options"
  7. :server-items-length="total"
  8. :search="search"
  9. :loading="isLoading"
  10. :loading-text="$t('generic.loading')"
  11. :no-data-text="$t('vuetify.noDataAvailable')"
  12. :footer-props="{
  13. 'showFirstLastPage': true,
  14. 'items-per-page-options': [10, 50, 100],
  15. 'items-per-page-text': $t('vuetify.itemsPerPageText'),
  16. 'page-text': $t('dataset.pageText')
  17. }"
  18. item-key="id"
  19. show-select
  20. @input="$emit('input', $event)"
  21. >
  22. <template #[`item.createdAt`]="{ item }">
  23. <span>{{ item.createdAt | dateParse('YYYY-MM-DDTHH:mm:ss') | dateFormat('DD/MM/YYYY HH:mm') }}</span>
  24. </template>
  25. <template #top>
  26. <v-text-field
  27. v-model="search"
  28. :prepend-inner-icon="mdiMagnify"
  29. :label="$t('generic.search')"
  30. single-line
  31. hide-details
  32. filled
  33. />
  34. </template>
  35. <!--
  36. Tempolary removing due to the performance
  37. <template #[`item.action`]="{ item }">
  38. <v-btn
  39. small
  40. color="primary text-capitalize"
  41. @click="toLabeling(item)"
  42. >
  43. {{ $t('dataset.annotate') }}
  44. </v-btn>
  45. </template> -->
  46. </v-data-table>
  47. </template>
  48. <script lang="ts">
  49. import Vue, { PropType } from 'vue'
  50. import { mdiMagnify } from '@mdi/js'
  51. import { DataOptions } from 'vuetify/types'
  52. import VueFilterDateFormat from '@vuejs-community/vue-filter-date-format'
  53. import VueFilterDateParse from '@vuejs-community/vue-filter-date-parse'
  54. import { CommentReadDTO } from '~/services/application/comment/commentData'
  55. Vue.use(VueFilterDateFormat)
  56. Vue.use(VueFilterDateParse)
  57. export default Vue.extend({
  58. props: {
  59. isLoading: {
  60. type: Boolean,
  61. default: false,
  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. total: {
  75. type: Number,
  76. default: 0,
  77. required: true
  78. }
  79. },
  80. data() {
  81. return {
  82. search: '',
  83. options: {} as DataOptions,
  84. headers: [
  85. { text: this.$t('dataset.text'), value: 'text' },
  86. { text: this.$t('user.username'), value: 'username' },
  87. { text: this.$t('comments.created_at'), value: 'createdAt' },
  88. { text: this.$t('dataset.action'), value: 'action' },
  89. ],
  90. mdiMagnify
  91. }
  92. },
  93. watch: {
  94. options: {
  95. handler() {
  96. this.$emit('update:query', {
  97. query: {
  98. limit: this.options.itemsPerPage.toString(),
  99. offset: ((this.options.page - 1) * this.options.itemsPerPage).toString(),
  100. q: this.search
  101. }
  102. })
  103. },
  104. deep: true
  105. },
  106. search() {
  107. this.$emit('update:query', {
  108. query: {
  109. limit: this.options.itemsPerPage.toString(),
  110. offset: '0',
  111. q: this.search
  112. }
  113. })
  114. this.options.page = 1
  115. }
  116. },
  117. // methods: {
  118. // toLabeling(item: CommentReadDTO) {
  119. // const index = this.examples.findIndex((example: ExampleDTO) => example.id === item.example)
  120. // const page = (index + 1).toString()
  121. // this.$emit('click:labeling', { page, q: this.search })
  122. // }
  123. // }
  124. })
  125. </script>