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.

96 lines
2.2 KiB

2 years ago
3 years ago
3 years ago
4 years ago
4 years ago
3 years ago
2 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 #top>
  20. <v-text-field
  21. v-model="search"
  22. :prepend-inner-icon="mdiMagnify"
  23. :label="$t('generic.search')"
  24. single-line
  25. hide-details
  26. filled
  27. />
  28. </template>
  29. <template #[`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 #[`item.actions`]="{ item }">
  38. <v-icon small @click="$emit('edit', item)">
  39. {{ mdiPencil }}
  40. </v-icon>
  41. </template>
  42. </v-data-table>
  43. </template>
  44. <script lang="ts">
  45. import { mdiMagnify, mdiPencil } from '@mdi/js'
  46. import type { PropType } from 'vue'
  47. import Vue from 'vue'
  48. import { LabelDTO } from '~/services/application/label/labelData'
  49. export default Vue.extend({
  50. props: {
  51. isLoading: {
  52. type: Boolean,
  53. default: false,
  54. required: true
  55. },
  56. items: {
  57. type: Array as PropType<LabelDTO[]>,
  58. default: () => [],
  59. required: true
  60. },
  61. value: {
  62. type: Array as PropType<LabelDTO[]>,
  63. default: () => [],
  64. required: true
  65. },
  66. disableEdit: {
  67. type: Boolean,
  68. default: false
  69. }
  70. },
  71. data() {
  72. return {
  73. search: '',
  74. mdiPencil,
  75. mdiMagnify
  76. }
  77. },
  78. computed: {
  79. headers() {
  80. const headers = [
  81. { text: this.$t('generic.name'), value: 'text', sortable: true },
  82. { text: this.$t('labels.shortkey'), value: 'suffixKey', sortable: true },
  83. { text: this.$t('labels.color'), value: 'backgroundColor', sortable: true }
  84. ]
  85. if (!this.disableEdit) {
  86. headers.push({ text: 'Actions', value: 'actions', sortable: false })
  87. }
  88. return headers
  89. }
  90. }
  91. })
  92. </script>