project fix filters
This commit is contained in:
parent
877ecb4f98
commit
1f2c8e5411
@ -26,7 +26,7 @@ const TablesList = ({ filteredTables, query, basePath = '/table', formInfo, isPr
|
|||||||
groups[year] = [...(groups[year] || []), table];
|
groups[year] = [...(groups[year] || []), table];
|
||||||
return groups;
|
return groups;
|
||||||
}, {}),
|
}, {}),
|
||||||
).sort(([firstYear], [secondYear]) => Number(secondYear) - Number(firstYear))
|
).sort(([firstYear], [secondYear]) => Number(firstYear) - Number(secondYear))
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
import CloseIcon from '@mui/icons-material/Close';
|
import CloseIcon from '@mui/icons-material/Close';
|
||||||
import { Box, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, MenuItem, TextField, Typography } from '@mui/material';
|
import { Box, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, MenuItem, TextField, Typography } from '@mui/material';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useAuth } from '../../../../app/context/AuthProvider';
|
||||||
import { DangerOutlinedButton, PrimaryButton } from '../../../../components/common/Buttons/Buttons';
|
import { DangerOutlinedButton, PrimaryButton } from '../../../../components/common/Buttons/Buttons';
|
||||||
import { DEVELOMENT_BLOCK, FUNDING_BY_DECISION } from '../../constants';
|
import { DEVELOMENT_BLOCK, FUNDING_BY_DECISION } from '../../constants';
|
||||||
|
import { canEditFirstTableField } from '../../constants/fieldAccess';
|
||||||
|
|
||||||
const EditModal = ({ open, onClose, rowData, onSave, isSaving = false, orgUnitNames = {} }) => {
|
const EditModal = ({ open, onClose, rowData, onSave, isSaving = false, orgUnitNames = {} }) => {
|
||||||
|
const { user } = useAuth();
|
||||||
const [formData, setFormData] = React.useState(rowData || {});
|
const [formData, setFormData] = React.useState(rowData || {});
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@ -66,6 +69,7 @@ const EditModal = ({ open, onClose, rowData, onSave, isSaving = false, orgUnitNa
|
|||||||
// Компонент для поля ввода
|
// Компонент для поля ввода
|
||||||
const renderField = (field) => {
|
const renderField = (field) => {
|
||||||
const rawValue = formData[field.key];
|
const rawValue = formData[field.key];
|
||||||
|
const isFieldDisabled = field.disabled || !canEditFirstTableField(field.key, user?.role_id);
|
||||||
const fieldValue = field.valueType === 'boolean' && rawValue !== null && rawValue !== undefined
|
const fieldValue = field.valueType === 'boolean' && rawValue !== null && rawValue !== undefined
|
||||||
? String(rawValue)
|
? String(rawValue)
|
||||||
: (rawValue ?? '');
|
: (rawValue ?? '');
|
||||||
@ -93,7 +97,7 @@ const EditModal = ({ open, onClose, rowData, onSave, isSaving = false, orgUnitNa
|
|||||||
multiline={field.multiline || false}
|
multiline={field.multiline || false}
|
||||||
rows={field.rows || 1}
|
rows={field.rows || 1}
|
||||||
select={Boolean(field.options)}
|
select={Boolean(field.options)}
|
||||||
disabled={field.disabled || isSaving}
|
disabled={isFieldDisabled || isSaving}
|
||||||
InputLabelProps={field.type === 'date' ? { shrink: true } : undefined}
|
InputLabelProps={field.type === 'date' ? { shrink: true } : undefined}
|
||||||
sx={{
|
sx={{
|
||||||
'& .MuiOutlinedInput-root': {
|
'& .MuiOutlinedInput-root': {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { ROLES_NAME_ID } from '../../../../constants/constants';
|
|||||||
|
|
||||||
const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQuery }) => {
|
const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQuery }) => {
|
||||||
const [branches, setBranches] = useState([]);
|
const [branches, setBranches] = useState([]);
|
||||||
|
const [branchInputValue, setBranchInputValue] = useState('');
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
|
|
||||||
@ -44,6 +45,10 @@ const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQu
|
|||||||
loadData();
|
loadData();
|
||||||
}, [loadData]);
|
}, [loadData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setBranchInputValue(selectedBranch?.title || '');
|
||||||
|
}, [selectedBranch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
elevation={0}
|
elevation={0}
|
||||||
@ -71,6 +76,10 @@ const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQu
|
|||||||
getOptionLabel={(option) => option.title || ''}
|
getOptionLabel={(option) => option.title || ''}
|
||||||
getOptionKey={(option) => option.id}
|
getOptionKey={(option) => option.id}
|
||||||
value={selectedBranch || null}
|
value={selectedBranch || null}
|
||||||
|
inputValue={branchInputValue}
|
||||||
|
onInputChange={(event, newInputValue) => {
|
||||||
|
setBranchInputValue(newInputValue);
|
||||||
|
}}
|
||||||
onChange={(event, newValue) => {
|
onChange={(event, newValue) => {
|
||||||
onBranchChange(newValue || '');
|
onBranchChange(newValue || '');
|
||||||
}}
|
}}
|
||||||
@ -100,7 +109,7 @@ const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQu
|
|||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
clearOnBlur={false}
|
clearOnBlur={false}
|
||||||
isOptionEqualToValue={(option, value) => option === value}
|
isOptionEqualToValue={(option, value) => option.id === value.id}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
@ -135,6 +144,7 @@ const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQu
|
|||||||
label='Сбросить фильтры'
|
label='Сбросить фильтры'
|
||||||
size='small'
|
size='small'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setBranchInputValue('');
|
||||||
onBranchChange('');
|
onBranchChange('');
|
||||||
onSearchChange('');
|
onSearchChange('');
|
||||||
}}
|
}}
|
||||||
|
|||||||
35
web/src/pages/ProjectPages/constants/fieldAccess.js
Normal file
35
web/src/pages/ProjectPages/constants/fieldAccess.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import { ROLES_NAME_ID } from '../../../constants/constants';
|
||||||
|
|
||||||
|
const ADMIN_ROLES = [ROLES_NAME_ID.admin];
|
||||||
|
const DFIP_ROLES = [ROLES_NAME_ID.admin, ROLES_NAME_ID.executor_dfip];
|
||||||
|
const RF_ROLES = [ROLES_NAME_ID.admin, ROLES_NAME_ID.executor_rf];
|
||||||
|
|
||||||
|
// Матрица доступа к полям первой таблицы.
|
||||||
|
// Поля «авто» доступны для ручного редактирования только администратору.
|
||||||
|
export const FIRST_TABLE_FIELD_ACCESS = {
|
||||||
|
name: ADMIN_ROLES,
|
||||||
|
org_unit_id: ADMIN_ROLES,
|
||||||
|
status: DFIP_ROLES,
|
||||||
|
technical_number: ADMIN_ROLES,
|
||||||
|
object_address: ADMIN_ROLES,
|
||||||
|
vsp_format: ADMIN_ROLES,
|
||||||
|
placement_type: ADMIN_ROLES,
|
||||||
|
staff_count: ADMIN_ROLES,
|
||||||
|
total_area: ADMIN_ROLES,
|
||||||
|
project_type: ADMIN_ROLES,
|
||||||
|
krf_decision_date: RF_ROLES,
|
||||||
|
fk_decision_date: RF_ROLES,
|
||||||
|
board_decision_date: RF_ROLES,
|
||||||
|
open_relocate_close_date: RF_ROLES,
|
||||||
|
funding_by_ko_decision: DFIP_ROLES,
|
||||||
|
year: ADMIN_ROLES,
|
||||||
|
is_in_plan: DFIP_ROLES,
|
||||||
|
is_in_plan_q2: DFIP_ROLES,
|
||||||
|
is_in_plan_q3: DFIP_ROLES,
|
||||||
|
is_in_plan_q4: DFIP_ROLES,
|
||||||
|
development_block: DFIP_ROLES,
|
||||||
|
reserve_to_prrs_ahr: DFIP_ROLES,
|
||||||
|
reserve_to_prrs_kv: DFIP_ROLES,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const canEditFirstTableField = (fieldKey, roleId) => FIRST_TABLE_FIELD_ACCESS[fieldKey]?.includes(roleId) ?? false;
|
||||||
Loading…
x
Reference in New Issue
Block a user