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.

102 lines
1.9 KiB

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="members"
  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.role="{ item }">
  24. <v-edit-dialog
  25. :return-value.sync="item.role"
  26. large
  27. persistent
  28. @save="updateRole({ id: item.id, role: newRole })"
  29. >
  30. <div>{{ item.role }}</div>
  31. <template v-slot:input>
  32. <div class="mt-4 title">
  33. Update Role
  34. </div>
  35. </template>
  36. <template v-slot:input>
  37. <v-select
  38. :value="item.role"
  39. :items="roles"
  40. :rules="roleRules"
  41. label="Role"
  42. @input="setNewRole"
  43. />
  44. </template>
  45. </v-edit-dialog>
  46. </template>
  47. </v-data-table>
  48. </template>
  49. <script>
  50. import { roleRules } from '@/rules/index'
  51. export default {
  52. props: {
  53. headers: {
  54. type: Array,
  55. default: () => [],
  56. required: true
  57. },
  58. members: {
  59. type: Array,
  60. default: () => [],
  61. required: true
  62. },
  63. selected: {
  64. type: Array,
  65. default: () => [],
  66. required: true
  67. },
  68. roles: {
  69. type: Array,
  70. default: () => [
  71. 'Admin',
  72. 'Member'
  73. ]
  74. },
  75. loading: {
  76. type: Boolean,
  77. default: false,
  78. required: true
  79. }
  80. },
  81. data() {
  82. return {
  83. search: '',
  84. newRole: null,
  85. roleRules
  86. }
  87. },
  88. methods: {
  89. setNewRole(value) {
  90. this.newRole = value
  91. },
  92. update(selected) {
  93. this.$emit('update-selected', selected)
  94. },
  95. updateRole(payload) {
  96. this.$emit('update-role', payload)
  97. }
  98. }
  99. }
  100. </script>