diff --git a/public/index.html b/public/index.html index 4eccf76..aeeddf7 100644 --- a/public/index.html +++ b/public/index.html @@ -17,4 +17,3 @@
-ц \ No newline at end of file diff --git a/src/components/views/RoleView.tsx b/src/components/views/RoleView.tsx index c951e51..3011446 100644 --- a/src/components/views/RoleView.tsx +++ b/src/components/views/RoleView.tsx @@ -7,36 +7,54 @@ import PermissionView from './PermissionView' export type RoleViewProps = { role?: UserRoleDto - parentRole?: UserRoleDto } -export const RoleView = memo(({ role, parentRole }) => role ? ( - - Название: - {role.caption} +export const RoleView = memo(({ role }) => { + const hasIncludedRoles = (role?.roles?.length && role.roles.length > 0) ? 1 : 0 + const hasPermissions = (role?.permissions?.length && role.permissions.length > 0) ? 1 : 0 - Роль-родитель: - {parentRole?.caption ?? 'Отсутствует'} + return role ? ( + + Название: + {role.caption} - Тип: - {role.idType} + Включённые роли: + {hasIncludedRoles ? ( + + {role.roles?.map((role, i) => ( + + + + ))} + + ) : ( + Отсутствуют + )} - Разрешения: - - {role.permissions?.map((permission, i) => ( - - - - )) ?? '-'} - - - } - > - {role.caption} - -) : ( - - -)) + Тип: + {role.idType} + + Разрешения: + {hasPermissions ? ( + + {role.permissions?.map((permission, i) => ( + + + + ))} + + ) : ( + Отсутствуют + )} + + } + > + {role.caption} + + ) : ( + - + ) +}) diff --git a/src/pages/AdminPanel/RoleController.jsx b/src/pages/AdminPanel/RoleController.jsx index 5d5ce6e..cfc6e32 100644 --- a/src/pages/AdminPanel/RoleController.jsx +++ b/src/pages/AdminPanel/RoleController.jsx @@ -1,9 +1,9 @@ import { memo, useEffect, useState } from 'react' import LoaderPortal from '../../components/LoaderPortal' -import { PermissionView } from '../../components/views' +import { PermissionView, RoleView } from '../../components/views' import { invokeWebApiWrapperAsync } from '../../components/factory' -import { EditableTable, makeActionHandler, makeColumn, makeSelectColumn, makeTagColumn } from '../../components/Table' +import { EditableTable, makeActionHandler, makeColumn, makeTagColumn } from '../../components/Table' import { AdminPermissionService, AdminUserRoleService } from '../../services/api' import { arrayOrDefault } from '../../utils' import { min1 } from '../../utils/validationRules' @@ -20,12 +20,12 @@ export const RoleController = memo(() => { } useEffect(() => { - const options = roles?.map((r) => ({ value: r.id, label: r.caption })) ?? [] setColumns([ makeColumn('Название', 'caption', { width: 200, editable: true, formItemRules: min1 }), - makeSelectColumn('Роль-родитель', 'idParent', options, options[0], { + makeTagColumn('Включённые роли', 'roles', roles, 'id', 'caption', { width: 200, - editable: true + editable: true, + render: (role) => }, { allowClear: true }), makeTagColumn('Разрешения', 'permissions', permissions, 'id', 'name', { editable: true, @@ -58,8 +58,8 @@ export const RoleController = memo(() => { return (