Load role permissions when opening the Edit Role dialog
The dialog reads from rolePermissionsForView / roleUsersForView, but
editRole(role) only ever populated the form fields and showed the
dialog — those arrays were left at whatever state the rest of the page
had set them to. Result: opening Edit Role for a role with existing
permissions showed "No permissions assigned to this role yet", and the
list only "appeared" because adding a permission triggered a refresh.
Mirror viewRole's pattern: clear both arrays, GET /admin/roles/{id},
populate from the response, then show the dialog after $nextTick.
Closes #14
This commit is contained in:
parent
0f2a38ee7f
commit
55f8249f2c
1 changed files with 23 additions and 1 deletions
|
|
@ -709,7 +709,7 @@ window.app = Vue.createApp({
|
|||
}
|
||||
},
|
||||
|
||||
editRole(role) {
|
||||
async editRole(role) {
|
||||
this.editingRole = true
|
||||
this.selectedRole = role
|
||||
this.roleForm = {
|
||||
|
|
@ -717,6 +717,28 @@ window.app = Vue.createApp({
|
|||
description: role.description || '',
|
||||
is_default: role.is_default || false
|
||||
}
|
||||
this.rolePermissionsForView = []
|
||||
this.roleUsersForView = []
|
||||
|
||||
try {
|
||||
const response = await LNbits.api.request(
|
||||
'GET',
|
||||
`/libra/api/v1/admin/roles/${role.id}`,
|
||||
this.g.user.wallets[0].adminkey
|
||||
)
|
||||
this.rolePermissionsForView = [...(response.data.permissions || [])]
|
||||
this.roleUsersForView = [...(response.data.users || [])]
|
||||
} catch (error) {
|
||||
console.error('Failed to load role details:', error)
|
||||
this.$q.notify({
|
||||
type: 'negative',
|
||||
message: 'Failed to load role permissions',
|
||||
caption: error.message || 'Unknown error',
|
||||
timeout: 5000
|
||||
})
|
||||
}
|
||||
|
||||
await this.$nextTick()
|
||||
this.showCreateRoleDialog = true
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue