M: Improve typification and expression visibility
This commit is contained in:
parent
02afd44488
commit
a6742a7b7c
|
@ -25,12 +25,12 @@ function InfoConstituenta({ data, className, ...restProps }: InfoConstituentaPro
|
||||||
) : null}
|
) : null}
|
||||||
<p className='break-all'>
|
<p className='break-all'>
|
||||||
<b>Типизация: </b>
|
<b>Типизация: </b>
|
||||||
{labelCstTypification(data)}
|
<span className='font-math'>{labelCstTypification(data)}</span>
|
||||||
</p>
|
</p>
|
||||||
{data.definition_formal ? (
|
{data.definition_formal ? (
|
||||||
<p>
|
<p>
|
||||||
<b>Выражение: </b>
|
<b>Выражение: </b>
|
||||||
{data.definition_formal}
|
<span className='font-math'>{data.definition_formal}</span>
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
{data.definition_resolved ? (
|
{data.definition_resolved ? (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
|
|
||||||
import { globals } from '@/utils/constants';
|
import { globals } from '@/utils/constants';
|
||||||
import { truncateText } from '@/utils/utils';
|
import { truncateToLastWord } from '@/utils/utils';
|
||||||
|
|
||||||
import { CProps } from '../props';
|
import { CProps } from '../props';
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ export interface TextContentProps extends CProps.Styling {
|
||||||
}
|
}
|
||||||
|
|
||||||
function TextContent({ className, text, maxLength, ...restProps }: TextContentProps) {
|
function TextContent({ className, text, maxLength, ...restProps }: TextContentProps) {
|
||||||
const truncated = maxLength ? truncateText(text, maxLength) : text;
|
const truncated = maxLength ? truncateToLastWord(text, maxLength) : text;
|
||||||
const isTruncated = maxLength && text.length > maxLength;
|
const isTruncated = maxLength && text.length > maxLength;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -6,7 +6,7 @@ import MiniButton from '@/components/ui/MiniButton.tsx';
|
||||||
import Overlay from '@/components/ui/Overlay';
|
import Overlay from '@/components/ui/Overlay';
|
||||||
import { OssNodeInternal } from '@/models/miscellaneous';
|
import { OssNodeInternal } from '@/models/miscellaneous';
|
||||||
import { PARAMETER, prefixes } from '@/utils/constants';
|
import { PARAMETER, prefixes } from '@/utils/constants';
|
||||||
import { truncateText } from '@/utils/utils';
|
import { truncateToLastWord } from '@/utils/utils';
|
||||||
|
|
||||||
import { useOssEdit } from '../OssEditContext';
|
import { useOssEdit } from '../OssEditContext';
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ function InputNode(node: OssNodeInternal) {
|
||||||
|
|
||||||
const hasFile = !!node.data.operation.result;
|
const hasFile = !!node.data.operation.result;
|
||||||
const longLabel = node.data.label.length > PARAMETER.ossLongLabel;
|
const longLabel = node.data.label.length > PARAMETER.ossLongLabel;
|
||||||
const labelText = truncateText(node.data.label, PARAMETER.ossTruncateLabel);
|
const labelText = truncateToLastWord(node.data.label, PARAMETER.ossTruncateLabel);
|
||||||
|
|
||||||
const handleOpenSchema = () => {
|
const handleOpenSchema = () => {
|
||||||
controller.openOperationSchema(Number(node.id));
|
controller.openOperationSchema(Number(node.id));
|
||||||
|
|
|
@ -8,7 +8,7 @@ import MiniButton from '@/components/ui/MiniButton.tsx';
|
||||||
import Overlay from '@/components/ui/Overlay';
|
import Overlay from '@/components/ui/Overlay';
|
||||||
import { OssNodeInternal } from '@/models/miscellaneous';
|
import { OssNodeInternal } from '@/models/miscellaneous';
|
||||||
import { PARAMETER, prefixes } from '@/utils/constants';
|
import { PARAMETER, prefixes } from '@/utils/constants';
|
||||||
import { truncateText } from '@/utils/utils';
|
import { truncateToLastWord } from '@/utils/utils';
|
||||||
|
|
||||||
import { useOssEdit } from '../OssEditContext';
|
import { useOssEdit } from '../OssEditContext';
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ function OperationNode(node: OssNodeInternal) {
|
||||||
|
|
||||||
const hasFile = !!node.data.operation.result;
|
const hasFile = !!node.data.operation.result;
|
||||||
const longLabel = node.data.label.length > PARAMETER.ossLongLabel;
|
const longLabel = node.data.label.length > PARAMETER.ossLongLabel;
|
||||||
const labelText = truncateText(node.data.label, PARAMETER.ossTruncateLabel);
|
const labelText = truncateToLastWord(node.data.label, PARAMETER.ossTruncateLabel);
|
||||||
|
|
||||||
const handleOpenSchema = () => {
|
const handleOpenSchema = () => {
|
||||||
controller.openOperationSchema(Number(node.id));
|
controller.openOperationSchema(Number(node.id));
|
||||||
|
|
|
@ -12,8 +12,9 @@ import TextURL from '@/components/ui/TextURL';
|
||||||
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
||||||
import useWindowSize from '@/hooks/useWindowSize';
|
import useWindowSize from '@/hooks/useWindowSize';
|
||||||
import { ConstituentaID, IConstituenta } from '@/models/rsform';
|
import { ConstituentaID, IConstituenta } from '@/models/rsform';
|
||||||
import { prefixes } from '@/utils/constants';
|
import { PARAMETER, prefixes } from '@/utils/constants';
|
||||||
import { labelCstTypification } from '@/utils/labels';
|
import { labelCstTypification } from '@/utils/labels';
|
||||||
|
import { truncateToSymbol } from '@/utils/utils';
|
||||||
|
|
||||||
interface TableRSListProps {
|
interface TableRSListProps {
|
||||||
items?: IConstituenta[];
|
items?: IConstituenta[];
|
||||||
|
@ -90,8 +91,13 @@ function TableRSList({
|
||||||
id: 'type',
|
id: 'type',
|
||||||
header: 'Типизация',
|
header: 'Типизация',
|
||||||
enableHiding: true,
|
enableHiding: true,
|
||||||
|
size: 150,
|
||||||
|
minSize: 150,
|
||||||
|
maxSize: 200,
|
||||||
cell: props => (
|
cell: props => (
|
||||||
<div className={clsx('min-w-[9.3rem] max-w-[9.3rem]', 'text-sm break-words')}>{props.getValue()}</div>
|
<div className={clsx('min-w-[9.3rem] max-w-[9.3rem]', 'text-xs break-words')}>
|
||||||
|
{truncateToSymbol(props.getValue(), PARAMETER.typificationTruncate)}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor(cst => cst.term_resolved || cst.term_raw || '', {
|
columnHelper.accessor(cst => cst.term_resolved || cst.term_raw || '', {
|
||||||
|
|
|
@ -25,6 +25,8 @@ export const PARAMETER = {
|
||||||
graphPopupDelay: 500, // milliseconds delay for graph popup selections
|
graphPopupDelay: 500, // milliseconds delay for graph popup selections
|
||||||
graphRefreshDelay: 10, // milliseconds delay for graph viewpoint reset
|
graphRefreshDelay: 10, // milliseconds delay for graph viewpoint reset
|
||||||
|
|
||||||
|
typificationTruncate: 42, // characters - threshold for long typification - truncate
|
||||||
|
|
||||||
ossLongLabel: 14, // characters - threshold for long labels - small font
|
ossLongLabel: 14, // characters - threshold for long labels - small font
|
||||||
ossTruncateLabel: 28, // characters - threshold for long labels - truncate
|
ossTruncateLabel: 28, // characters - threshold for long labels - truncate
|
||||||
|
|
||||||
|
|
|
@ -67,9 +67,9 @@ export function applyPattern(text: string, mapping: Record<string, string>, patt
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Truncate text to max symbols. Add ellipsis if truncated.
|
* Truncate text to last word up to max symbols. Add ellipsis if truncated.
|
||||||
*/
|
*/
|
||||||
export function truncateText(text: string, maxSymbols: number): string {
|
export function truncateToLastWord(text: string, maxSymbols: number): string {
|
||||||
if (text.length <= maxSymbols) {
|
if (text.length <= maxSymbols) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,17 @@ export function truncateText(text: string, maxSymbols: number): string {
|
||||||
return trimmedText.slice(0, lastSpaceIndex) + '...';
|
return trimmedText.slice(0, lastSpaceIndex) + '...';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Truncate text to max symbols. Add ellipsis if truncated.
|
||||||
|
*/
|
||||||
|
export function truncateToSymbol(text: string, maxSymbols: number): string {
|
||||||
|
if (text.length <= maxSymbols) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
const trimmedText = text.slice(0, maxSymbols);
|
||||||
|
return trimmedText + '...';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if Axios response is html.
|
* Check if Axios response is html.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user