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.

115 lines
2.4 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="Loading... Please wait"
  9. item-key="id"
  10. show-select
  11. @input="updateSelected"
  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.rolename="{ item }">
  24. <v-edit-dialog
  25. :return-value.sync="item"
  26. large
  27. @save="updateRole({ id: item.id })"
  28. >
  29. <div>{{ item.rolename }}</div>
  30. <template v-slot:input>
  31. <div class="mt-4 title">
  32. Update Role
  33. </div>
  34. </template>
  35. <template v-slot:input>
  36. <v-select
  37. :value="getRole(item)"
  38. :items="roles"
  39. :rules="roleRules"
  40. item-text="name"
  41. item-value="id"
  42. label="Role"
  43. return-object
  44. @input="setNewRole"
  45. />
  46. </template>
  47. </v-edit-dialog>
  48. </template>
  49. </v-data-table>
  50. </template>
  51. <script>
  52. import { mapState, mapActions, mapMutations, mapGetters } from 'vuex'
  53. import { roleRules } from '@/rules/index'
  54. export default {
  55. data() {
  56. return {
  57. headers: [
  58. {
  59. text: 'Name',
  60. align: 'left',
  61. sortable: false,
  62. value: 'username'
  63. },
  64. {
  65. text: 'Role',
  66. value: 'rolename'
  67. }
  68. ],
  69. search: '',
  70. newRole: null,
  71. roleRules
  72. }
  73. },
  74. computed: {
  75. ...mapState('members', ['items', 'selected', 'loading']),
  76. ...mapGetters('roles', ['roles'])
  77. },
  78. created() {
  79. this.getMemberList({
  80. projectId: this.$route.params.id
  81. })
  82. this.getRoleList()
  83. },
  84. methods: {
  85. ...mapActions('members', ['getMemberList', 'updateMemberRole']),
  86. ...mapMutations('members', ['updateSelected']),
  87. ...mapActions('roles', ['getRoleList']),
  88. getRole(item) {
  89. return {
  90. id: item.role,
  91. userId: item.user,
  92. mappingId: item.id
  93. }
  94. },
  95. setNewRole(value) {
  96. this.newRole = value
  97. },
  98. updateRole(payload) {
  99. this.updateMemberRole({
  100. projectId: this.$route.params.id,
  101. id: payload.id,
  102. role: this.newRole.id
  103. })
  104. }
  105. }
  106. }
  107. </script>