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.

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