From f3ee2ab82cca282eaf00fed80d4c64dff2f46966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 11 May 2023 16:50:23 +0200 Subject: [PATCH] fix: Filter selected groups first and properly display groups that are not fetched in the initial result response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/components/SettingsSelectGroup.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/SettingsSelectGroup.vue b/src/components/SettingsSelectGroup.vue index db2dbd9ceb..927387b47b 100644 --- a/src/components/SettingsSelectGroup.vue +++ b/src/components/SettingsSelectGroup.vue @@ -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: { @@ -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() }) @@ -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) => {