* Исправлена ширина колонок контроллера ролей

* Продолжена мемоизация
This commit is contained in:
Александр Сироткин 2022-03-03 19:34:22 +05:00
parent 592cfc30e2
commit 2b227e9777
7 changed files with 34 additions and 33 deletions

View File

@ -1,4 +1,4 @@
import { memo, useEffect, useState } from 'react'
import { memo, useCallback, useEffect, useState } from 'react'
import {
EditableTable,
@ -40,7 +40,7 @@ export const ClusterController = memo(() => {
makeTimezoneColumn('Зона', 'timezone', null, true, { width: 150 }),
]
const updateTable = () => invokeWebApiWrapperAsync(
const updateTable = useCallback(() => invokeWebApiWrapperAsync(
async () => {
const clusters = await AdminClusterService.getAll()
setClusters(arrayOrDefault(clusters))
@ -48,7 +48,7 @@ export const ClusterController = memo(() => {
setShowLoader,
`Не удалось загрузить список кустов`,
'Получение списка кустов'
)
), [])
useEffect(() => invokeWebApiWrapperAsync(
async () => {
@ -61,7 +61,7 @@ export const ClusterController = memo(() => {
'Получение списка месторождений'
), [])
useEffect(updateTable, [])
useEffect(updateTable, [updateTable])
const handlerProps = {
service: AdminClusterService,

View File

@ -1,4 +1,4 @@
import { memo, useEffect, useState } from 'react'
import { memo, useCallback, useEffect, useState } from 'react'
import {
EditableTable,
@ -21,10 +21,10 @@ export const CompanyController = memo(() => {
const [companies, setCompanies] = useState([])
const [showLoader, setShowLoader] = useState(false)
const updateTable = async () => {
const updateTable = useCallback(async () => {
const companies = await AdminCompanyService.getAll()
setCompanies(arrayOrDefault(companies))
}
}, [])
useEffect(() => invokeWebApiWrapperAsync(
async() => {
@ -51,7 +51,7 @@ export const CompanyController = memo(() => {
setShowLoader,
`Не удалось загрузить список типов компаний`,
'Получение списка типов команд'
), [])
), [updateTable])
const handlerProps = {
service: AdminCompanyService,

View File

@ -1,4 +1,4 @@
import { memo, useEffect, useState } from 'react'
import { memo, useCallback, useEffect, useState } from 'react'
import {
EditableTable,
@ -27,7 +27,7 @@ export const CompanyTypeController = memo(() => {
const [companyTypes, setCompanyTypes] = useState([])
const [showLoader, setShowLoader] = useState(false)
const updateTable = () => invokeWebApiWrapperAsync(
const updateTable = useCallback(() => invokeWebApiWrapperAsync(
async() => {
const companyTypes = await AdminCompanyTypeService.getAll()
setCompanyTypes(arrayOrDefault(companyTypes))
@ -35,9 +35,9 @@ export const CompanyTypeController = memo(() => {
setShowLoader,
`Не удалось загрузить список типов компаний`,
'Получение списка типов компаний'
)
), [])
useEffect(updateTable, [])
useEffect(updateTable, [updateTable])
const handlerProps = {
service: AdminCompanyTypeService,

View File

@ -1,4 +1,4 @@
import { memo, useEffect, useState } from 'react'
import { memo, useCallback, useEffect, useState } from 'react'
import LoaderPortal from '@components/LoaderPortal'
import { invokeWebApiWrapperAsync } from '@components/factory'
@ -21,7 +21,7 @@ export const DepositController = memo(() => {
const [deposits, setDeposits] = useState([])
const [showLoader, setShowLoader] = useState(false)
const updateTable = () => invokeWebApiWrapperAsync(
const updateTable = useCallback(() => invokeWebApiWrapperAsync(
async() => {
const deposits = await AdminDepositService.getAll()
setDeposits(arrayOrDefault(deposits))
@ -29,9 +29,9 @@ export const DepositController = memo(() => {
setShowLoader,
`Не удалось загрузить список месторождении`,
'Получение списка месторождений'
)
), [])
useEffect(updateTable, [])
useEffect(updateTable, [updateTable])
const handlerProps = {
service: AdminDepositService,

View File

@ -1,4 +1,4 @@
import { memo, useEffect, useState } from 'react'
import { memo, useCallback, useEffect, useState } from 'react'
import {
EditableTable,
@ -30,7 +30,7 @@ export const PermissionController = memo(() => {
const [showLoader, setShowLoader] = useState(false)
const [permissions, setPermissions] = useState([])
const updateTable = async () => invokeWebApiWrapperAsync(
const updateTable = useCallback(async () => invokeWebApiWrapperAsync(
async () => {
const permission = await AdminPermissionService.getAll()
setPermissions(arrayOrDefault(permission))
@ -38,9 +38,9 @@ export const PermissionController = memo(() => {
setShowLoader,
`Не удалось загрузить список прав`,
'Получение списка прав'
)
), [])
useEffect(() => updateTable(), [])
useEffect(() => updateTable(), [updateTable])
const handlerProps = {
service: AdminPermissionService,

View File

@ -1,4 +1,4 @@
import { memo, useEffect, useState } from 'react'
import { memo, useCallback, useEffect, useState } from 'react'
import LoaderPortal from '@components/LoaderPortal'
import { PermissionView, RoleView } from '@components/views'
@ -15,20 +15,21 @@ export const RoleController = memo(() => {
const [showLoader, setShowLoader] = useState(false)
const [columns, setColumns] = useState([])
const loadRoles = async () => {
const loadRoles = useCallback(async () => {
const roles = await AdminUserRoleService.getAll()
setRoles(arrayOrDefault(roles))
}
}, [])
useEffect(() => {
setColumns([
makeColumn('Название', 'caption', { width: 200, editable: true, formItemRules: min1 }),
makeColumn('Название', 'caption', { width: 100, editable: true, formItemRules: min1 }),
makeTagColumn('Включённые роли', 'roles', roles, 'id', 'caption', {
width: 200,
width: 400,
editable: true,
render: (role) => <RoleView role={role} />
}, { allowClear: true }),
makeTagColumn('Разрешения', 'permissions', permissions, 'id', 'name', {
width: 600,
editable: true,
render: (permission) => <PermissionView info={permission} />,
}),
@ -44,7 +45,7 @@ export const RoleController = memo(() => {
setShowLoader,
`Не удалось загрузить список ролей`,
'Получение списка ролей'
), [])
), [loadRoles])
const handlerProps = {
service: AdminUserRoleService,

View File

@ -35,6 +35,11 @@ const wellTypes = [
{ value: 2, label: 'Горизонтальная' },
]
const recordParser = (record) => ({
...record,
idTelemetry: record.telemetry?.id,
})
export const WellController = memo(() => {
const [columns, setColumns] = useState([])
const [wells, setWells] = useState([])
@ -54,14 +59,14 @@ export const WellController = memo(() => {
// TODO: Метод дубликации скважины
}
const addititonalButtons = (record, editingKey) => (
const addititonalButtons = memo((record, editingKey) => (
<Button
icon={<CopyOutlined />}
title={'Дублировать скважину'}
disabled={(editingKey ?? '') !== ''}
onClick={() => duplicateWell(record)}
/>
)
))
useEffect(() => invokeWebApiWrapperAsync(
async () => {
@ -109,11 +114,6 @@ export const WellController = memo(() => {
'Получение списка кустов'
), [])
const recordParser = (record) => ({
...record,
idTelemetry: record.telemetry?.id,
})
const handlerProps = {
service: AdminWellService,
setLoader: setShowLoader,