2024-06-27 14:43:06 +03:00
|
|
|
|
import { Handle, Position } from 'reactflow';
|
|
|
|
|
|
2024-08-17 23:43:15 +03:00
|
|
|
|
import { IconConsolidation, IconRSForm } from '@/components/Icons';
|
2024-07-26 00:33:22 +03:00
|
|
|
|
import TooltipOperation from '@/components/info/TooltipOperation';
|
2024-06-27 14:43:06 +03:00
|
|
|
|
import MiniButton from '@/components/ui/MiniButton.tsx';
|
2024-07-24 18:11:28 +03:00
|
|
|
|
import Overlay from '@/components/ui/Overlay';
|
2024-07-26 17:30:37 +03:00
|
|
|
|
import { OssNodeInternal } from '@/models/miscellaneous';
|
2024-07-26 00:33:22 +03:00
|
|
|
|
import { prefixes } from '@/utils/constants';
|
2024-06-27 14:43:06 +03:00
|
|
|
|
|
|
|
|
|
import { useOssEdit } from '../OssEditContext';
|
|
|
|
|
|
2024-07-26 17:30:37 +03:00
|
|
|
|
function OperationNode(node: OssNodeInternal) {
|
2024-06-27 14:43:06 +03:00
|
|
|
|
const controller = useOssEdit();
|
|
|
|
|
|
2024-07-26 17:30:37 +03:00
|
|
|
|
const hasFile = !!node.data.operation.result;
|
2024-06-27 14:43:06 +03:00
|
|
|
|
|
2024-07-24 18:11:28 +03:00
|
|
|
|
const handleOpenSchema = () => {
|
2024-07-26 17:30:37 +03:00
|
|
|
|
controller.openOperationSchema(Number(node.id));
|
2024-06-27 14:43:06 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2024-07-23 23:03:58 +03:00
|
|
|
|
<Handle type='source' position={Position.Bottom} />
|
2024-07-24 18:11:28 +03:00
|
|
|
|
|
2024-08-17 12:16:50 +03:00
|
|
|
|
<Overlay position='top-0 right-0' className='flex flex-col gap-1'>
|
2024-07-24 18:11:28 +03:00
|
|
|
|
<MiniButton
|
2024-08-17 12:16:50 +03:00
|
|
|
|
icon={
|
|
|
|
|
<IconRSForm
|
|
|
|
|
className={hasFile ? 'clr-text-green' : 'clr-text-red'}
|
|
|
|
|
size={node.data.operation.is_consolidation ? '0.6rem' : '0.75rem'}
|
|
|
|
|
/>
|
|
|
|
|
}
|
2024-07-24 18:11:28 +03:00
|
|
|
|
noHover
|
2024-08-17 12:16:50 +03:00
|
|
|
|
noPadding
|
|
|
|
|
title={hasFile ? 'Связанная КС' : 'Нет связанной КС'}
|
2024-07-28 00:37:33 +03:00
|
|
|
|
hideTitle={!controller.showTooltip}
|
2024-07-28 21:29:46 +03:00
|
|
|
|
onClick={handleOpenSchema}
|
2024-07-24 18:11:28 +03:00
|
|
|
|
disabled={!hasFile}
|
|
|
|
|
/>
|
2024-08-17 12:16:50 +03:00
|
|
|
|
{node.data.operation.is_consolidation ? (
|
|
|
|
|
<MiniButton
|
2024-08-17 23:43:15 +03:00
|
|
|
|
icon={<IconConsolidation className='clr-text-primary' size='0.6rem' />}
|
2024-08-17 12:16:50 +03:00
|
|
|
|
disabled
|
|
|
|
|
noPadding
|
|
|
|
|
noHover
|
2024-08-17 23:43:15 +03:00
|
|
|
|
titleHtml='<b>Внимание!</b><br />Ромбовидный синтез</br/>Возможны дубликаты конституент'
|
2024-08-17 12:16:50 +03:00
|
|
|
|
hideTitle={!controller.showTooltip}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
2024-07-24 18:11:28 +03:00
|
|
|
|
</Overlay>
|
2024-07-26 00:33:22 +03:00
|
|
|
|
|
2024-08-15 23:23:10 +03:00
|
|
|
|
{!node.data.operation.is_owned ? (
|
|
|
|
|
<Overlay position='left-[0.2rem] top-[0.1rem]'>
|
|
|
|
|
<div className='border rounded-none clr-input h-[1.3rem]'></div>
|
|
|
|
|
</Overlay>
|
|
|
|
|
) : null}
|
|
|
|
|
|
2024-08-02 11:17:27 +03:00
|
|
|
|
<div id={`${prefixes.operation_list}${node.id}`} className='flex-grow text-center'>
|
2024-07-26 17:30:37 +03:00
|
|
|
|
{node.data.label}
|
2024-07-26 21:08:31 +03:00
|
|
|
|
{controller.showTooltip && !node.dragging ? (
|
|
|
|
|
<TooltipOperation anchor={`#${prefixes.operation_list}${node.id}`} node={node} />
|
|
|
|
|
) : null}
|
2024-07-26 00:33:22 +03:00
|
|
|
|
</div>
|
2024-06-27 14:43:06 +03:00
|
|
|
|
|
2024-07-23 23:03:58 +03:00
|
|
|
|
<Handle type='target' position={Position.Top} id='left' style={{ left: 40 }} />
|
|
|
|
|
<Handle type='target' position={Position.Top} id='right' style={{ right: 40, left: 'auto' }} />
|
2024-06-27 14:43:06 +03:00
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default OperationNode;
|