Add function to select concept kernel

This commit is contained in:
IRBorisov 2024-04-06 23:09:25 +03:00
parent 6e8801628d
commit 5c52e2a6f8
5 changed files with 29 additions and 12 deletions

View File

@ -33,6 +33,7 @@ export { BiExpand as IconGraphExpand } from 'react-icons/bi';
export { LuMaximize as IconGraphMaximize } from 'react-icons/lu';
export { BiGitBranch as IconGraphInputs } from 'react-icons/bi';
export { BiGitMerge as IconGraphOutputs } from 'react-icons/bi';
export { LuAtom as IconGraphCore } from 'react-icons/lu';
export { BiCheckShield as IconImmutable } from 'react-icons/bi';
export { RiOpenSourceLine as IconPublic } from 'react-icons/ri';

View File

@ -14,10 +14,12 @@ function InfoConstituenta({ data, className, ...restProps }: InfoConstituentaPro
return (
<div className={clsx('dense min-w-[15rem]', className)} {...restProps}>
<h2>Конституента {data.alias}</h2>
<p>
<b>Термин: </b>
{data.term_resolved || data.term_raw}
</p>
{data.term_resolved ? (
<p>
<b>Термин: </b>
{data.term_resolved || data.term_raw}
</p>
) : null}
<p>
<b>Типизация: </b>
{labelCstTypification(data)}

View File

@ -6,6 +6,7 @@ import { useLayoutEffect, useMemo, useState } from 'react';
import DataTable, { createColumnHelper, RowSelectionState } from '@/components/ui/DataTable';
import { useConceptOptions } from '@/context/OptionsContext';
import { ConstituentaID, IConstituenta, IRSForm } from '@/models/rsform';
import { isBasicConcept } from '@/models/rsformAPI';
import { describeConstituenta } from '@/utils/labels';
import ConstituentaBadge from '../info/ConstituentaBadge';
@ -80,7 +81,8 @@ function ConstituentaMultiPicker({ id, schema, prefixID, rows, selected, setSele
</span>
{schema ? (
<SelectGraphToolbar
graph={schema.graph} // prettier: split lines
graph={schema.graph}
core={schema.items.filter(cst => isBasicConcept(cst.cst_type)).map(cst => cst.id)}
setSelected={setSelected}
className='w-full ml-8'
/>

View File

@ -4,6 +4,7 @@ import { Graph } from '@/models/Graph';
import {
IconGraphCollapse,
IconGraphCore,
IconGraphExpand,
IconGraphInputs,
IconGraphMaximize,
@ -15,10 +16,11 @@ import MiniButton from '../ui/MiniButton';
interface SelectGraphToolbarProps extends CProps.Styling {
graph: Graph;
core: number[];
setSelected: React.Dispatch<React.SetStateAction<number[]>>;
}
function SelectGraphToolbar({ className, graph, setSelected, ...restProps }: SelectGraphToolbarProps) {
function SelectGraphToolbar({ className, graph, core, setSelected, ...restProps }: SelectGraphToolbarProps) {
return (
<div className={clsx('cc-icons', className)} {...restProps}>
<MiniButton
@ -51,6 +53,11 @@ function SelectGraphToolbar({ className, graph, setSelected, ...restProps }: Sel
icon={<IconGraphOutputs size='1.25rem' className='icon-primary' />}
onClick={() => setSelected(prev => [...prev, ...graph.expandOutputs(prev)])}
/>
<MiniButton
titleHtml='Выделить ядро'
icon={<IconGraphCore size='1.25rem' className='icon-primary' />}
onClick={() => setSelected([...core, ...graph.expandInputs(core)])}
/>
</div>
);
}

View File

@ -16,6 +16,7 @@ import SelectGraphToolbar from '@/components/select/SelectGraphToolbar';
import MiniButton from '@/components/ui/MiniButton';
import Overlay from '@/components/ui/Overlay';
import { HelpTopic } from '@/models/miscellaneous';
import { isBasicConcept } from '@/models/rsformAPI';
import { useRSEdit } from '../RSEditContext';
@ -62,6 +63,11 @@ function GraphToolbar({
icon={<IconFilter size='1.25rem' className='icon-primary' />}
onClick={showParamsDialog}
/>
<MiniButton
icon={<IconFitImage size='1.25rem' className='icon-primary' />}
title='Граф целиком'
onClick={onResetViewpoint}
/>
<MiniButton
title={!noText ? 'Скрыть текст' : 'Отобразить текст'}
icon={
@ -84,11 +90,6 @@ function GraphToolbar({
}
onClick={toggleFoldDerived}
/>
<MiniButton
icon={<IconFitImage size='1.25rem' className='icon-primary' />}
title='Граф целиком'
onClick={onResetViewpoint}
/>
<MiniButton
icon={<IconRotate3D size='1.25rem' className={orbit ? 'icon-green' : 'icon-primary'} />}
title='Анимация вращения'
@ -113,7 +114,11 @@ function GraphToolbar({
) : null}
<BadgeHelp topic={HelpTopic.GRAPH_TERM} className='max-w-[calc(100vw-4rem)]' offset={4} />
</div>
<SelectGraphToolbar graph={controller.schema!.graph} setSelected={controller.setSelected} />
<SelectGraphToolbar
graph={controller.schema!.graph}
core={controller.schema!.items.filter(cst => isBasicConcept(cst.cst_type)).map(cst => cst.id)}
setSelected={controller.setSelected}
/>
</Overlay>
);
}