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.

132 lines
3.3 KiB

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