mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
M: Remove expression column from sideview
This commit is contained in:
parent
89889c9f40
commit
ce73be22bf
|
@ -1,12 +1,11 @@
|
|||
'use client';
|
||||
|
||||
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
||||
import { useCallback, useLayoutEffect, useMemo } from 'react';
|
||||
|
||||
import BadgeConstituenta from '@/components/info/BadgeConstituenta';
|
||||
import DataTable, { createColumnHelper, IConditionalStyle, VisibilityState } from '@/components/ui/DataTable';
|
||||
import DataTable, { createColumnHelper, IConditionalStyle } from '@/components/ui/DataTable';
|
||||
import NoData from '@/components/ui/NoData';
|
||||
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
||||
import useWindowSize from '@/hooks/useWindowSize';
|
||||
import { ConstituentaID, IConstituenta } from '@/models/rsform';
|
||||
import { isMockCst } from '@/models/rsformAPI';
|
||||
import { PARAMETER, prefixes } from '@/utils/constants';
|
||||
|
@ -16,7 +15,6 @@ interface TableSideConstituentsProps {
|
|||
items: IConstituenta[];
|
||||
activeCst?: IConstituenta;
|
||||
onOpenEdit: (cstID: ConstituentaID) => void;
|
||||
denseThreshold?: number;
|
||||
autoScroll?: boolean;
|
||||
maxHeight: string;
|
||||
}
|
||||
|
@ -28,13 +26,9 @@ function TableSideConstituents({
|
|||
activeCst,
|
||||
autoScroll = true,
|
||||
onOpenEdit,
|
||||
maxHeight,
|
||||
denseThreshold = 9999
|
||||
maxHeight
|
||||
}: TableSideConstituentsProps) {
|
||||
const { colors } = useConceptOptions();
|
||||
const windowSize = useWindowSize();
|
||||
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({ expression: true });
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!activeCst) {
|
||||
|
@ -54,17 +48,6 @@ function TableSideConstituents({
|
|||
}
|
||||
}, [activeCst, autoScroll]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setColumnVisibility(prev => {
|
||||
const newValue = (windowSize.width ?? 0) >= denseThreshold;
|
||||
if (newValue === prev.expression) {
|
||||
return prev;
|
||||
} else {
|
||||
return { expression: newValue };
|
||||
}
|
||||
});
|
||||
}, [windowSize, denseThreshold]);
|
||||
|
||||
const handleRowClicked = useCallback(
|
||||
(cst: IConstituenta) => {
|
||||
if (!isMockCst(cst)) {
|
||||
|
@ -103,25 +86,6 @@ function TableSideConstituents({
|
|||
{props.getValue()}
|
||||
</div>
|
||||
)
|
||||
}),
|
||||
columnHelper.accessor('definition_formal', {
|
||||
id: 'expression',
|
||||
header: 'Выражение',
|
||||
size: 2000,
|
||||
minSize: 0,
|
||||
maxSize: 2000,
|
||||
enableHiding: true,
|
||||
cell: props => (
|
||||
<div
|
||||
style={{
|
||||
textWrap: 'pretty',
|
||||
fontSize: 12,
|
||||
color: isMockCst(props.row.original) ? colors.fgWarning : undefined
|
||||
}}
|
||||
>
|
||||
{props.getValue()}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
],
|
||||
[colors]
|
||||
|
@ -162,8 +126,6 @@ function TableSideConstituents({
|
|||
conditionalRowStyles={conditionalRowStyles}
|
||||
headPosition='0'
|
||||
enableHiding
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
noDataComponent={
|
||||
<NoData className='min-h-[5rem]'>
|
||||
<p>Список конституент пуст</p>
|
||||
|
|
|
@ -14,9 +14,6 @@ import { animateSideView } from '@/styling/animations';
|
|||
import ConstituentsSearch from './ConstituentsSearch';
|
||||
import TableSideConstituents from './TableSideConstituents';
|
||||
|
||||
// Window width cutoff for expression show
|
||||
const COLUMN_EXPRESSION_HIDE_THRESHOLD = 1500;
|
||||
|
||||
// Window width cutoff for dense search bar
|
||||
const COLUMN_DENSE_SEARCH_THRESHOLD = 1100;
|
||||
|
||||
|
@ -47,7 +44,6 @@ function ViewConstituents({ expression, schema, activeCst, isBottom, onOpenEdit
|
|||
activeCst={activeCst}
|
||||
onOpenEdit={onOpenEdit}
|
||||
autoScroll={!isBottom}
|
||||
denseThreshold={COLUMN_EXPRESSION_HIDE_THRESHOLD}
|
||||
/>
|
||||
),
|
||||
[isBottom, filteredData, activeCst, onOpenEdit, calculateHeight, accessLevel]
|
||||
|
|
Loading…
Reference in New Issue
Block a user