Fix preloading some role pickers values correctly
This commit is contained in:
parent
550db9f7ae
commit
36a787f705
@ -98,11 +98,19 @@ export default {
|
||||
},
|
||||
|
||||
preloadSelected () {
|
||||
if (!this.value.length) {
|
||||
return
|
||||
}
|
||||
|
||||
this.preloading = true
|
||||
|
||||
return this.$SystemAPI.roleList({ memberID: this.$auth.user.userID })
|
||||
.then(({ set }) => { this.selectedRoles = set || [] })
|
||||
.finally(() => { this.preloading = false })
|
||||
return this.$SystemAPI.roleList({ roleID: this.value })
|
||||
.then(({ set }) => {
|
||||
this.selectedRoles = set || []
|
||||
})
|
||||
.finally(() => {
|
||||
this.preloading = false
|
||||
})
|
||||
.catch(this.toastErrorHandler(this.$t('notification:role.fetch.error')))
|
||||
},
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@
|
||||
/>
|
||||
|
||||
<c-user-editor-roles
|
||||
v-if="user && userID"
|
||||
v-if="user && userID && membership.active"
|
||||
v-model="membership.active"
|
||||
class="mt-3"
|
||||
:processing="roles.processing"
|
||||
@ -147,8 +147,8 @@ export default {
|
||||
initialUserState: undefined,
|
||||
|
||||
membership: {
|
||||
active: [],
|
||||
initial: [],
|
||||
active: undefined,
|
||||
initial: undefined,
|
||||
},
|
||||
|
||||
externalAuthProviders: [],
|
||||
@ -238,7 +238,10 @@ export default {
|
||||
this.incLoader()
|
||||
return this.$SystemAPI.userMembershipList({ userID: this.userID })
|
||||
.then((set = []) => {
|
||||
this.membership = { active: [...set], initial: [...set] }
|
||||
this.membership = {
|
||||
active: [...set],
|
||||
initial: [...set],
|
||||
}
|
||||
})
|
||||
.catch(this.toastErrorHandler(this.$t('notification:user.roles.error')))
|
||||
.finally(() => {
|
||||
|
||||
@ -952,25 +952,23 @@ export default {
|
||||
|
||||
methods: {
|
||||
fetchRoles () {
|
||||
if (this.options.filterPresets.length) {
|
||||
this.fetchingRoles = true
|
||||
|
||||
const rolesToResolve = this.options.filterPresets.reduce((acc, { roles }) => {
|
||||
return acc.concat(roles)
|
||||
}, [])
|
||||
|
||||
Promise.all(rolesToResolve.map(roleID => {
|
||||
if (this.resolvedRoles[roleID]) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
return this.$SystemAPI.roleRead({ roleID }).then(role => {
|
||||
this.resolvedRoles[roleID] = role
|
||||
})
|
||||
})).finally(() => {
|
||||
this.fetchingRoles = false
|
||||
})
|
||||
if (!this.options.filterPresets.length) {
|
||||
return
|
||||
}
|
||||
|
||||
this.fetchingRoles = true
|
||||
|
||||
const rolesToResolve = this.options.filterPresets.reduce((acc, { roles }) => {
|
||||
return acc.concat(roles)
|
||||
}, [])
|
||||
|
||||
this.$SystemAPI.roleList({ roleID: rolesToResolve }).then(({ set }) => {
|
||||
set.forEach(role => {
|
||||
this.resolvedRoles[role.roleID] = role
|
||||
})
|
||||
}).finally(() => {
|
||||
this.fetchingRoles = false
|
||||
})
|
||||
},
|
||||
|
||||
onFilterRoleChange (filter, roles) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user