forked from ddrilling/asb_cloud_front
Проверка прав для импорта, измерений и аналитики
This commit is contained in:
parent
5ef6279f17
commit
a275bd20c7
@ -18,11 +18,12 @@ import { View } from './View'
|
||||
|
||||
import '@styles/index.css'
|
||||
import '@styles/measure.css'
|
||||
import { hasPermission } from '@asb/utils/permissions'
|
||||
|
||||
const createEditingColumns = (cols, renderDelegate) =>
|
||||
cols.map(col => ({ render: renderDelegate, ...col }))
|
||||
|
||||
export const MeasureTable = memo(({idWell, group, updateMeasuresFunc, additionalButtons}) => {
|
||||
export const MeasureTable = memo(({ idWell, group, updateMeasuresFunc, additionalButtons }) => {
|
||||
const [showLoader, setShowLoader] = useState(false)
|
||||
const [displayedValues, setDisplayedValues] = useState({})
|
||||
const [editingColumns, setEditingColumns] = useState(group.columns)
|
||||
@ -64,7 +65,9 @@ export const MeasureTable = memo(({idWell, group, updateMeasuresFunc, additional
|
||||
'Удаление записи для скважины'
|
||||
)
|
||||
|
||||
const isDataDefault = () => !!displayedValues?.isDefaultData
|
||||
const disabled = !hasPermission('Measure.edit')
|
||||
const editingDisabled = disabled || !!displayedValues?.isDefaultData
|
||||
const deleteDisabled = !hasPermission('Measure.delete') || !!displayedValues?.isDefaultData
|
||||
|
||||
const editTable = (action) => {
|
||||
setEditingActionName(action)
|
||||
@ -116,14 +119,14 @@ export const MeasureTable = memo(({idWell, group, updateMeasuresFunc, additional
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Button key={'add'} className={'flex-1'} onClick={() => editTable('add')}>
|
||||
<Button key={'add'} className={'flex-1'} onClick={() => editTable('add')} disabled={disabled}>
|
||||
<PlusOutlined />
|
||||
</Button>
|
||||
<Button key={'edit'} className={'flex-1'} onClick={() => editTable('edit')} disabled={isDataDefault()}>
|
||||
<Button key={'edit'} className={'flex-1'} onClick={() => editTable('edit')} disabled={editingDisabled}>
|
||||
<EditOutlined />
|
||||
</Button>
|
||||
<Popconfirm style={{ flex: '1' }} title={'Удалить данные?'} onConfirm={markMeasuresAsDeleted} disabled={isDataDefault()}>
|
||||
<Button key={'delete'} onClick={() => setEditingActionName('delete')} disabled={isDataDefault()}>
|
||||
<Popconfirm style={{ flex: '1' }} title={'Удалить данные?'} onConfirm={markMeasuresAsDeleted} disabled={deleteDisabled}>
|
||||
<Button key={'delete'} onClick={() => setEditingActionName('delete')} disabled={deleteDisabled}>
|
||||
<DeleteOutlined style={{ margin:'auto 28px' }}/>
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
|
@ -3,6 +3,7 @@ import { Button, Tooltip, Modal } from 'antd'
|
||||
import { FileOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons'
|
||||
|
||||
import { download } from '@components/factory'
|
||||
import { hasPermission } from '@utils/permissions'
|
||||
|
||||
import { ImportOperations } from './ImportOperations'
|
||||
|
||||
@ -23,7 +24,7 @@ export const ImportExportBar = memo(({ idWell, onImported, disabled }) => {
|
||||
<>
|
||||
<Tooltip title={'Импорт - загрузить файл с операциями на сервер'}>
|
||||
<Button
|
||||
disabled={disabled}
|
||||
disabled={!hasPermission('WellOperation.edit') || disabled}
|
||||
icon={<ImportOutlined/>}
|
||||
style={style}
|
||||
onClick={() => setIsImportModalVisible(true)}/>
|
||||
|
@ -8,6 +8,7 @@ import LoaderPortal from '@components/LoaderPortal'
|
||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||
import { makeTextColumn, makeNumericColumnPlanFact } from '@components/Table'
|
||||
import { DrillParamsService, WellCompositeService } from '@api'
|
||||
import { hasPermission } from '@utils/permissions'
|
||||
|
||||
import {
|
||||
calcAndUpdateStatsBySections,
|
||||
@ -172,7 +173,7 @@ export const WellCompositeSections = memo(({ idWell, statsWells, selectedSection
|
||||
|
||||
const rowSelection = {
|
||||
selectedRowKeys: selectedWellsKeys,
|
||||
onChange: (keys, items) => invokeWebApiWrapperAsync(
|
||||
onChange: (keys, items) => hasPermission('WellOperation.edit') && invokeWebApiWrapperAsync(
|
||||
async () => {
|
||||
const selectedSections = items.map((row) => ({idWell, idWellSrc: row.id, idWellSectionType: row.sectionId}))
|
||||
await WellCompositeService.save(idWell, selectedSections)
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
WellCompositeService,
|
||||
} from '@api'
|
||||
import { arrayOrDefault } from '@utils'
|
||||
import { hasPermission } from '@utils/permissions'
|
||||
import LoaderPortal from '@components/LoaderPortal'
|
||||
import { invokeWebApiWrapperAsync } from '@components/factory'
|
||||
import { PrivateDefaultRoute, PrivateMenuItemLink, PrivateRoute } from '@components/Private'
|
||||
@ -103,6 +104,7 @@ export const WellCompositeEditor = memo(({ idWell }) => {
|
||||
tagRender={(props) => (
|
||||
<Tag {...props}>{wellLabels[props.value] ?? props.label}</Tag>
|
||||
)}
|
||||
disabled={!hasPermission('WellOperation.edit')}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
|
Loading…
Reference in New Issue
Block a user