From 1f2c8e541193142a99ac58e1b9a31acfce515752 Mon Sep 17 00:00:00 2001 From: PotapovaA Date: Tue, 18 Aug 2026 14:56:38 +0300 Subject: [PATCH] project fix filters --- .../components/common/TableList/TableList.jsx | 2 +- .../components/EditModal/EditModal.jsx | 6 +++- .../components/TableFilters/TableFilters.jsx | 12 ++++++- .../ProjectPages/constants/fieldAccess.js | 35 +++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 web/src/pages/ProjectPages/constants/fieldAccess.js diff --git a/web/src/components/common/TableList/TableList.jsx b/web/src/components/common/TableList/TableList.jsx index 5cf91ab..a0bb1da 100644 --- a/web/src/components/common/TableList/TableList.jsx +++ b/web/src/components/common/TableList/TableList.jsx @@ -26,7 +26,7 @@ const TablesList = ({ filteredTables, query, basePath = '/table', formInfo, isPr groups[year] = [...(groups[year] || []), table]; return groups; }, {}), - ).sort(([firstYear], [secondYear]) => Number(secondYear) - Number(firstYear)) + ).sort(([firstYear], [secondYear]) => Number(firstYear) - Number(secondYear)) : []; return ( diff --git a/web/src/pages/ProjectPages/components/EditModal/EditModal.jsx b/web/src/pages/ProjectPages/components/EditModal/EditModal.jsx index 542dd60..84ce381 100644 --- a/web/src/pages/ProjectPages/components/EditModal/EditModal.jsx +++ b/web/src/pages/ProjectPages/components/EditModal/EditModal.jsx @@ -1,10 +1,13 @@ import CloseIcon from '@mui/icons-material/Close'; import { Box, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, MenuItem, TextField, Typography } from '@mui/material'; import React from 'react'; +import { useAuth } from '../../../../app/context/AuthProvider'; import { DangerOutlinedButton, PrimaryButton } from '../../../../components/common/Buttons/Buttons'; import { DEVELOMENT_BLOCK, FUNDING_BY_DECISION } from '../../constants'; +import { canEditFirstTableField } from '../../constants/fieldAccess'; const EditModal = ({ open, onClose, rowData, onSave, isSaving = false, orgUnitNames = {} }) => { + const { user } = useAuth(); const [formData, setFormData] = React.useState(rowData || {}); React.useEffect(() => { @@ -66,6 +69,7 @@ const EditModal = ({ open, onClose, rowData, onSave, isSaving = false, orgUnitNa // Компонент для поля ввода const renderField = (field) => { const rawValue = formData[field.key]; + const isFieldDisabled = field.disabled || !canEditFirstTableField(field.key, user?.role_id); const fieldValue = field.valueType === 'boolean' && rawValue !== null && rawValue !== undefined ? String(rawValue) : (rawValue ?? ''); @@ -93,7 +97,7 @@ const EditModal = ({ open, onClose, rowData, onSave, isSaving = false, orgUnitNa multiline={field.multiline || false} rows={field.rows || 1} select={Boolean(field.options)} - disabled={field.disabled || isSaving} + disabled={isFieldDisabled || isSaving} InputLabelProps={field.type === 'date' ? { shrink: true } : undefined} sx={{ '& .MuiOutlinedInput-root': { diff --git a/web/src/pages/ProjectPages/components/TableFilters/TableFilters.jsx b/web/src/pages/ProjectPages/components/TableFilters/TableFilters.jsx index 5b9fbee..94ae4c1 100644 --- a/web/src/pages/ProjectPages/components/TableFilters/TableFilters.jsx +++ b/web/src/pages/ProjectPages/components/TableFilters/TableFilters.jsx @@ -8,6 +8,7 @@ import { ROLES_NAME_ID } from '../../../../constants/constants'; const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQuery }) => { const [branches, setBranches] = useState([]); + const [branchInputValue, setBranchInputValue] = useState(''); const [isLoading, setIsLoading] = useState(false); const { user } = useAuth(); @@ -44,6 +45,10 @@ const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQu loadData(); }, [loadData]); + useEffect(() => { + setBranchInputValue(selectedBranch?.title || ''); + }, [selectedBranch]); + return ( option.title || ''} getOptionKey={(option) => option.id} value={selectedBranch || null} + inputValue={branchInputValue} + onInputChange={(event, newInputValue) => { + setBranchInputValue(newInputValue); + }} onChange={(event, newValue) => { onBranchChange(newValue || ''); }} @@ -100,7 +109,7 @@ const TableFilters = ({ onBranchChange, onSearchChange, selectedBranch, searchQu )} clearOnBlur={false} - isOptionEqualToValue={(option, value) => option === value} + isOptionEqualToValue={(option, value) => option.id === value.id} /> { + setBranchInputValue(''); onBranchChange(''); onSearchChange(''); }} diff --git a/web/src/pages/ProjectPages/constants/fieldAccess.js b/web/src/pages/ProjectPages/constants/fieldAccess.js new file mode 100644 index 0000000..11deaf8 --- /dev/null +++ b/web/src/pages/ProjectPages/constants/fieldAccess.js @@ -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;