Skip to content

Commit

Permalink
fix: Filter selected groups first and properly display groups that ar…
Browse files Browse the repository at this point in the history
…e not fetched in the initial result response

Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl committed May 11, 2023
1 parent 9ef6871 commit f3ee2ab
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/SettingsSelectGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export default {
return 'settings-select-group-' + this.uuid
},
groupsArray() {
return Object.values(this.groups)
return Object.values(this.groups).sort((a, b) => {
return this.inputValObjects.indexOf(b) - this.inputValObjects.indexOf(a)
})
},
},
watch: {
Expand All @@ -88,6 +90,13 @@ export default {
created() {
this.uuid = uuid.toString()
uuid += 1
// Preseed with placeholder entries for groups
this.getValueObject().forEach((element) => {
this.$set(this.groups, element.id, element)
})
this.inputValObjects = this.getValueObject()
// Fetch actual group metadata
this.asyncFindGroup('').then((result) => {
this.inputValObjects = this.getValueObject()
})
Expand All @@ -111,7 +120,7 @@ export default {
},
asyncFindGroup(query) {
query = typeof query === 'string' ? encodeURI(query) : ''
return axios.get(generateOcsUrl(`cloud/groups/details?search=${query}&limit=10`, 2))
return axios.get(generateOcsUrl(`cloud/groups/details?search=${query}&limit=100`, 2))
.then((response) => {
if (Object.keys(response.data.ocs.data.groups).length > 0) {
response.data.ocs.data.groups.forEach((element) => {
Expand Down

0 comments on commit f3ee2ab

Please sign in to comment.