From 8f5b48355d00fe4cad7c637756b4ce3533330490 Mon Sep 17 00:00:00 2001 From: goodmice Date: Wed, 15 Jun 2022 12:22:38 +0500 Subject: [PATCH] =?UTF-8?q?*=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B2=20EditableTable=20*=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B5=D0=B5=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20Menu.Item=20*=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B0=D0=B2=20=D0=BA=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=B3=D0=BE=D1=80=D0=B8=D0=B9=20=D0=B2=20Documents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Private/PrivateMenu.tsx | 7 ++----- src/components/Table/EditableTable.jsx | 6 +++--- src/pages/Documents/DocumentsTemplate.jsx | 5 +++-- src/pages/Documents/index.jsx | 24 ++++++++++++----------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/components/Private/PrivateMenu.tsx b/src/components/Private/PrivateMenu.tsx index fa246cd..8913560 100644 --- a/src/components/Private/PrivateMenu.tsx +++ b/src/components/Private/PrivateMenu.tsx @@ -19,10 +19,8 @@ export type PrivateMenuLinkProps = Partial & Omit & R permissions?: string[] } -export const PrivateMenuLink = memo(({ content, danger, icon, path = '', title, ...other }) => ( - - {title ?? content?.title} - +export const PrivateMenuLink = memo(({ content, path = '', title, ...other }) => ( + {title ?? content?.title} )) const PrivateMenuMain = memo(({ selectable, mode, selectedKeys, root, children, ...other }) => { @@ -55,7 +53,6 @@ const PrivateMenuMain = memo(({ selectable, mode, selectedKeys if (visible || hasPermission(permissions)) return { ...child.props, - icon: null, key, label: , } diff --git a/src/components/Table/EditableTable.jsx b/src/components/Table/EditableTable.jsx index c911d19..a7a835c 100755 --- a/src/components/Table/EditableTable.jsx +++ b/src/components/Table/EditableTable.jsx @@ -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]) diff --git a/src/pages/Documents/DocumentsTemplate.jsx b/src/pages/Documents/DocumentsTemplate.jsx index a5cfe49..6bc1829 100755 --- a/src/pages/Documents/DocumentsTemplate.jsx +++ b/src/pages/Documents/DocumentsTemplate.jsx @@ -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 diff --git a/src/pages/Documents/index.jsx b/src/pages/Documents/index.jsx index ba1f60a..e65b331 100755 --- a/src/pages/Documents/index.jsx +++ b/src/pages/Documents/index.jsx @@ -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 => ( } title={category.title} + permissions={category.permissions} /> ))}