forked from ddrilling/asb_cloud_front
* Исправлена обработка методов в EditableTable
* Удалено лишнее использование Menu.Item * Добавлена обработка прав категорий в Documents
This commit is contained in:
parent
c2338c98ab
commit
8f5b48355d
@ -19,10 +19,8 @@ export type PrivateMenuLinkProps = Partial<ItemType> & Omit<LinkProps, 'to'> & R
|
||||
permissions?: string[]
|
||||
}
|
||||
|
||||
export const PrivateMenuLink = memo<PrivateMenuLinkProps>(({ content, danger, icon, path = '', title, ...other }) => (
|
||||
<Menu.Item icon={icon ?? content?.icon} danger={danger}>
|
||||
<Link to={path} {...other}>{title ?? content?.title}</Link>
|
||||
</Menu.Item>
|
||||
export const PrivateMenuLink = memo<PrivateMenuLinkProps>(({ content, path = '', title, ...other }) => (
|
||||
<Link to={path} {...other}>{title ?? content?.title}</Link>
|
||||
))
|
||||
|
||||
const PrivateMenuMain = memo<PrivateMenuProps>(({ selectable, mode, selectedKeys, root, children, ...other }) => {
|
||||
@ -55,7 +53,6 @@ const PrivateMenuMain = memo<PrivateMenuProps>(({ selectable, mode, selectedKeys
|
||||
if (visible || hasPermission(permissions))
|
||||
return {
|
||||
...child.props,
|
||||
icon: null,
|
||||
key,
|
||||
label: <PrivateMenuLink {...child.props} path={path} />,
|
||||
}
|
||||
|
@ -75,9 +75,9 @@ export const EditableTable = memo(({
|
||||
const [data, setData] = useState(tryAddKeys(dataSource))
|
||||
const [editingKey, setEditingKey] = useState('')
|
||||
|
||||
const onAdd = useMemo(() => typeof onRowAdd === 'function' ? onRowAdd : makeTableAction(onRowAdd), [onRowAdd])
|
||||
const onEdit = useMemo(() => typeof onRowEdit === 'function' ? onRowEdit : makeTableAction(onRowEdit), [onRowEdit])
|
||||
const onDelete = useMemo(() => typeof onRowDelete === 'function' ? onRowDelete : makeTableAction(onRowDelete), [onRowDelete])
|
||||
const onAdd = useMemo(() => onRowAdd && typeof onRowAdd !== 'function' ? makeTableAction(onRowAdd) : onRowAdd, [onRowAdd])
|
||||
const onEdit = useMemo(() => onRowEdit && typeof onRowEdit !== 'function' ? makeTableAction(onRowEdit) : onRowEdit, [onRowEdit])
|
||||
const onDelete = useMemo(() => onRowDelete && typeof onRowDelete !== 'function' ? makeTableAction(onRowDelete) : onRowDelete, [onRowDelete])
|
||||
|
||||
const isEditing = useCallback((record) => record?.key === editingKey, [editingKey])
|
||||
|
||||
|
@ -7,6 +7,7 @@ import { UploadForm } from '@components/UploadForm'
|
||||
import { CompanyView, UserView } from '@components/views'
|
||||
import { invokeWebApiWrapperAsync, downloadFile, formatBytes } from '@components/factory'
|
||||
import { EditableTable, makeColumn, makeDateColumn, makeNumericColumn, makePaginationObject } from '@components/Table'
|
||||
import { unique } from '@utils/filters'
|
||||
import { hasPermission } from '@utils'
|
||||
import { FileService } from '@api'
|
||||
|
||||
@ -46,8 +47,8 @@ export const DocumentsTemplate = ({ idCategory, idWell: wellId, mimeTypes, heade
|
||||
const uploadUrl = useMemo(() => `/api/well/${idWell}/files/?idCategory=${idCategory}`, [idWell, idCategory])
|
||||
|
||||
const mergedColumns = useMemo(() => [...columns, ...(customColumns ?? [])], [customColumns])
|
||||
const companies = useMemo(() => [...new Set(files.map(file => file.company))].filter(company => company), [files])
|
||||
const filenames = useMemo(() => [...new Set(files.map(file => file.name))].filter(name => name), [files])
|
||||
const companies = useMemo(() => files.map(file => file?.author?.company?.caption).filter(Boolean).filter(unique), [files])
|
||||
const filenames = useMemo(() => files.map(file => file.name).filter(Boolean).filter(unique), [files])
|
||||
|
||||
const update = useCallback(() => {
|
||||
let begin = null
|
||||
|
@ -11,17 +11,19 @@ import DocumentsTemplate from './DocumentsTemplate'
|
||||
|
||||
const { Content } = Layout
|
||||
|
||||
const makeDocCat = (id, key, title, permissions = ['File.get']) => ({ id, key, title, permissions })
|
||||
|
||||
export const documentCategories = [
|
||||
{ id: 1, key: 'fluidService', title: 'Растворный сервис' },
|
||||
{ id: 2, key: 'cementing', title: 'Цементирование' },
|
||||
{ id: 3, key: 'nnb', title: 'ННБ' },
|
||||
{ id: 4, key: 'gti', title: 'ГТИ' },
|
||||
{ id: 5, key: 'documentsForWell', title: 'Документы по скважине' },
|
||||
{ id: 6, key: 'supervisor', title: 'Супервайзер' },
|
||||
{ id: 7, key: 'master', title: 'Мастер' },
|
||||
{ id: 8, key: 'toolService', title: 'Долотный сервис' },
|
||||
{ id: 9, key: 'drillService', title: 'Буровой подрядчик' },
|
||||
{ id: 9, key: 'closingService', title: 'Сервис по заканчиванию скважины' },
|
||||
makeDocCat(1 , 'fluidService' , 'Растворный сервис' ),
|
||||
makeDocCat(2 , 'cementing' , 'Цементирование' ),
|
||||
makeDocCat(3 , 'nnb' , 'ННБ' ),
|
||||
makeDocCat(4 , 'gti' , 'ГТИ' ),
|
||||
makeDocCat(5 , 'documentsForWell', 'Документы по скважине' ),
|
||||
makeDocCat(6 , 'supervisor' , 'Супервайзер' ),
|
||||
makeDocCat(7 , 'master' , 'Мастер' ),
|
||||
makeDocCat(8 , 'toolService' , 'Долотный сервис' ),
|
||||
makeDocCat(9 , 'drillService' , 'Буровой подрядчик' ),
|
||||
makeDocCat(10, 'closingService' , 'Сервис по заканчиванию скважины'),
|
||||
]
|
||||
|
||||
const MenuDocuments = memo(() => {
|
||||
@ -35,9 +37,9 @@ const MenuDocuments = memo(() => {
|
||||
{documentCategories.map(category => (
|
||||
<PrivateMenu.Link
|
||||
key={`${category.key}`}
|
||||
className={'ant-menu-item'}
|
||||
icon={<FolderOutlined/>}
|
||||
title={category.title}
|
||||
permissions={category.permissions}
|
||||
/>
|
||||
))}
|
||||
</PrivateMenu>
|
||||
|
Loading…
Reference in New Issue
Block a user