-
);
}
diff --git a/rsconcept/frontend/src/dialogs/DlgInlineSynthesis/SubstitutionsTab.tsx b/rsconcept/frontend/src/dialogs/DlgInlineSynthesis/SubstitutionsTab.tsx
index 53805fe0..7fb7459c 100644
--- a/rsconcept/frontend/src/dialogs/DlgInlineSynthesis/SubstitutionsTab.tsx
+++ b/rsconcept/frontend/src/dialogs/DlgInlineSynthesis/SubstitutionsTab.tsx
@@ -1,18 +1,165 @@
'use client';
-import { ICstSubstituteData, IRSForm } from '@/models/rsform';
+import { useState } from 'react';
+import { LuLocate, LuLocateOff, LuPower, LuPowerOff, LuReplace } from 'react-icons/lu';
+
+import { ErrorData } from '@/components/info/InfoError';
+import ConstituentaSelector from '@/components/select/ConstituentaSelector';
+import Button from '@/components/ui/Button';
+import Label from '@/components/ui/Label';
+import MiniButton from '@/components/ui/MiniButton';
+import Overlay from '@/components/ui/Overlay';
+import DataLoader from '@/components/wrap/DataLoader';
+import { ConstituentaID, IConstituenta, IRSForm, ISubstitution } from '@/models/rsform';
+import { prefixes } from '@/utils/constants';
+
+import SubstitutionsTable from './SubstitutionsTable';
interface SubstitutionsTabProps {
receiver?: IRSForm;
source?: IRSForm;
+ selected: ConstituentaID[];
+
loading?: boolean;
- substitutions: ICstSubstituteData[];
- setSubstitutions: React.Dispatch
;
+ error?: ErrorData;
+
+ substitutions: ISubstitution[];
+ setSubstitutions: React.Dispatch>;
}
-// { source, receiver, loading, substitutions, setSubstitutions }: SubstitutionsTabProps
-function SubstitutionsTab(props: SubstitutionsTabProps) {
- return <>3 - {props.loading}>;
+function SubstitutionsTab({
+ source,
+ receiver,
+ selected,
+
+ error,
+ loading,
+
+ substitutions,
+ setSubstitutions
+}: SubstitutionsTabProps) {
+ const [leftCst, setLeftCst] = useState(undefined);
+ const [rightCst, setRightCst] = useState(undefined);
+ const [deleteRight, setDeleteRight] = useState(false);
+ const [takeLeftTerm, setTakeLeftTerm] = useState(false);
+
+ const toggleDelete = () => setDeleteRight(prev => !prev);
+ const toggleTerm = () => setTakeLeftTerm(prev => !prev);
+
+ function addSubstitution() {
+ if (!leftCst || !rightCst) {
+ return;
+ }
+ const newSubstitution: ISubstitution = {
+ leftCst: leftCst,
+ rightCst: rightCst,
+ deleteRight: deleteRight,
+ takeLeftTerm: takeLeftTerm
+ };
+ setSubstitutions([
+ newSubstitution,
+ ...substitutions.filter(
+ item =>
+ (!item.deleteRight && item.leftCst.id !== leftCst.id) ||
+ (item.deleteRight && item.rightCst.id !== rightCst.id)
+ )
+ ]);
+ }
+
+ return (
+
+
+
+
+
+ ) : (
+
+ )
+ }
+ />
+
+ ) : (
+
+ )
+ }
+ />
+
+
+ selected.includes(cst.id))}
+ value={leftCst}
+ onSelectValue={setLeftCst}
+ />
+
+
+
}
+ disabled={!leftCst || !rightCst}
+ onClick={addSubstitution}
+ />
+
+
+
+
+ ) : (
+
+ )
+ }
+ />
+
+ ) : (
+
+ )
+ }
+ />
+
+
+
+
+
+
+ Таблица отождествлений
+
+
+
+ );
}
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')}
>
-
+
-
+