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.

120 lines
2.6 KiB

5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <v-data-table
  3. :value="selected"
  4. :headers="headers"
  5. :items="items"
  6. :search="search"
  7. :loading="loading"
  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. }"
  14. item-key="id"
  15. show-select
  16. @input="updateSelected"
  17. >
  18. <template v-slot:top>
  19. <v-text-field
  20. v-model="search"
  21. prepend-inner-icon="search"
  22. :label="$t('generic.search')"
  23. single-line
  24. hide-details
  25. filled
  26. />
  27. </template>
  28. <template v-slot:item.rolename="{ item }">
  29. <v-edit-dialog
  30. :return-value.sync="item"
  31. large
  32. @save="updateRole({ id: item.id })"
  33. >
  34. <div>{{ item.rolename }}</div>
  35. <template v-slot:input>
  36. <div class="mt-4 title">
  37. {{ $t('members.updateRole') }}
  38. </div>
  39. </template>
  40. <template v-slot:input>
  41. <v-select
  42. :value="getRole(item)"
  43. :items="roles"
  44. :rules="roleRules($t('rules.roleRules'))"
  45. item-text="name"
  46. item-value="id"
  47. label="Role"
  48. return-object
  49. @input="setNewRole"
  50. />
  51. </template>
  52. </v-edit-dialog>
  53. </template>
  54. </v-data-table>
  55. </template>
  56. <script>
  57. import { mapState, mapActions, mapMutations, mapGetters } from 'vuex'
  58. import { roleRules } from '@/rules/index'
  59. export default {
  60. data() {
  61. return {
  62. headers: [
  63. {
  64. text: this.$t('generic.name'),
  65. align: 'left',
  66. sortable: false,
  67. value: 'username'
  68. },
  69. {
  70. text: this.$t('members.role'),
  71. value: 'rolename'
  72. }
  73. ],
  74. search: '',
  75. newRole: null,
  76. roleRules
  77. }
  78. },
  79. computed: {
  80. ...mapState('members', ['items', 'selected', 'loading']),
  81. ...mapGetters('roles', ['roles'])
  82. },
  83. created() {
  84. this.getMemberList({
  85. projectId: this.$route.params.id
  86. })
  87. this.getRoleList()
  88. },
  89. methods: {
  90. ...mapActions('members', ['getMemberList', 'updateMemberRole']),
  91. ...mapMutations('members', ['updateSelected']),
  92. ...mapActions('roles', ['getRoleList']),
  93. getRole(item) {
  94. return {
  95. id: item.role,
  96. userId: item.user,
  97. mappingId: item.id
  98. }
  99. },
  100. setNewRole(value) {
  101. this.newRole = value
  102. },
  103. updateRole(payload) {
  104. this.updateMemberRole({
  105. projectId: this.$route.params.id,
  106. id: payload.id,
  107. role: this.newRole.id
  108. })
  109. }
  110. }
  111. }
  112. </script>