M: Minor UI fixes

This commit is contained in:
Ivan 2024-08-20 14:35:46 +03:00
parent 3f8fab80aa
commit 0b9e599d6e
2 changed files with 8 additions and 10 deletions

View File

@ -22,29 +22,24 @@ function NodeCore({ node }: NodeCoreProps) {
const longLabel = node.data.label.length > PARAMETER.ossLongLabel; const longLabel = node.data.label.length > PARAMETER.ossLongLabel;
const labelText = truncateToLastWord(node.data.label, PARAMETER.ossTruncateLabel); const labelText = truncateToLastWord(node.data.label, PARAMETER.ossTruncateLabel);
const handleOpenSchema = () => {
controller.openOperationSchema(Number(node.id));
};
return ( return (
<> <>
<Overlay position='top-0 right-0' className='flex flex-col gap-1 p-[2px]'> <Overlay position='top-0 right-0' className='flex flex-col gap-1 p-[2px]'>
<MiniButton <MiniButton
icon={<IconRSForm className={hasFile ? 'clr-text-green' : 'clr-text-red'} size='12px' />} disabled
noHover noHover
noPadding noPadding
title={hasFile ? 'Связанная КС' : 'Нет связанной КС'} title={hasFile ? 'Связанная КС' : 'Нет связанной КС'}
icon={<IconRSForm className={hasFile ? 'clr-text-green' : 'clr-text-red'} size='12px' />}
hideTitle={!controller.showTooltip} hideTitle={!controller.showTooltip}
onClick={handleOpenSchema}
disabled={!hasFile}
/> />
{node.data.operation.is_consolidation ? ( {node.data.operation.is_consolidation ? (
<MiniButton <MiniButton
icon={<IconConsolidation className='clr-text-primary' size='12px' />}
disabled disabled
noPadding noPadding
noHover noHover
titleHtml='<b>Внимание!</b><br />Ромбовидный синтез</br/>Возможны дубликаты конституент' titleHtml='<b>Внимание!</b><br />Ромбовидный синтез</br/>Возможны дубликаты конституент'
icon={<IconConsolidation className='clr-text-primary' size='12px' />}
hideTitle={!controller.showTooltip} hideTitle={!controller.showTooltip}
/> />
) : null} ) : null}

View File

@ -239,6 +239,9 @@ function OssFlow({ isModified, setIsModified }: OssFlowProps) {
}, []); }, []);
const handleSaveImage = useCallback(() => { const handleSaveImage = useCallback(() => {
if (!model.schema) {
return;
}
const canvas: HTMLElement | null = document.querySelector('.react-flow__viewport'); const canvas: HTMLElement | null = document.querySelector('.react-flow__viewport');
if (canvas === null) { if (canvas === null) {
toast.error(errors.imageFailed); toast.error(errors.imageFailed);
@ -261,7 +264,7 @@ function OssFlow({ isModified, setIsModified }: OssFlowProps) {
}) })
.then(dataURL => { .then(dataURL => {
const a = document.createElement('a'); const a = document.createElement('a');
a.setAttribute('download', 'reactflow.svg'); a.setAttribute('download', `${model.schema?.alias ?? 'oss'}.svg`);
a.setAttribute('href', dataURL); a.setAttribute('href', dataURL);
a.click(); a.click();
}) })
@ -269,7 +272,7 @@ function OssFlow({ isModified, setIsModified }: OssFlowProps) {
console.error(error); console.error(error);
toast.error(errors.imageFailed); toast.error(errors.imageFailed);
}); });
}, [colors, nodes]); }, [colors, nodes, model.schema]);
const handleContextMenu = useCallback( const handleContextMenu = useCallback(
(event: CProps.EventMouse, node: OssNode) => { (event: CProps.EventMouse, node: OssNode) => {