display role names instead of _id

This commit is contained in:
Maurits Lourens 2021-07-23 23:27:38 +02:00
parent d8136d0704
commit 03ecf7f34f
3 changed files with 6 additions and 4 deletions

View File

@ -36,7 +36,8 @@
$: defaultRoleId = $userFetch?.data?.builder?.global ? "ADMIN" : "BASIC"
// Merge the Apps list and the roles response to get something that makes sense for the table
$: appList = Object.keys($apps?.data).map(id => {
const role = $userFetch?.data?.roles?.[id] || defaultRoleId
const roleId = $userFetch?.data?.roles?.[id] || defaultRoleId
const role = $apps?.data?.[id].roles.find(role => role._id === roleId)
return {
...$apps?.data?.[id],
_id: id,

View File

@ -4,7 +4,7 @@
const displayLimit = 5
$: roles = value?.filter(role => role != null) ?? []
$: roles = value?.filter(role => role != null).map(role => role.name) ?? []
$: tags = roles.slice(0, displayLimit)
$: leftover = roles.length - tags.length
</script>

View File

@ -8,8 +8,7 @@
const dispatch = createEventDispatcher()
const roles = app.roles
let options = roles.map(role => role._id).filter(id => id !== "PUBLIC")
let options = app.roles.filter(role => role._id !== "PUBLIC")
let selectedRole = user?.roles?.[app?._id]
async function updateUserRoles() {
@ -46,5 +45,7 @@
on:change
{options}
label="Role"
getOptionLabel={role => role.name}
getOptionValue={role => role._id}
/>
</ModalContent>