diff --git a/rsconcept/frontend/src/components/select/ConstituentaMultiPicker.tsx b/rsconcept/frontend/src/components/select/ConstituentaMultiPicker.tsx index d4d747d0..505151fc 100644 --- a/rsconcept/frontend/src/components/select/ConstituentaMultiPicker.tsx +++ b/rsconcept/frontend/src/components/select/ConstituentaMultiPicker.tsx @@ -94,11 +94,11 @@ function ConstituentaMultiPicker({ id, schema, prefixID, rows, selected, setSele return (
-
+
Выбраны {selected.length} из {schema?.items.length ?? 0} -
+
+ +

Таблица отождествлений

+ + + + ); } export default SubstitutionsTab; diff --git a/rsconcept/frontend/src/dialogs/DlgInlineSynthesis/SubstitutionsTable.tsx b/rsconcept/frontend/src/dialogs/DlgInlineSynthesis/SubstitutionsTable.tsx new file mode 100644 index 00000000..28b0107a --- /dev/null +++ b/rsconcept/frontend/src/dialogs/DlgInlineSynthesis/SubstitutionsTable.tsx @@ -0,0 +1,130 @@ +'use client'; + +import { useCallback, useMemo } from 'react'; +import { BiChevronLeft, BiChevronRight, BiFirstPage, BiLastPage, BiX } from 'react-icons/bi'; + +import ConstituentaBadge from '@/components/info/ConstituentaBadge'; +import DataTable, { createColumnHelper } from '@/components/ui/DataTable'; +import MiniButton from '@/components/ui/MiniButton'; +import { useConceptTheme } from '@/context/ThemeContext'; +import { ISubstitution } from '@/models/rsform'; +import { describeConstituenta } from '@/utils/labels'; + +interface SubstitutionsTableProps { + prefixID: string; + rows?: number; + items: ISubstitution[]; + setItems: React.Dispatch>; +} + +function SubstitutionIcon({ item }: { item: ISubstitution }) { + if (item.deleteRight) { + if (item.takeLeftTerm) { + return ; + } else { + return ; + } + } else { + if (item.takeLeftTerm) { + return ; + } else { + return ; + } + } +} + +const columnHelper = createColumnHelper(); + +function SubstitutionsTable({ items, rows, setItems, prefixID }: SubstitutionsTableProps) { + const { colors } = useConceptTheme(); + + const handleDeleteRow = useCallback( + (row: number) => { + setItems(prev => { + const newItems: ISubstitution[] = []; + prev.forEach((item, index) => { + if (index !== row) { + newItems.push(item); + } + }); + return newItems; + }); + }, + [setItems] + ); + + const columns = useMemo( + () => [ + columnHelper.accessor(item => describeConstituenta(item.leftCst), { + id: 'left_text', + header: 'Описание', + size: 1000, + cell: props =>
{props.getValue()}
+ }), + columnHelper.accessor(item => item.leftCst.alias, { + id: 'left_alias', + header: 'Имя', + size: 65, + cell: props => ( + + ) + }), + columnHelper.display({ + id: 'status', + header: '', + size: 40, + cell: props => + }), + columnHelper.accessor(item => item.rightCst.alias, { + id: 'right_alias', + header: 'Имя', + size: 65, + cell: props => ( + + ) + }), + columnHelper.accessor(item => describeConstituenta(item.rightCst), { + id: 'right_text', + header: 'Описание', + size: 1000, + cell: props =>
{props.getValue()}
+ }), + columnHelper.display({ + id: 'actions', + size: 50, + minSize: 50, + maxSize: 50, + cell: props => ( + } + onClick={() => handleDeleteRow(props.row.index)} + /> + ) + }) + ], + [handleDeleteRow, colors, prefixID] + ); + + return ( + +

Список пуст

+

Добавьте отождествление

+ + } + /> + ); +} + +export default SubstitutionsTable; diff --git a/rsconcept/frontend/src/dialogs/DlgSubstituteCst.tsx b/rsconcept/frontend/src/dialogs/DlgSubstituteCst.tsx index b88c36c4..ddaa1c83 100644 --- a/rsconcept/frontend/src/dialogs/DlgSubstituteCst.tsx +++ b/rsconcept/frontend/src/dialogs/DlgSubstituteCst.tsx @@ -44,18 +44,28 @@ function DlgSubstituteCst({ hideWindow, onSubstitute }: DlgSubstituteCstProps) { hideWindow={hideWindow} canSubmit={canSubmit} onSubmit={handleSubmit} - className={clsx('w-[30rem]', 'px-6 py-3 flex flex-col gap-3 justify-center items-center')} + className={clsx('w-[25rem]', 'px-6 py-3 flex flex-col gap-3 justify-center items-center')} >