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.

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