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.

RequestUserGroup.vue 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!--
  2. - @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
  3. -
  4. - @author Julius Härtl <jus@bitgrid.net>
  5. -
  6. - @license GNU AGPL version 3 or any later version
  7. -
  8. - This program is free software: you can redistribute it and/or modify
  9. - it under the terms of the GNU Affero General Public License as
  10. - published by the Free Software Foundation, either version 3 of the
  11. - License, or (at your option) any later version.
  12. -
  13. - This program is distributed in the hope that it will be useful,
  14. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. - GNU Affero General Public License for more details.
  17. -
  18. - You should have received a copy of the GNU Affero General Public License
  19. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. -
  21. -->
  22. <template>
  23. <div>
  24. <Multiselect v-model="newValue"
  25. :class="{'icon-loading-small': groups.length === 0}"
  26. :options="groups"
  27. :multiple="false"
  28. label="displayname"
  29. track-by="id"
  30. @input="setValue" />
  31. </div>
  32. </template>
  33. <script>
  34. import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
  35. import valueMixin from '../../mixins/valueMixin'
  36. import axios from 'nextcloud-axios'
  37. export default {
  38. name: 'RequestUserGroup',
  39. components: {
  40. Multiselect
  41. },
  42. mixins: [
  43. valueMixin
  44. ],
  45. data() {
  46. return {
  47. groups: []
  48. }
  49. },
  50. beforeMount() {
  51. axios.get(OC.linkToOCS('cloud', 2) + 'groups').then((response) => {
  52. this.groups = response.data.ocs.data.groups.reduce((obj, item) => {
  53. obj.push({
  54. id: item,
  55. displayname: item
  56. })
  57. return obj
  58. }, [])
  59. this.updateInternalValue(this.value)
  60. }, (error) => {
  61. console.error('Error while loading group list', error.response)
  62. })
  63. },
  64. methods: {
  65. updateInternalValue() {
  66. this.newValue = this.groups.find(group => group.id === this.value) || null
  67. },
  68. setValue(value) {
  69. if (value !== null) {
  70. this.$emit('input', this.newValue.id)
  71. }
  72. }
  73. }
  74. }
  75. </script>