Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-10-11 17:52:29 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2019-10-29 20:03:56 +0300
commit2adcc754137e0b31518693c3e823eb40548403d7 (patch)
tree43d081a06b7fb2eb7b3b8642d66f54d39a319524 /apps/workflowengine/src
parent06d43bdd77c0d7b2c407e9f37f6d0c718a200fc4 (diff)
Fetch groups on the fly
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/workflowengine/src')
-rw-r--r--apps/workflowengine/src/components/Checks/RequestUserGroup.vue84
1 files changed, 57 insertions, 27 deletions
diff --git a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
index 0a548a83ba4..f254a5185f6 100644
--- a/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
+++ b/apps/workflowengine/src/components/Checks/RequestUserGroup.vue
@@ -22,61 +22,91 @@
<template>
<div>
- <Multiselect v-model="newValue"
- :class="{'icon-loading-small': groups.length === 0}"
+ <Multiselect :value="currentValue"
+ :loading="status.isLoading && groups.length === 0"
:options="groups"
:multiple="false"
label="displayname"
track-by="id"
- @input="setValue" />
+ @search-change="searchAsync"
+ @input="(value) => $emit('input', value.id)" />
</div>
</template>
<script>
import { Multiselect } from 'nextcloud-vue/dist/Components/Multiselect'
-import valueMixin from '../../mixins/valueMixin'
import axios from '@nextcloud/axios'
+
+const groups = []
+const status = {
+ isLoading: false
+}
+
export default {
name: 'RequestUserGroup',
components: {
Multiselect
},
- mixins: [
- valueMixin
- ],
+ props: {
+ value: {
+ type: String,
+ default: ''
+ },
+ check: {
+ type: Object,
+ default: () => { return {} }
+ }
+ },
data() {
return {
- groups: []
+ groups: groups,
+ status: status
}
},
- beforeMount() {
- axios.get(OC.linkToOCS('cloud', 2) + 'groups').then((response) => {
- this.groups = response.data.ocs.data.groups.reduce((obj, item) => {
- obj.push({
- id: item,
- displayname: item
- })
- return obj
- }, [])
- this.updateInternalValue(this.value)
- }, (error) => {
- console.error('Error while loading group list', error.response)
- })
+ computed: {
+ currentValue() {
+ return this.groups.find(group => group.id === this.value) || null
+ }
+ },
+ async mounted() {
+ if (this.groups.length === 0) {
+ await this.searchAsync('')
+ }
+ if (this.currentValue === null) {
+ await this.searchAsync(this.value)
+ }
},
methods: {
- updateInternalValue() {
- this.newValue = this.groups.find(group => group.id === this.value) || null
+ searchAsync(searchQuery) {
+ if (this.status.isLoading) {
+ return
+ }
+
+ this.status.isLoading = true
+ return axios.get(OC.linkToOCS('cloud', 2) + 'groups?limit=20&search=' + encodeURI(searchQuery)).then((response) => {
+ response.data.ocs.data.groups.reduce((obj, item) => {
+ obj.push({
+ id: item,
+ displayname: item
+ })
+ return obj
+ }, []).forEach((group) => this.addGroup(group))
+ this.status.isLoading = false
+ }, (error) => {
+ console.error('Error while loading group list', error.response)
+ })
},
- setValue(value) {
- if (value !== null) {
- this.$emit('input', this.newValue.id)
+ addGroup(group) {
+ const index = this.groups.findIndex((item) => item.id === group.id)
+ if (index === -1) {
+ this.groups.push(group)
}
}
}
}
</script>
<style scoped>
- .multiselect, input[type='text'] {
+ .multiselect {
width: 100%;
}
</style>