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.

109 lines
2.1 KiB

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. <base-card
  3. :disabled="!valid"
  4. @agree="create"
  5. @cancel="cancel"
  6. title="Add Member"
  7. agree-text="Add"
  8. cancel-text="Cancel"
  9. >
  10. <template #content>
  11. <v-form
  12. ref="form"
  13. v-model="valid"
  14. >
  15. <v-autocomplete
  16. v-model="selectedUser"
  17. :items="items"
  18. :loading="isLoading"
  19. :search-input.sync="username"
  20. color="white"
  21. hide-no-data
  22. hide-selected
  23. item-text="username"
  24. label="User Search APIs"
  25. placeholder="Start typing to Search"
  26. prepend-icon="mdi-account"
  27. return-object
  28. />
  29. <v-select
  30. v-model="role"
  31. :items="roles"
  32. :rules="roleRules"
  33. item-text="name"
  34. item-value="id"
  35. label="Role"
  36. return-object
  37. prepend-icon="mdi-account-card-details-outline"
  38. />
  39. </v-form>
  40. </template>
  41. </base-card>
  42. </template>
  43. <script>
  44. import BaseCard from '@/components/molecules/BaseCard'
  45. import { roleRules } from '@/rules/index'
  46. export default {
  47. components: {
  48. BaseCard
  49. },
  50. props: {
  51. addMember: {
  52. type: Function,
  53. default: () => {},
  54. required: true
  55. },
  56. items: {
  57. type: Array,
  58. default: () => {},
  59. required: true
  60. },
  61. roles: {
  62. type: Array,
  63. default: () => {},
  64. required: true
  65. }
  66. },
  67. data() {
  68. return {
  69. valid: false,
  70. username: '',
  71. role: null,
  72. isLoading: false,
  73. selectedUser: null,
  74. roleRules
  75. }
  76. },
  77. watch: {
  78. username(val) {
  79. this.$emit('search-user', val)
  80. }
  81. },
  82. methods: {
  83. cancel() {
  84. this.$emit('close')
  85. },
  86. validate() {
  87. return this.$refs.form.validate()
  88. },
  89. reset() {
  90. this.$refs.form.reset()
  91. },
  92. create() {
  93. if (this.validate()) {
  94. this.addMember({
  95. userId: this.selectedUser.id,
  96. projectId: this.$route.params.id,
  97. role: this.role.id
  98. })
  99. this.reset()
  100. this.cancel()
  101. }
  102. }
  103. }
  104. }
  105. </script>