From 5dc14a4065557a01e078760917b64590901ee2b8 Mon Sep 17 00:00:00 2001 From: Norman Niati Date: Mon, 18 May 2026 16:00:00 +0200 Subject: [PATCH] feat(plugin-id): show Groups field on user creation with open dropdown Per Fabrice's review (18 mai 13:30): the Groups multi-select autosuggest was previously hidden on /id/user/new with a v-if="isEdit". Removing the guard so the field is visible on both create and edit modes. The save() payload is updated to send the groups array in both cases. On /new only, the dropdown is preloaded with the first 20 groups and opened on mount so the available groups are visible without typing. /edit keeps the existing behaviour (the user's existing groups are already shown as chips). --- ui/src/views/UserEditView.vue | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/ui/src/views/UserEditView.vue b/ui/src/views/UserEditView.vue index 48424ec..1a3629e 100644 --- a/ui/src/views/UserEditView.vue +++ b/ui/src/views/UserEditView.vue @@ -58,8 +58,8 @@ v-model holds an array of group **names** (strings), matching the payload contract of rest/service/id/user. --> !!route.params.id) @@ -286,6 +287,24 @@ function onGroupModelUpdate() { groupResults.value = [] } +/** Preload the first page of groups so the dropdown can be opened + * with content already visible on mount (used on /new where the user + * has no pre-selected groups). The list endpoint returns 200 with an + * empty array when no IAM is configured, so this is safe to call. */ +async function preloadGroups() { + groupLoading.value = true + try { + const url = 'rest/service/id/group?rows=20&page=1&sidx=name&sord=asc' + const resp = await api.get(url) + groupResults.value = Array.isArray(resp) ? resp : (Array.isArray(resp?.data) ? resp.data : []) + } catch (err) { + console.error('Group preload failed:', err) + groupResults.value = [] + } finally { + groupLoading.value = false + } +} + async function searchGroups(query) { if (!query || query.length < 1) { groupResults.value = [] @@ -406,6 +425,11 @@ onMounted(async () => { demoMode.value = true errorStore.clear() } + // Preload group list and open the dropdown so the available groups + // are visible on mount (per Fabrice's UX feedback). Only on /new + // since /edit already shows the user's existing groups as chips. + await preloadGroups() + groupMenu.value = true } initGuard() }) @@ -427,9 +451,8 @@ async function save() { company: form.value.company, mail: form.value.mail, // groups is an array of names (strings). Defensive `.map(g => g.name || g)` - // in case any legacy object slipped through. Only sent on edit since the - // groups field is hidden on New User for this PR. - ...(isEdit.value ? { groups: groups.value.map(g => g.name || g) } : {}), + // in case any legacy object slipped through. + groups: groups.value.map(g => g.name || g), } if (isEdit.value) {