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

View File

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