From 2e1652e7eef203e388daf1608c96ad6cf6d0f582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=D1=81=20=D0=A1=D1=83=D0=BB=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Tue, 21 Jul 2026 12:01:07 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=BF=D0=BE=D0=B4=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0=B8=D0=BA=20=D0=BF=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D1=86?= =?UTF-8?q?=D0=B5=D0=BB=D0=B8=D0=BA=D0=BE=D0=BC=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B5=20=D0=BF=D1=80=D0=B8=D0=B2?= =?UTF-8?q?=D1=8F=D0=B7=D0=B0=D0=BD=D0=BD=D0=BE=D0=B9=20=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/SubdirectoryFieldConfig.tsx | 2 +- .../components/TableFieldWithSubdirectory.tsx | 36 +------------ client/src/pages/TableEditor.tsx | 54 ++----------------- 3 files changed, 8 insertions(+), 84 deletions(-) diff --git a/client/src/components/SubdirectoryFieldConfig.tsx b/client/src/components/SubdirectoryFieldConfig.tsx index f060e67..f797dd3 100644 --- a/client/src/components/SubdirectoryFieldConfig.tsx +++ b/client/src/components/SubdirectoryFieldConfig.tsx @@ -200,7 +200,7 @@ export default function SubdirectoryFieldConfig({ {selectedSubdirectory && (

- Фильтр: «{selectedTable?.columns?.[selectedSubdirectory.parentColumnIndex ?? 0]?.name || '?'}» = «{selectedSubdirectory.childTable?.columns?.[selectedSubdirectory.childColumnIndex ?? 0]?.name || '?'}» + Подсправочник показывается при выборе привязанных строк родителя.

)} diff --git a/client/src/components/TableFieldWithSubdirectory.tsx b/client/src/components/TableFieldWithSubdirectory.tsx index 99ea39d..8b8f189 100644 --- a/client/src/components/TableFieldWithSubdirectory.tsx +++ b/client/src/components/TableFieldWithSubdirectory.tsx @@ -3,7 +3,7 @@ import { useQuery } from '@tanstack/react-query'; import { apiRequest } from '@/lib/queryClient'; import TableFieldSelect from '@/components/TableFieldSelect'; import TableFieldMultiSelect from '@/components/TableFieldMultiSelect'; -import type { DataTableRow, DataTableSubdirectory } from '@shared/schema'; +import type { DataTableSubdirectory } from '@shared/schema'; interface TableFieldValue { parentId?: string | null; @@ -67,23 +67,6 @@ export default function TableFieldWithSubdirectory({ const showSubdirectory = !!opts.showSubdirectory; const subdirectoryId = opts.subdirectoryId as number | undefined; - const { data: tableData } = useQuery<{ - table: { - rows: DataTableRow[]; - columns: Array<{ name: string }>; - treeColumnIndex: number | null; - treeDisplayColumnIndex: number | null; - treeColumns: number[] | null; - treeDisplayColumns: number[] | null; - }; - }>({ - queryKey: ['/api/directories', tableId], - enabled: !!tableId, - staleTime: 5 * 60 * 1000, - gcTime: 10 * 60 * 1000, - retry: false, - }); - const { data: subdirectoriesData } = useQuery<{ subdirectories: DataTableSubdirectory[] }>({ queryKey: ['/api/directories', tableId, 'subdirectories'], queryFn: async () => { @@ -100,24 +83,11 @@ export default function TableFieldWithSubdirectory({ const { parentId, childId } = parseTableValue(value); - const parentRow = useMemo(() => { - if (!parentId || !tableData?.table?.rows) return null; - return tableData.table.rows.find((r) => r.id.toString() === parentId) || null; - }, [parentId, tableData]); - const isParentLinked = useMemo(() => { if (!subdirectory || !parentId) return false; return subdirectory.parentRowIds?.includes(Number(parentId)) ?? false; }, [subdirectory, parentId]); - const childFilter = useMemo(() => { - if (!subdirectory || !parentRow) return undefined; - const col = String(subdirectory.childColumnIndex ?? 0); - const parentValue = parentRow.values?.[subdirectory.parentColumnIndex ?? 0] ?? ''; - if (!parentValue) return undefined; - return { [col]: parentValue }; - }, [subdirectory, parentRow]); - const handleParentChange = (newParentId: string) => { onChange(serializeTableValue(newParentId || null, null)); }; @@ -144,8 +114,6 @@ export default function TableFieldWithSubdirectory({ const childOptions = { ...opts, tableId: subdirectory.childTableId, - displayColumn: subdirectory.childTable?.columns?.[subdirectory.childColumnIndex ?? 0]?.name || undefined, - filters: childFilter, }; return ( @@ -158,7 +126,7 @@ export default function TableFieldWithSubdirectory({ value={parentId || ''} onChange={handleParentChange} /> - {isParentLinked && childFilter && ( + {isParentLinked && ( (null); const [subdirectoryChildTableId, setSubdirectoryChildTableId] = useState('none'); - const [subdirectoryParentColumnIndex, setSubdirectoryParentColumnIndex] = useState(0); - const [subdirectoryChildColumnIndex, setSubdirectoryChildColumnIndex] = useState(0); const [subdirectoryParentRowIds, setSubdirectoryParentRowIds] = useState>(new Set()); const { filters, sort, setFilter, clearFilter, clearAll, setSort, clearSort, hasActiveFilters } = useColumnFilters(); @@ -213,7 +211,7 @@ export default function TableEditor() { }, [rowEditorOpen, rowEditorInitialValues]); const createSubdirectoryMutation = useMutation({ - mutationFn: async (payload: { childTableId: number; parentColumnIndex: number; childColumnIndex: number; parentRowIds: number[] }) => { + mutationFn: async (payload: { childTableId: number; parentRowIds: number[] }) => { return apiRequest('POST', `/api/directories/${tableId}/subdirectories`, payload); }, onSuccess: () => { @@ -230,7 +228,7 @@ export default function TableEditor() { }); const updateSubdirectoryMutation = useMutation({ - mutationFn: async ({ linkId, payload }: { linkId: number; payload: { childTableId?: number; parentColumnIndex?: number; childColumnIndex?: number; parentRowIds?: number[] } }) => { + mutationFn: async ({ linkId, payload }: { linkId: number; payload: { childTableId?: number; parentRowIds?: number[] } }) => { return apiRequest('PATCH', `/api/directories/${tableId}/subdirectories/${linkId}`, payload); }, onSuccess: () => { @@ -263,8 +261,6 @@ export default function TableEditor() { const resetSubdirectoryForm = () => { setSubdirectoryChildTableId('none'); - setSubdirectoryParentColumnIndex(0); - setSubdirectoryChildColumnIndex(0); setSubdirectoryParentRowIds(new Set()); setEditingSubdirectory(null); }; @@ -273,8 +269,6 @@ export default function TableEditor() { if (link) { setEditingSubdirectory(link); setSubdirectoryChildTableId(link.childTableId?.toString() || 'none'); - setSubdirectoryParentColumnIndex(link.parentColumnIndex ?? 0); - setSubdirectoryChildColumnIndex(link.childColumnIndex ?? 0); setSubdirectoryParentRowIds(new Set(link.parentRowIds || [])); } else { resetSubdirectoryForm(); @@ -298,8 +292,6 @@ export default function TableEditor() { } const payload = { childTableId: childId, - parentColumnIndex: subdirectoryParentColumnIndex, - childColumnIndex: subdirectoryChildColumnIndex, parentRowIds: Array.from(subdirectoryParentRowIds), }; if (editingSubdirectory?.id) { @@ -1793,10 +1785,9 @@ export default function TableEditor() {
{link.childTable?.name || `ID ${link.childTableId}`}
- по столбцу «{columns[link.parentColumnIndex ?? 0]?.name || '?'}» => «{link.childTable?.columns?.[link.childColumnIndex ?? 0]?.name || '?'}» - {link.parentRowIds && link.parentRowIds.length > 0 && ( - ({link.parentRowIds.length} строк) - )} + {link.parentRowIds && link.parentRowIds.length > 0 + ? `Привязан к ${link.parentRowIds.length} строкам` + : 'Не привязан к строкам'}
@@ -1833,41 +1824,6 @@ export default function TableEditor() {
-
-
- - -
-
- - -
-
-