Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve group multiselect behaviour with multiple and long group names #2944

Merged
merged 3 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,9 @@ export default {

input[type='text'],
.multiselect {
width: 100%;
max-width: 400px;
width: auto;
min-width: 200px;
max-width: 100%;
}

input#wopi_url {
Expand Down
16 changes: 12 additions & 4 deletions src/components/SettingsSelectGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
<template>
<NcMultiselect v-model="inputValObjects"
:options="groupsArray"
:options-limit="5"
:auto-limit="false"
:placeholder="label"
track-by="id"
label="displayname"
class="multiselect-vue"
:multiple="true"
:close-on-select="false"
:tag-width="60"
:disabled="disabled"
@input="update"
@search-change="asyncFindGroup">
Expand Down Expand Up @@ -78,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 @@ -89,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 @@ -112,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