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.

88 lines
2.0 KiB

3 years ago
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. :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-text': $t('vuetify.itemsPerPageText'),
  13. 'page-text': $t('dataset.pageText')
  14. }"
  15. item-key="id"
  16. show-select
  17. @input="$emit('input', $event)"
  18. >
  19. <template v-slot:top>
  20. <v-text-field
  21. v-model="search"
  22. prepend-inner-icon="search"
  23. :label="$t('generic.search')"
  24. single-line
  25. hide-details
  26. filled
  27. />
  28. </template>
  29. <template v-slot:[`item.backgroundColor`]="props">
  30. <v-chip
  31. :color="props.item.backgroundColor"
  32. :text-color="$contrastColor(props.item.backgroundColor)"
  33. >
  34. {{ props.item.backgroundColor }}
  35. </v-chip>
  36. </template>
  37. <template v-slot:[`item.actions`]="{ item }">
  38. <v-icon
  39. small
  40. @click="$emit('edit', item)"
  41. >
  42. mdi-pencil
  43. </v-icon>
  44. </template>
  45. </v-data-table>
  46. </template>
  47. <script lang="ts">
  48. import Vue, { PropType } from 'vue'
  49. import { LabelDTO } from '~/services/application/label/labelData'
  50. export default Vue.extend({
  51. props: {
  52. isLoading: {
  53. type: Boolean,
  54. default: false,
  55. required: true
  56. },
  57. items: {
  58. type: Array as PropType<LabelDTO[]>,
  59. default: () => [],
  60. required: true
  61. },
  62. value: {
  63. type: Array as PropType<LabelDTO[]>,
  64. default: () => [],
  65. required: true
  66. }
  67. },
  68. data() {
  69. return {
  70. search: ''
  71. }
  72. },
  73. computed: {
  74. headers() {
  75. return [
  76. { text: this.$t('generic.name'), value: 'text' },
  77. { text: this.$t('labels.shortkey'), value: 'suffixKey' },
  78. { text: this.$t('labels.color'), value: 'backgroundColor' },
  79. { text: 'Actions', value: 'actions', sortable: false },
  80. ]
  81. }
  82. }
  83. })
  84. </script>