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.

73 lines
1.4 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. loading-text="Loading... Please wait"
  9. item-key="id"
  10. show-select
  11. @input="update"
  12. >
  13. <template v-slot:top>
  14. <v-text-field
  15. v-model="search"
  16. prepend-inner-icon="search"
  17. label="Search"
  18. single-line
  19. hide-details
  20. filled
  21. />
  22. </template>
  23. <template v-slot:item.name="{ item }">
  24. <nuxt-link :to="`/projects/${item.id}`">
  25. <span>{{ item.name }}</span>
  26. </nuxt-link>
  27. </template>
  28. </v-data-table>
  29. </template>
  30. <script>
  31. import { mapState, mapActions, mapMutations } from 'vuex'
  32. export default {
  33. data() {
  34. return {
  35. search: '',
  36. headers: [
  37. {
  38. text: 'Name',
  39. align: 'left',
  40. value: 'name'
  41. },
  42. {
  43. text: 'Description',
  44. value: 'description'
  45. },
  46. {
  47. text: 'Type',
  48. value: 'project_type'
  49. }
  50. ]
  51. }
  52. },
  53. computed: {
  54. ...mapState('projects', ['projects', 'selected', 'loading'])
  55. },
  56. async created() {
  57. await this.getProjectList()
  58. },
  59. methods: {
  60. ...mapActions('projects', ['getProjectList']),
  61. ...mapMutations('projects', ['updateSelected']),
  62. update(selected) {
  63. this.updateSelected(selected)
  64. }
  65. }
  66. }
  67. </script>