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.

79 lines
1.7 KiB

4 years ago
  1. <template>
  2. <v-data-table
  3. :value="selected"
  4. :headers="headers"
  5. :items="projects"
  6. :search="search"
  7. :loading="loading"
  8. :no-data-text="$t('vuetify.noDataAvailable')"
  9. :footer-props="{
  10. 'showFirstLastPage': true,
  11. 'items-per-page-options': [5, 10, 15, $t('generic.all')],
  12. 'items-per-page-text': $t('vuetify.itemsPerPageText'),
  13. 'page-text': $t('dataset.pageText')
  14. }"
  15. item-key="id"
  16. show-select
  17. @input="update"
  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.name="{ item }">
  30. <nuxt-link :to="localePath(`/projects/${item.id}`)">
  31. <span>{{ item.name }}</span>
  32. </nuxt-link>
  33. </template>
  34. </v-data-table>
  35. </template>
  36. <script>
  37. import { mapState, mapActions, mapMutations } from 'vuex'
  38. export default {
  39. data() {
  40. return {
  41. search: '',
  42. headers: [
  43. {
  44. text: this.$t('generic.name'),
  45. align: 'left',
  46. value: 'name'
  47. },
  48. {
  49. text: this.$t('generic.description'),
  50. value: 'description'
  51. },
  52. {
  53. text: this.$t('generic.type'),
  54. value: 'project_type'
  55. }
  56. ]
  57. }
  58. },
  59. computed: {
  60. ...mapState('projects', ['projects', 'selected', 'loading'])
  61. },
  62. async created() {
  63. await this.getProjectList()
  64. },
  65. methods: {
  66. ...mapActions('projects', ['getProjectList']),
  67. ...mapMutations('projects', ['updateSelected']),
  68. update(selected) {
  69. this.updateSelected(selected)
  70. }
  71. }
  72. }
  73. </script>