fix(settings): Fix duplicated group options in new account dialog

Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
Christopher Ng 2025-03-25 14:31:45 -07:00 committed by backportbot[bot]
parent 42b7fda39b
commit a5e2c7dd38

View file

@ -71,8 +71,7 @@
:multiple="true"
:taggable="true"
:required="!settings.isAdmin && !settings.isDelegatedAdmin"
:create-option="(value) => ({ name: value })"
@input="handleGroupInput"
:create-option="(value) => ({ id: value, name: value, isCreating: true })"
@search="searchGroups"
@option:created="createGroup" />
<!-- If user is not admin, he is a subadmin.
@ -271,15 +270,6 @@ export default {
}
},
handleGroupInput(groups) {
/**
* Filter out groups with no id to prevent duplicate selected options
*
* Created groups are added programmatically by `createGroup()`
*/
this.newUser.groups = groups.filter(group => Boolean(group.id))
},
async searchGroups(query, toggleLoading) {
if (this.promise) {
this.promise.cancel()
@ -318,6 +308,21 @@ export default {
this.loading.groups = false
},
/**
* Add user to group
*
* @param {object} group Group object
*/
async addGroup(group) {
if (group.isCreating) {
return
}
if (group.canAdd === false) {
return
}
this.newUser.groups.push(group)
},
/**
* Validate quota string to make sure it's a valid human file size
*